Skip to content

Commit 4a51bff

Browse files
fix(e2e): resolve flaky haiku display test by checking only last haiku
The Tool Based Generative UI haiku test was exhibiting flaky behavior where it would sometimes pass and sometimes fail with the same test conditions. The test was more reliable when run with --headed than when run headless, suggesting a timing-related issue. Root cause: The extractMainDisplayHaikuContent() method was concatenating ALL visible haiku lines from the main display, while the chat extraction only captured the most recent haiku. When multiple haikus were displayed simultaneously (due to rendering timing), this caused mismatches. Fix: Modified extractMainDisplayHaikuContent() to extract only the last 3 lines (the most recent haiku), matching the behavior of the chat extraction and eliminating timing-related flakiness. This affects all 10 platform integration tests that use ToolBaseGenUIPage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 660b564 commit 4a51bff

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

typescript-sdk/apps/dojo/e2e/featurePages/ToolBaseGenUIPage.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,23 @@ export class ToolBaseGenUIPage {
7373
}
7474

7575
async extractMainDisplayHaikuContent(page: Page): Promise<string> {
76+
// Wait for main haiku lines to be present
7677
const mainDisplayLines = page.locator('[data-testid="main-haiku-line"]');
7778
const mainCount = await mainDisplayLines.count();
79+
80+
if (mainCount === 0) {
81+
return '';
82+
}
83+
84+
// Take only the last 3 lines (most recent haiku)
85+
// Haikus are 3 lines, and they're appended in order
86+
const startIndex = Math.max(0, mainCount - 3);
7887
const lines: string[] = [];
7988

80-
if (mainCount > 0) {
81-
for (let i = 0; i < mainCount; i++) {
82-
const haikuLine = mainDisplayLines.nth(i);
83-
const japaneseText = await haikuLine.locator('p').first().innerText();
84-
lines.push(japaneseText);
85-
}
89+
for (let i = startIndex; i < mainCount; i++) {
90+
const haikuLine = mainDisplayLines.nth(i);
91+
const japaneseText = await haikuLine.locator('p').first().innerText();
92+
lines.push(japaneseText);
8693
}
8794

8895
const mainHaikuContent = lines.join('').replace(/\s/g, '');

0 commit comments

Comments
 (0)