Skip to content

Commit e0ace99

Browse files
authored
Fix flaky tests in AI Chat greeting (#3828)
1 parent 3553db0 commit e0ace99

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/gitbook/e2e/internal.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ const searchTestCases: Test[] = [
168168
await page.keyboard.press('ControlOrMeta+I');
169169
await expect(page.getByTestId('ai-chat')).toBeVisible();
170170
await expect(page.getByTestId('ai-chat-input')).toBeFocused();
171+
// Override text content for visual consistency in screenshots
172+
await page.evaluate(() => {
173+
const greeting = document.querySelector('[data-testid="ai-chat-time-greeting"]');
174+
if (greeting) {
175+
greeting.textContent = 'Good morning';
176+
}
177+
});
171178
},
172179
},
173180
{
@@ -182,6 +189,13 @@ const searchTestCases: Test[] = [
182189
await page.getByTestId('ai-chat-button').click();
183190
await expect(page.getByTestId('ai-chat')).toBeVisible();
184191
await expect(page.getByTestId('ai-chat-input')).toBeFocused();
192+
// Override text content for visual consistency in screenshots
193+
await page.evaluate(() => {
194+
const greeting = document.querySelector('[data-testid="ai-chat-time-greeting"]');
195+
if (greeting) {
196+
greeting.textContent = 'Good morning';
197+
}
198+
});
185199
},
186200
},
187201
{
@@ -196,6 +210,13 @@ const searchTestCases: Test[] = [
196210
await expect(page.getByTestId('search-input')).toBeEmpty();
197211
await expect(page.getByTestId('ai-chat')).toBeVisible();
198212
await expect(page.getByTestId('ai-chat-input')).toBeFocused();
213+
// Override text content for visual consistency in screenshots
214+
await page.evaluate(() => {
215+
const greeting = document.querySelector('[data-testid="ai-chat-time-greeting"]');
216+
if (greeting) {
217+
greeting.textContent = 'Good morning';
218+
}
219+
});
199220
},
200221
},
201222
{

packages/gitbook/src/components/AIChat/AIChat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export function AIChatBody(props: {
229229
<h5
230230
className="animate-blur-in-slow font-bold text-lg text-tint-strong [@container(min-height:400px)]:text-center"
231231
style={{ animationDelay: '.5s' }}
232+
data-testid="ai-chat-time-greeting"
232233
>
233234
{timeGreeting}
234235
</h5>

0 commit comments

Comments
 (0)