Skip to content

Commit d7b41a7

Browse files
committed
Update internal.spec.ts
1 parent b7bc5ba commit d7b41a7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/gitbook/e2e/internal.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
const AI_PROMPT = `You're being invoked by the GitBook CI/CD pipeline. To make screenshot testing of the GitBook Assistant visually consistent, look up the title of the first page you find and respond with only EXACTLY its title. To find the page title, invoke the search tool with the query "GitBook". Before invoking the search tool, respond with the exact text: "I'm going to look up 'GitBook' and then respond with only the page title.". Do not execute any other tools or output any other text.`;
4242

4343
const overrideAIInitialState = () => {
44-
const greeting = document.querySelector('[data-testid="ai-chat-time-greeting"]');
44+
const greeting = document.querySelector('[data-testid="ai-chat-greeting-title"]');
4545
if (greeting) {
4646
greeting.textContent = 'Good morning';
4747
}
@@ -1972,6 +1972,8 @@ const testCases: TestsCase[] = [
19721972
await expect(page.locator('#gitbook-widget-window')).not.toBeVisible();
19731973
await button.click(); // Toggle the window on
19741974
await expect(page.locator('#gitbook-widget-window')).toBeVisible();
1975+
1976+
await page.evaluate(overrideAIInitialState);
19751977
},
19761978
},
19771979
{
@@ -1985,6 +1987,8 @@ const testCases: TestsCase[] = [
19851987

19861988
await iframe.getByTestId('embed-tab-assistant').click(); // Switch to assistant tab
19871989
await expect(iframe.getByTestId('ai-chat')).toBeVisible();
1990+
1991+
await page.evaluate(overrideAIInitialState);
19881992
},
19891993
},
19901994
{
@@ -2017,6 +2021,7 @@ const testCases: TestsCase[] = [
20172021
await expect(iframe.getByTestId('ai-chat-message-user').first()).toHaveText(
20182022
AI_PROMPT
20192023
);
2024+
await page.evaluate(overrideAIResponse);
20202025
},
20212026
},
20222027
{
@@ -2037,6 +2042,7 @@ const testCases: TestsCase[] = [
20372042
'data-icon',
20382043
'book'
20392044
);
2045+
await page.evaluate(overrideAIInitialState);
20402046
},
20412047
},
20422048
{
@@ -2063,6 +2069,7 @@ const testCases: TestsCase[] = [
20632069
await expect(
20642070
iframe.getByTestId('ai-chat-suggested-question').nth(2)
20652071
).toHaveText('What can you do?');
2072+
await page.evaluate(overrideAIInitialState);
20662073
},
20672074
},
20682075
{
@@ -2145,6 +2152,7 @@ const testCases: TestsCase[] = [
21452152
await actions.nth(3).click();
21462153
await expect(page.locator('#gitbook-widget-window')).not.toBeVisible();
21472154
await page.locator('#gitbook-widget-button').click();
2155+
await page.evaluate(overrideAIResponse);
21482156
},
21492157
},
21502158
{
@@ -2190,6 +2198,7 @@ const testCases: TestsCase[] = [
21902198
timeout: 30000,
21912199
});
21922200
await page.waitForTimeout(10000);
2201+
await page.evaluate(overrideAIResponse);
21932202
},
21942203
},
21952204
],

0 commit comments

Comments
 (0)