Skip to content

Wait for a toast to disappear before comparing snapshots in taking-exam#1662

Open
Redande wants to merge 8 commits intomasterfrom
fix-taking-exam-spec
Open

Wait for a toast to disappear before comparing snapshots in taking-exam#1662
Redande wants to merge 8 commits intomasterfrom
fix-taking-exam-spec

Conversation

@Redande
Copy link
Contributor

@Redande Redande commented Feb 25, 2026

Summary by CodeRabbit

  • Tests
    • Improved test reliability and stability across exam, grading, feedback, popover, and chapter-lock scenarios.
    • Wrapped critical exam actions with a success-notification guard to reduce timing flakiness and removed fragile immediate text assertions.
    • Added automatic clearing of notifications for screenshot comparisons.
    • Added explicit waits and refreshed element references for popovers and exercise interactions.
    • Replaced fragile click patterns with more robust locator-driven interactions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 071df23 and 8f04ef0.

⛔ Files ignored due to path filters (3)
  • system-tests/src/__screenshots__/exams/taking-exam.spec.ts/exam-started-mobile-tall.png is excluded by !**/*.png
  • system-tests/src/__screenshots__/manage-course-structure.spec.ts/manage-course-structure-middle-of-the-page-desktop-regular.png is excluded by !**/*.png
  • system-tests/src/__screenshots__/manage-course-structure.spec.ts/manage-course-structure-middle-of-the-page-mobile-tall.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • system-tests/src/tests/chatbot-conversation.spec.ts
  • system-tests/src/tests/exams/grade-exams-manually.spec.ts
  • system-tests/src/tests/feedback/feedback.spec.ts
  • system-tests/src/tests/lock-chapter.spec.ts

📝 Walkthrough

Walkthrough

Introduces explicit synchronization and stability waits in system tests: wraps several action sequences with waitForSuccessNotification, re-queries and waits for popover content, switches to Locator-based interactions, and ensures iframe/button existence before interacting.

Changes

Cohort / File(s) Summary
Exam tests (notification sync)
system-tests/src/tests/exams/taking-exam.spec.ts, system-tests/src/tests/exams/grade-exams-manually.spec.ts
Import and use waitForSuccessNotification to wrap user actions (start/end exam + confirm-dialog), remove immediate text assertion in favor of notification-driven flow, and add clearNotifications: true to screenshot assertions.
Chatbot popover stability
system-tests/src/tests/chatbot-conversation.spec.ts
Re-query citation popover element after reopening, add explicit wait for visibility/stability on the fresh locator, remove earlier stability check on the initial reference.
Feedback interaction robustness
system-tests/src/tests/feedback/feedback.spec.ts
Replace direct page.click("text=So big") with a Locator: scroll into view and perform a triple-click via the locator to preserve clickCount semantics.
Iframe/locator ordering
system-tests/src/tests/lock-chapter.spec.ts
Move creation of exercise iframe locator earlier and wait for the "Correct answer" button to exist before interacting; remove duplicate locator declaration.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • nygrenh

Poem

🐇 I waited patient, paws akimbo bright,
A little toast appeared, a soft-lit light.
I hopped, I clicked, then paused for cheer,
The tests marched on — carrots all near. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title focuses on waiting for a toast in taking-exam, but the PR also modifies four other test files (chatbot-conversation, grade-exams-manually, feedback, lock-chapter) with similar patterns, making the title incomplete. Consider revising the title to reflect the broader scope, such as 'Add notification/success guards and element stability improvements to multiple system tests' or split into smaller focused PRs.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-taking-exam-spec

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the test label Feb 25, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@system-tests/src/tests/exams/taking-exam.spec.ts`:
- Around line 29-32: The current wait on
page.getByTestId("toast-notification").waitFor(...).catch(() => {}) swallows
failures and hides flakiness; replace this with the project's success-toast sync
pattern by calling the shared helper waitForSuccessNotification (or, if
unavailable, remove the .catch so the wait can fail) after the start-exam
mutation. Locate the usage of page.getByTestId("toast-notification")/waitFor in
taking-exam.spec.ts and swap it for waitForSuccessNotification(...) or let the
wait throw so the test fails when the toast does not appear.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d09d72b and 0a75cd3.

📒 Files selected for processing (1)
  • system-tests/src/tests/exams/taking-exam.spec.ts

@coderabbitai coderabbitai bot removed the test label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant