Skip to content

Address review feedback for test setup, test type coverage, and component state keys#65

Merged
JosunLP merged 5 commits intodevelopmentfrom
copilot/sub-pr-64
Mar 14, 2026
Merged

Address review feedback for test setup, test type coverage, and component state keys#65
JosunLP merged 5 commits intodevelopmentfrom
copilot/sub-pr-64

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 14, 2026

This updates the v1.6.0 branch to address the review-thread follow-ups around test environment correctness, incomplete test type-check coverage, and the public component state helper types. The main effect is that the existing test:types step now checks the full test suite, and the typed component state API better matches runtime behavior.

  • Test environment shim

    • Fixed the getComputedStyle global setup to call the window method with the correct receiver instead of using an unbound function reference.
    • Keeps happy-dom-backed style assertions aligned with browser method semantics.
  • Full test type-check coverage

    • Expanded tsconfig.component-test.json from a single component test file to the full tests/ tree.
    • Cleaned up the newly included test files so the “Type-check tests” step reflects the whole suite instead of a narrow subset.
  • Component state helper typing

    • Constrained typed setState() / getState() keys to string keys only.
    • Added a dedicated ComponentStateKey alias to make that contract explicit in the public type surface.
  • Related typing cleanup surfaced by wider coverage

    • Tightened nullable assertions in tests where Bun’s assertion overloads were too narrow.
    • Normalized a few store action generic constraints so action inference remains callable under the broader test typecheck.
    • Added a small helper/comment for Bun’s augmented fetch.preconnect shape in tests.
type CounterState = { count: number; ready: boolean };

declare const el: ComponentElement<CounterState>;

el.getState('count'); // number
el.setState('ready', true);

// now rejected at the type level
el.getState(0);

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 2 commits March 14, 2026 00:29
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to version 1.6.0 for @bquery/bquery Address review feedback for test setup, test type coverage, and component state keys Mar 14, 2026
Copilot AI requested a review from JosunLP March 14, 2026 00:33
@JosunLP JosunLP marked this pull request as ready for review March 14, 2026 00:44
Copilot AI review requested due to automatic review settings March 14, 2026 00:44
@github-actions github-actions bot added component Changes to the component module store Changes to the store module tests Chenges to the tests build Changes to the build and meta files labels Mar 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the v1.6.0 branch to improve test environment correctness, expand TypeScript type-check coverage across the full test suite, and align component/store typings with runtime behavior.

Changes:

  • Expanded tsconfig.component-test.json to type-check all files under tests/.
  • Fixed getComputedStyle test shim to use a properly bound window method receiver.
  • Tightened typings across component state keys and store action generics; updated tests to satisfy the broader type-check surface.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsconfig.component-test.json Expands TS include set to cover the full tests/ tree.
tests/view.test.ts Adds explicit signal object typing to satisfy stricter test type-checking.
tests/utils.test.ts Switches to hasOwnProperty.call checks to avoid typing/runtime issues with Object.hasOwn.
tests/store.test.ts Adds explicit store generics so actions remain callable under stricter typing.
tests/signal.test.ts Adds a helper to model Bun’s fetch.preconnect typing in mocks; adjusts related assertions/types.
tests/setup.ts Binds window.getComputedStyle before assigning it to globalThis.
tests/security.test.ts Casts sanitized result to string for assertion compatibility.
tests/router.test.ts Tightens route typing and removes unused guard tracking.
tests/motion.test.ts Introduces a ViewTransition mock helper and aligns startViewTransition typing with DOM lib types.
tests/core.test.ts Tightens null assertions and event delegation expectations under stricter typings.
tests/component.test.ts Adds a type-level assertion that numeric state keys are rejected.
src/store/watch.ts Loosens action function constraints to any[]/any to allow specific parameter types.
src/store/types.ts Refactors Actions typing to rely on ThisType for correct this in action bodies.
src/store/persisted.ts Loosens action function constraints to support specific parameter types.
src/store/mapping.ts Loosens action function constraints to support specific parameter types.
src/store/define-store.ts Loosens action function constraints to support specific parameter types.
src/component/types.ts Constrains component state keys to string and introduces a ComponentStateKey alias.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 14, 2026

@copilot apply changes based on the comments in this thread

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 14, 2026

@copilot apply changes based on the comments in this thread

