Repository navigation
fix (ci/tests): Stabilize cross-page slide comparison - #25052
gustavotrott merged 2 commits into
Conversation
Strip per-user auth query params from slide HTML and poll the user page until it matches the moderator side, fixing flaky uploads in CI.
WalkthroughThis PR refactors presentation test utilities by introducing a shared Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
bigbluebutton-tests/playwright/presentation/util.ts (2)
30-40: 💤 Low valueConsider checking for null/undefined moderator slide
The function captures the moderator slide HTML once at line 38, then polls the user page until it matches. While
getSlideOuterHtmlwaits for the element,document.querySelector(...).outerHTMLcould theoretically returnundefinedif a race condition occurs between the wait and the evaluate.🛡️ Optional: Add assertion that moderator slide HTML was captured
export async function expectSlidesEqualBetweenPages( modPage: Page, userPage: Page, description: string, timeout = ELEMENT_WAIT_LONGER_TIME, ) { const modSlide = await getSlideOuterHtml(modPage); + if (!modSlide) { + throw new Error('Failed to capture moderator slide HTML'); + } await expect.poll(() => getSlideOuterHtml(userPage), { message: description, timeout }).toBe(modSlide); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bigbluebutton-tests/playwright/presentation/util.ts` around lines 30 - 40, The code captures the moderator slide HTML into modSlide in expectSlidesEqualBetweenPages but doesn't guard against it being null/undefined; after calling getSlideOuterHtml(modPage) add an explicit check/assert that modSlide is defined (e.g., throw or use expect(modSlide).toBeDefined()/toBeTruthy()) before starting the poll so the test fails fast with a clear message if the moderator slide wasn't captured; reference the function expectSlidesEqualBetweenPages, the variable modSlide, and the helper getSlideOuterHtml when making this change.
130-148: ⚡ Quick winClarify the retry logic for upload done icon check
The current try/catch pattern duplicates the
uploadDoneIconcheck: it appears both inside the try block (line 138-141) and in the catch block (line 143-147). This provides retry behavior if processing completes too quickly to observe or if the firstuploadDoneIconcheck times out, but the duplication obscures the intent.♻️ Clearer alternative: separate concerns and avoid duplication
try { await testPage.hasNElements( e.processingPresentationItem, fileNames.length, 'should display the presentation status info element with converting label after confirmation to upload the new file', ); - + } catch { + // Processing may complete too quickly to observe; this is acceptable + } + // Always verify upload completion + await testPage.hasNElements( + e.uploadDoneIcon, + fileNames.length, + 'should display the upload done icon after all presentations are successfully uploaded', + ); + // Fallback retry if upload still in progress + try { await testPage.hasNElements( e.uploadDoneIcon, fileNames.length, 'should display the upload done icon after all presentations are successfully uploaded', ); } catch { - await testPage.hasNElements( - e.uploadDoneIcon, - fileNames.length, - 'should display the upload done icon after all presentations are successfully uploaded', - ); + // Final attempt with implicit timeout from hasNElements }Or more simply:
try { await testPage.hasNElements( e.processingPresentationItem, fileNames.length, 'should display the presentation status info element with converting label after confirmation to upload the new file', ); - - await testPage.hasNElements( - e.uploadDoneIcon, - fileNames.length, - 'should display the upload done icon after all presentations are successfully uploaded', - ); } catch { - await testPage.hasNElements( - e.uploadDoneIcon, - fileNames.length, - 'should display the upload done icon after all presentations are successfully uploaded', - ); + // Processing completed too quickly; this is acceptable in CI } + await testPage.hasNElements( + e.uploadDoneIcon, + fileNames.length, + 'should display the upload done icon after all presentations are successfully uploaded', + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bigbluebutton-tests/playwright/presentation/util.ts` around lines 130 - 148, The duplicated upload-done check should be clarified: remove the second (duplicate) call inside the try/catch and either (a) call testPage.hasNElements(e.uploadDoneIcon, fileNames.length, ...) once after awaiting the processing check (so the flow is: await hasNElements(e.processingPresentationItem...) then await hasNElements(e.uploadDoneIcon...)), or (b) replace the try/catch duplication with a small retry wrapper around testPage.hasNElements for e.uploadDoneIcon (e.g. a loop with short delays that retries until success or timeout) so the retry intent is explicit; update references to testPage.hasNElements, e.processingPresentationItem and e.uploadDoneIcon accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@bigbluebutton-tests/playwright/presentation/util.ts`:
- Around line 30-40: The code captures the moderator slide HTML into modSlide in
expectSlidesEqualBetweenPages but doesn't guard against it being null/undefined;
after calling getSlideOuterHtml(modPage) add an explicit check/assert that
modSlide is defined (e.g., throw or use
expect(modSlide).toBeDefined()/toBeTruthy()) before starting the poll so the
test fails fast with a clear message if the moderator slide wasn't captured;
reference the function expectSlidesEqualBetweenPages, the variable modSlide, and
the helper getSlideOuterHtml when making this change.
- Around line 130-148: The duplicated upload-done check should be clarified:
remove the second (duplicate) call inside the try/catch and either (a) call
testPage.hasNElements(e.uploadDoneIcon, fileNames.length, ...) once after
awaiting the processing check (so the flow is: await
hasNElements(e.processingPresentationItem...) then await
hasNElements(e.uploadDoneIcon...)), or (b) replace the try/catch duplication
with a small retry wrapper around testPage.hasNElements for e.uploadDoneIcon
(e.g. a loop with short delays that retries until success or timeout) so the
retry intent is explicit; update references to testPage.hasNElements,
e.processingPresentationItem and e.uploadDoneIcon accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4e259285-73ec-4e20-9c4e-c0521994268d
📒 Files selected for processing (2)
bigbluebutton-tests/playwright/presentation/presentation.tsbigbluebutton-tests/playwright/presentation/util.ts
✅ Automated tests have passed! |



Poll the user page until it matches the moderator side, fixing flaky uploads in CI.
Attempt to avoid this error that occurs often: