Skip to content

fix: replace no-op assertions in Playwright E2E tests - #90

Merged
Senthil455 merged 1 commit into
mainfrom
fix/e2e-noop-assertions
Jun 17, 2026
Merged

fix: replace no-op assertions in Playwright E2E tests#90
Senthil455 merged 1 commit into
mainfrom
fix/e2e-noop-assertions

Conversation

@DivyashreeR008

Copy link
Copy Markdown
Collaborator

Three Playwright E2E tests had assertions that could never fail, giving false confidence in CI and letting regressions slip through undetected.

Changes

1. Course catalog count (lms-workflow.spec.ts)
Changed expect(count).toBeGreaterThanOrEqual(0) to expect(count).toBeGreaterThan(0). An empty page with zero course cards would have passed the old assertion. Now it correctly fails if no courses are rendered.

2. Enrollment test (lms-workflow.spec.ts)
Removed the if (await enrollButton.isVisible()) guard that let the test silently pass when the enroll button was missing. Replaced with �wait enrollButton.waitFor({ state: 'visible', timeout: 5000 }) so the test fails with a clear timeout if no enroll button exists on the page.

3. Compliance URL assertions (compliance.spec.ts)

  • Removed the if (isVisible()) guards from both compliance tests (same no-op pattern as the enrollment test).
  • Changed expect(page).toHaveURL(/.audit.|.compliance./i) to expect(page).toHaveURL(/.audit./i) -- the old pattern matched /dashboard/compliance before any click happened.
  • Changed expect(page).toHaveURL(/.policy.|.compliance./i) to expect(page).toHaveURL(/.policies.|.policy./i) -- same issue, removed the compliance fallback.

Fixes #52

The LMS and compliance E2E tests had multiple assertions that could
never fail, giving false confidence in the test suite. This commit
fixes all three issues:

1. Course count check: changed expect(count).toBeGreaterThanOrEqual(0)
   to expect(count).toBeGreaterThan(0). A count of zero means no
   courses loaded - the test should catch that.

2. Enrollment test: removed the if (isVisible()) guard. The test was
   silently passing when the enroll button was missing. Now uses
   waitFor({ state: 'visible' }) so the test fails with a clear
   timeout error if no enroll button exists.

3. Compliance URL assertions: removed the |.*compliance.* fallback
   from both URL regex patterns. The old patterns matched the starting
   URL /dashboard/compliance even when no navigation occurred. Now
   the audit test checks for /.*audit.*/i and the policies test
   checks for /.*policies.*|.*policy.*/i, which only match after
   a real navigation.

Fixes #52
@DivyashreeR008

Copy link
Copy Markdown
Collaborator Author

@Senthil455 Please review this fix for #52.

@DivyashreeR008

Copy link
Copy Markdown
Collaborator Author

Thanks for the thorough review, @Senthil455. Agreed on the timeout -- will bump to 10s if we see flakiness in CI, but 5s should be fine for now since the page and buttons are already loaded by the time those assertions run.

@Senthil455
Senthil455 merged commit 7b6102b into main Jun 17, 2026
7 of 19 checks passed

@Senthil455 Senthil455 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

gh: Not Found (HTTP 404)
{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"}

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.

HIGH: Playwright E2E tests have multiple no-op assertions that can never fail

2 participants