Skip to content

Commit 14490ed

Browse files
Add logic to wait for main content to be edited
Signed-off-by: Luis Valdes <[email protected]>
1 parent cd8eb55 commit 14490ed

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,13 @@ export class ToolBaseGenUIPage {
112112
}
113113

114114
async checkHaikuDisplay(page: Page): Promise<void> {
115+
// Wait for both chat and main display to be fully loaded
116+
await page.waitForTimeout(3000);
117+
115118
const chatHaikuContent = await this.extractChatHaikuContent(page);
116119

117-
await page.waitForTimeout(5000);
120+
// Wait a bit more for main display to sync
121+
await page.waitForTimeout(2000);
118122

119123
const mainHaikuContent = await this.extractMainDisplayHaikuContent(page);
120124

@@ -123,14 +127,43 @@ export class ToolBaseGenUIPage {
123127
return;
124128
}
125129

130+
// Check if contents match exactly
126131
if (chatHaikuContent === mainHaikuContent) {
127132
expect(mainHaikuContent).toBe(chatHaikuContent);
133+
return;
134+
}
135+
136+
// If they don't match, check if one is a substring of the other (partial loading)
137+
if (mainHaikuContent.includes(chatHaikuContent) || chatHaikuContent.includes(mainHaikuContent)) {
138+
console.log(`Content partially matches - Chat: "${chatHaikuContent}", Main: "${mainHaikuContent}"`);
139+
140+
// Wait for content to stabilize and try again
141+
await page.waitForTimeout(5000);
142+
143+
const finalChatContent = await this.extractChatHaikuContent(page);
144+
const finalMainContent = await this.extractMainDisplayHaikuContent(page);
145+
146+
// Use the longer content as the expected result (more complete)
147+
const expectedContent = finalChatContent.length >= finalMainContent.length ? finalChatContent : finalMainContent;
148+
149+
expect(finalMainContent).toBe(expectedContent);
150+
expect(finalChatContent).toBe(expectedContent);
128151
} else {
129-
await page.waitForTimeout(3000);
152+
// Contents are completely different - this might indicate an error
153+
console.log(`Content mismatch - Chat: "${chatHaikuContent}", Main: "${mainHaikuContent}"`);
154+
155+
// Wait longer and try one more time
156+
await page.waitForTimeout(5000);
157+
158+
const retryMainContent = await this.extractMainDisplayHaikuContent(page);
159+
const retryChatContent = await this.extractChatHaikuContent(page);
130160

131-
const updatedMainContent = await this.extractMainDisplayHaikuContent(page);
161+
// At least verify both have content
162+
expect(retryChatContent.length).toBeGreaterThan(0);
163+
expect(retryMainContent.length).toBeGreaterThan(0);
132164

133-
expect(updatedMainContent).toBe(chatHaikuContent);
165+
// Try to match again
166+
expect(retryMainContent).toBe(retryChatContent);
134167
}
135168
}
136169
}

0 commit comments

Comments
 (0)