Applied the export fix in commit 7f1b084. ComponentStateKey is now exported from the component types module and re-exported from both the component and full entrypoints. No UI changes were involved.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the v1.6.0 branch to ensure the test:types step type-checks the entire tests/ suite, fixes a subtle test environment shim issue, and aligns public component/store typings with runtime behavior and TS/Bun constraints.

Changes:

  • Expand tsconfig.component-test.json to include all tests and adjust test files to type-check under the widened coverage.
  • Fix the test getComputedStyle global shim by binding the window receiver correctly.
  • Refine public typings: constrain component state keys to string keys and loosen store action generic constraints to support specific parameter types.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsconfig.component-test.json Includes the full tests/ tree in the type-check config.
tests/setup.ts Binds window.getComputedStyle to preserve correct receiver semantics.
tests/view.test.ts Tightens the signal object typing to support style property removal scenarios.
tests/utils.test.ts Uses a more broadly-compatible own-property check for security regression tests.
tests/store.test.ts Makes store generics explicit to keep action callability under full-suite type-checking.
tests/signal.test.ts Adds an asMockFetch helper to model Bun’s augmented fetch shape in tests.
tests/security.test.ts Ensures assertions compare against string values for branded HTML outputs.
tests/router.test.ts Adds missing route typing and cleans up guard assertions under stricter checking.
tests/motion.test.ts Improves startViewTransition mocking to match the DOM typing surface more closely.
tests/core.test.ts Narrows nullable DOM values before dispatch/assertions for stricter typing.
tests/component.test.ts Adds a type-level assertion that numeric state keys are rejected.
src/store/types.ts Updates Actions typing to use ThisType and relaxes action function constraints.
src/store/watch.ts Relaxes action constraints to accept specifically-typed action parameters.
src/store/persisted.ts Same action constraint relaxation for persisted stores.
src/store/mapping.ts Same action constraint relaxation for mapActions.
src/store/define-store.ts Same action constraint relaxation for defineStore.
src/component/types.ts Introduces ComponentStateKey and uses it for getState/setState key typing.
src/component/index.ts Re-exports ComponentStateKey from the component entry point.
src/full.ts Re-exports ComponentStateKey from the full bundle entry point.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 14, 2026

@copilot apply changes based on the comments in this thread

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 14, 2026

@copilot apply changes based on the comments in this thread

Applied in commit 6a8c264. ComponentStateKey now defaults its state generic to undefined, so it can be referenced without an explicit type argument while staying aligned with the related component helper types. No UI changes were involved.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens TypeScript correctness across the project by expanding test-suite type-checking, fixing a subtle test environment shim issue, and refining public component/store typing so it better matches runtime behavior.

Changes:

  • Expand test:types coverage to type-check the entire tests/ tree and adjust affected tests to satisfy stricter typing.
  • Fix the getComputedStyle global shim to use the correct receiver, aligning happy-dom behavior with browser semantics.
  • Refine public typings: add ComponentStateKey and constrain component state access to string keys; adjust store action typing to keep actions callable with specific parameter types.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tsconfig.component-test.json Expands type-check coverage from a single test file to the full tests/ directory.
tests/setup.ts Binds window.getComputedStyle to ensure correct receiver semantics in the global shim.
tests/signal.test.ts Adds a typed fetch mock helper compatible with Bun’s augmented fetch shape.
tests/store.test.ts Adds explicit store generics so action signatures remain callable under broader test type-checking.
src/store/types.ts Updates Actions typing to use ThisType and preserves specific action parameter typing.
src/store/watch.ts Relaxes action generic constraints to allow specific action parameter types.
src/store/define-store.ts Aligns action generic constraints with callable action signatures.
src/store/persisted.ts Aligns action generic constraints with callable action signatures.
src/store/mapping.ts Aligns action generic constraints with callable action signatures.
src/component/types.ts Introduces ComponentStateKey and constrains typed getState/setState keys to strings.
src/component/index.ts Re-exports ComponentStateKey as part of the public component API surface.
src/full.ts Re-exports ComponentStateKey from the full bundle entrypoint.
tests/component.test.ts Adds a type-level assertion ensuring numeric state keys are rejected.
tests/security.test.ts Adjusts assertion to match branded/typed sanitize return values.
tests/utils.test.ts Switches prototype-pollution assertions to a hasOwnProperty.call form that type-checks broadly.
tests/view.test.ts Narrows signal object typing to allow property removal while maintaining type safety.
tests/router.test.ts Improves guard typing/narrowing under expanded test type-checking.
tests/motion.test.ts Updates startViewTransition mocking to match the DOM lib type and newer overload shape.
tests/core.test.ts Tightens null assertions for DOM queries to satisfy stricter typing.

@JosunLP JosunLP merged commit cbf358f into development Mar 14, 2026
14 checks passed
@JosunLP JosunLP deleted the copilot/sub-pr-64 branch March 14, 2026 01:14
JosunLP added a commit that referenced this pull request Mar 15, 2026
* Add `bool()` support for boolean attributes in component templates (#55)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Add typed state generics to component definitions (#56)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Pass attribute change metadata to component `updated()` hooks (#58)

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Add per-component sanitizer overrides for component render output (#57)

* Initial plan

* feat: add per-component sanitizer options

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: clarify component sanitizer baseline

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: warn about sensitive component sanitizer opts

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: cover sanitizer allowTags overrides

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* perf: precompute component sanitizer allowlists

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Signed-off-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Pass previous props into component `beforeUpdate` (#59)

* Initial plan

* Add previous props to beforeUpdate hook

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Refine beforeUpdate old props implementation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix beforeUpdate typing regressions

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Signed-off-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Add explicit signal subscriptions to `component()` renders (#60)

* Initial plan

* feat: add component signal subscriptions

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* chore: document signal subscription tracking

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: address signal integration review feedback

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: tighten component signal typing

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: resolve eslint failure in component signal test

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: handle reconnect lifecycle and signal effect errors

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: preserve reconnect signal wiring after hook errors

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: skip beforeUpdate for signal rerenders

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Signed-off-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Add trusted sanitized fragments for `safeHtml` composition (#61)

* Initial plan

* feat: add trusted safeHtml fragment support

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* chore: finalize trusted safeHtml support

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: address trusted safeHtml review feedback

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: fix second trusted safeHtml review follow-up

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* refactor: split trusted html helpers from sanitizer

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* refactor: tighten trusted html branding

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: tighten trusted html internals

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Signed-off-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>

* Reuse component shadow-root style nodes across re-renders (#62)

* Initial plan

* fix: reuse component style element on rerender

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* chore: finalize component style reuse fix

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: tighten style reuse regression assertions

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Add `@bquery/bquery/storybook` template helpers for Storybook stories (#63)

* Initial plan

* feat: add storybook template helper

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs: clarify storybook when fallback behavior

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: keep storybook helpers out of full bundle

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix: sanitize storybook helper output

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* test: tighten storybook helper security coverage

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* feat: enhance storyHtml with improved boolean attribute handling and sanitization tests

* fix: update storyHtml example to reflect correct boolean attribute output

* fix: defensive tag delimiter and parser comments per code review

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* chore: release version 1.6.0

- Update CHANGELOG.md for version 1.6.0 release notes including added features, changes, fixes, and security improvements.
- Enhance README.md to document new boolean attribute helpers and Storybook integration.
- Update bun.lock to reflect dependency upgrades for Storybook and happy-dom.
- Modify definition.md to include new Storybook helpers and component state management features.
- Revise components.md to demonstrate new boolean attribute handling and typed state in components.
- Update getting-started.md with Storybook authoring examples and improved module descriptions.
- Enhance security.md to clarify sanitization practices and introduce trusted fragment handling.
- Revise index.md to highlight new Storybook helpers in the feature list.
- Update llms.txt to reflect the new version 1.6.0.
- Bump version in package.json to 1.6.0 and update devDependencies for Storybook.

* Address review feedback for test setup, test type coverage, and component state keys (#65)

* Initial plan

* Address review feedback for test typing and setup

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Finalize review feedback fixes

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Export component state key type

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Default component state key generic

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Tighten component/state update semantics and Storybook attribute sanitization (#66)

* Initial plan

* fix review follow-up for state updates and storybook sanitization

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix storybook attribute value scanning

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* fix storybook interpolation boundary parsing

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* docs align storybook attribute scan jsdoc

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Signed-off-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
JosunLP added a commit that referenced this pull request Mar 27, 2026
…nent state keys (#65)

* Initial plan

* Address review feedback for test typing and setup

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Finalize review feedback fixes

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Export component state key type

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Default component state key generic

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Changes to the build and meta files component Changes to the component module store Changes to the store module tests Chenges to the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants