Skip to content

test: cover gridConnector logic with WTR unit tests#9505

Open
tomivirkki wants to merge 1 commit into
mainfrom
test/grid-connector-wtr-coverage
Open

test: cover gridConnector logic with WTR unit tests#9505
tomivirkki wants to merge 1 commit into
mainfrom
test/grid-connector-wtr-coverage

Conversation

@tomivirkki

Copy link
Copy Markdown
Member

Summary

  • Much of the gridConnector logic had no direct test coverage: a line could be removed without any unit test failing, and while integration tests likely cover some of the behavior, it is hard to tell which test covers which line. This adds fast WTR unit tests that target each behavior directly. Each new test was verified to fail when the line it covers is removed.
  • Writing the tests revealed one cleanup, included here: the header/footer renderers cleared root.innerHTML even though the grid already clears cell content whenever the renderer changes, so the lines were removed as redundant.

🤖 Generated with Claude Code

@tomivirkki tomivirkki marked this pull request as draft June 12, 2026 09:55
@tomivirkki tomivirkki force-pushed the test/grid-connector-wtr-coverage branch 2 times, most recently from 7c39ec9 to d309fa8 Compare June 12, 2026 12:07
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tomivirkki tomivirkki force-pushed the test/grid-connector-wtr-coverage branch from d309fa8 to 458a2b8 Compare June 12, 2026 12:58
@tomivirkki tomivirkki marked this pull request as ready for review June 12, 2026 12:59
@sonarqubecloud

Copy link
Copy Markdown

describe('aria-selected', () => {
it('should remove aria-selected from rows and cells in none selection mode', async () => {
grid.$connector.setSelectionMode('NONE');
grid.requestContentUpdate();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This shouldn't be needed, since grid.selectedItems = [] should already update the rows and cells.

Suggested change
grid.requestContentUpdate();


it('should keep aria-selected on rows and cells in single selection mode', async () => {
grid.$connector.setSelectionMode('SINGLE');
grid.requestContentUpdate();

@vursen vursen Jun 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here:

Suggested change
grid.requestContentUpdate();


it('should prevent context menu on selection column left click', () => {
let prevented: boolean;
grid.addEventListener('click', (e) => (prevented = grid.preventContextMenu(e)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
grid.addEventListener('click', (e) => (prevented = grid.preventContextMenu(e)));
grid.addEventListener('click', (e) => {
prevented = grid.preventContextMenu(e);
});


it('should not prevent context menu on regular column left click', () => {
let prevented: boolean;
grid.addEventListener('click', (e) => (prevented = grid.preventContextMenu(e)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
grid.addEventListener('click', (e) => (prevented = grid.preventContextMenu(e)));
grid.addEventListener('click', (e) => {
prevented = grid.preventContextMenu(e);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants