Skip to content

Commit 66ff7ea

Browse files
committed
fix: fix E2E timeout
1 parent 28f7fba commit 66ff7ea

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

packages/gitbook/e2e/internal.spec.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
CustomizationSidebarListStyle,
1010
CustomizationThemeMode,
1111
} from '@gitbook/api';
12-
import { expect } from '@playwright/test';
12+
import { type Page, expect } from '@playwright/test';
1313
import jwt from 'jsonwebtoken';
1414

1515
import {
@@ -36,6 +36,10 @@ import {
3636
waitForNotFound,
3737
} from './util';
3838

39+
async function expectResultsToBeVisible(page: Page) {
40+
await expect(page.getByTestId('search-results')).toBeVisible({ timeout: 15_000 });
41+
}
42+
3943
const searchTestCases: Test[] = [
4044
{
4145
name: 'Search - AI Mode: None - Complete flow',
@@ -48,11 +52,12 @@ const searchTestCases: Test[] = [
4852
run: async (page) => {
4953
const searchInput = page.getByTestId('search-input');
5054
await searchInput.focus();
55+
await expectResultsToBeVisible(page);
5156
await expect(page.getByTestId('search-results')).toHaveCount(0); // No pop-up yet because there's no recommended questions.
5257

5358
// Fill search input, expecting search results
5459
await searchInput.fill('gitbook');
55-
await expect(page.getByTestId('search-results')).toBeVisible();
60+
await expectResultsToBeVisible(page);
5661
const pageResults = await page.getByTestId('search-page-result').all();
5762
await expect(pageResults.length).toBeGreaterThan(2);
5863
const pageSectionResults = await page.getByTestId('search-page-section-result').all();
@@ -81,6 +86,7 @@ const searchTestCases: Test[] = [
8186
},
8287
})}&q=`,
8388
run: async (page) => {
89+
await expectResultsToBeVisible(page);
8490
await expect(page.getByTestId('search-results')).toHaveCount(0); // No pop-up yet because there's no recommended questions.
8591
},
8692
},
@@ -94,7 +100,7 @@ const searchTestCases: Test[] = [
94100
run: async (page) => {
95101
await expect(page.getByTestId('search-input')).toBeFocused();
96102
await expect(page.getByTestId('search-input')).toHaveValue('gitbook');
97-
await expect(page.getByTestId('search-results')).toBeVisible();
103+
await expectResultsToBeVisible(page);
98104
},
99105
},
100106
{
@@ -110,15 +116,15 @@ const searchTestCases: Test[] = [
110116

111117
// Focus search input, expecting recommended questions
112118
await searchInput.focus();
113-
await expect(page.getByTestId('search-results')).toBeVisible();
119+
await expectResultsToBeVisible(page);
114120
const recommendedQuestions = await page
115121
.getByTestId('search-recommended-question')
116122
.all();
117123
await expect(recommendedQuestions.length).toBeGreaterThan(2); // Expect at least 3 questions
118124

119125
// Fill search input, expecting AI search option
120126
await searchInput.fill('What is gitbook?');
121-
await expect(page.getByTestId('search-results')).toBeVisible();
127+
await expectResultsToBeVisible(page);
122128
const aiSearchResult = page.getByTestId('search-ask-question');
123129
await expect(aiSearchResult).toBeVisible();
124130
await aiSearchResult.click();
@@ -137,7 +143,7 @@ const searchTestCases: Test[] = [
137143
screenshot: false,
138144
run: async (page) => {
139145
await expect(page.getByTestId('search-input')).toBeFocused();
140-
await expect(page.getByTestId('search-results')).toBeVisible();
146+
await expectResultsToBeVisible(page);
141147
const recommendedQuestions = await page
142148
.getByTestId('search-recommended-question')
143149
.all();
@@ -155,7 +161,7 @@ const searchTestCases: Test[] = [
155161
run: async (page) => {
156162
await expect(page.getByTestId('search-input')).toBeFocused();
157163
await expect(page.getByTestId('search-input')).toHaveValue('gitbook');
158-
await expect(page.getByTestId('search-results')).toBeVisible();
164+
await expectResultsToBeVisible(page);
159165
},
160166
},
161167
{
@@ -168,7 +174,7 @@ const searchTestCases: Test[] = [
168174
screenshot: false,
169175
run: async (page) => {
170176
await expect(page.getByTestId('search-input')).toBeFocused();
171-
await expect(page.getByTestId('search-results')).toBeVisible();
177+
await expectResultsToBeVisible(page);
172178
const recommendedQuestions = await page
173179
.getByTestId('search-recommended-question')
174180
.all();
@@ -204,7 +210,7 @@ const searchTestCases: Test[] = [
204210

205211
// Focus search input, expecting recommended questions
206212
await searchInput.focus();
207-
await expect(page.getByTestId('search-results')).toBeVisible();
213+
await expectResultsToBeVisible(page);
208214
const recommendedQuestions = await page
209215
.getByTestId('search-recommended-question')
210216
.all();

0 commit comments

Comments
 (0)