Skip to content

chore(E2E): add toBeExpanded() aria-expanded matcher - #3437

Draft
Dave Shoup (shouples) wants to merge 2 commits into
mainfrom
djs/issue-2566-aria-expanded-matcher
Draft

chore(E2E): add toBeExpanded() aria-expanded matcher#3437
Dave Shoup (shouples) wants to merge 2 commits into
mainfrom
djs/issue-2566-aria-expanded-matcher

Conversation

@shouples

@shouples Dave Shoup (shouples) commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Across the E2E suite we repeatedly assert that a tree item or view is expanded by checking its aria-expanded attribute directly: await expect(locator).toHaveAttribute("aria-expanded", "true"). This PR adds a small Playwright custom matcher so that reads as await expect(locator).toBeExpanded() instead, and converts the 19 existing positive assertions to use it.

No functional or behavioral changes to any test. Full E2E pipeline passing.

Closes #2566

Optional: Any additional details or context that should be provided?

  • The matcher lives in tests/e2e/matchers.ts, registers on Playwright's shared expect via expect.extend, and is wired in through a side-effect import in tests/e2e/baseTest.ts (which every spec already imports), so it's available everywhere without per-file setup. It's typed via a global augmentation so .toBeExpanded() type-checks anywhere expect is imported, and it delegates to toHaveAttribute internally, so auto-waiting and .not.toBeExpanded() still work.
  • Two categories of aria-expanded usage were intentionally left as-is: the two not.toHaveAttribute("aria-expanded") checks (which assert the attribute is absent on a non-expandable leaf item, a stricter condition than "not expanded"), and the five getAttribute("aria-expanded") reads that feed an if to decide whether to click (control-flow, not assertions). A value-asserting matcher can't cover either without weakening or reshaping them.
  • The matcher's own logic (both toBeExpanded() and .not.toBeExpanded(), across expanded / collapsed / absent states) is covered by a focused functional test at src/webview/aria-expanded-matcher.spec.ts. The rollwright functional harness is the only non-Electron way to run real-DOM Playwright assertions here, so the matcher's edge cases run fast in npx gulp functional without needing Docker/sidecar. The 19 converted assertions additionally exercise the positive path in the E2E suite in CI.
  • Verified locally with npx gulp check (the type augmentation and all 19 converted call sites compile), npx gulp lint, prettier, and npx gulp functional -t "toBeExpanded" (3 passing).

Pull request checklist

Please check if your PR fulfills the following (if applicable):

Tests

  • Added new
  • Updated existing
  • Deleted existing

Release notes

  • Does anything in this PR need to be mentioned in the user-facing CHANGELOG?

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 21, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a typed Playwright toBeExpanded() matcher and replaces 19 direct aria-expanded="true" assertions across the E2E suite.

Changes:

  • Adds and registers the shared matcher.
  • Migrates positive expansion assertions.
  • Updates E2E documentation while preserving absence checks and control-flow reads.

Reviewed changes

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

Show a summary per file
File Changes Review note
tests/README.md Updates the E2E assertion example.
tests/e2e/utils/workspace.ts Migrates workspace expansion assertions.
tests/e2e/utils/connections.ts Migrates connection expansion assertions.
tests/e2e/specs/schemas.spec.ts Migrates schema setup assertions.
tests/e2e/specs/scaffold.spec.ts Migrates scaffolding assertions.
tests/e2e/specs/produceMessage.spec.ts Migrates topic setup assertions.
tests/e2e/specs/flinkStatement.spec.ts Migrates statement setup assertions.
tests/e2e/specs/flinkArtifact.spec.ts Migrates artifact setup assertions.
tests/e2e/specs/directConnectionLifecycle.spec.ts Migrates lifecycle assertions.
tests/e2e/objects/views/View.ts Migrates base view assertions.
tests/e2e/objects/views/TopicsView.ts Migrates topics view assertions.
tests/e2e/objects/views/SchemasView.ts Migrates schemas view assertions.
tests/e2e/objects/views/ResourcesView.ts Migrates resources assertions.
tests/e2e/objects/views/FlinkDatabaseView.ts Migrates database view assertions.
tests/e2e/matchers.ts Defines the matcher and global typings. Nit (3 votes): add focused assertions covering expanded and non-expanded locators for .not.toBeExpanded().
tests/e2e/baseTest.ts Registers the matcher and updates fixture assertions.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/e2e/matchers.ts
Covers both toBeExpanded() and .not.toBeExpanded() across expanded,
collapsed, and absent aria-expanded states via the rollwright harness,
exercising the negated branch that no converted call site hits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqube-confluent

Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

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.

E2E: Set up custom matcher for aria-expanded

2 participants