Skip to content

Fix E2E timeout #3558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions packages/gitbook/e2e/internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
CustomizationSidebarListStyle,
CustomizationThemeMode,
} from '@gitbook/api';
import { expect } from '@playwright/test';
import { type Page, expect } from '@playwright/test';
import jwt from 'jsonwebtoken';

import {
Expand All @@ -36,6 +36,10 @@ import {
waitForNotFound,
} from './util';

async function expectResultsToBeVisible(page: Page) {
await expect(page.getByTestId('search-results')).toBeVisible({ timeout: 15_000 });
}

const searchTestCases: Test[] = [
{
name: 'Search - AI Mode: None - Complete flow',
Expand All @@ -48,11 +52,12 @@ const searchTestCases: Test[] = [
run: async (page) => {
const searchInput = page.getByTestId('search-input');
await searchInput.focus();
await expectResultsToBeVisible(page);
await expect(page.getByTestId('search-results')).toHaveCount(0); // No pop-up yet because there's no recommended questions.

// Fill search input, expecting search results
await searchInput.fill('gitbook');
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
const pageResults = await page.getByTestId('search-page-result').all();
await expect(pageResults.length).toBeGreaterThan(2);
const pageSectionResults = await page.getByTestId('search-page-section-result').all();
Expand Down Expand Up @@ -81,6 +86,7 @@ const searchTestCases: Test[] = [
},
})}&q=`,
run: async (page) => {
await expectResultsToBeVisible(page);
await expect(page.getByTestId('search-results')).toHaveCount(0); // No pop-up yet because there's no recommended questions.
},
},
Expand All @@ -94,7 +100,7 @@ const searchTestCases: Test[] = [
run: async (page) => {
await expect(page.getByTestId('search-input')).toBeFocused();
await expect(page.getByTestId('search-input')).toHaveValue('gitbook');
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
},
},
{
Expand All @@ -110,15 +116,15 @@ const searchTestCases: Test[] = [

// Focus search input, expecting recommended questions
await searchInput.focus();
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
const recommendedQuestions = await page
.getByTestId('search-recommended-question')
.all();
await expect(recommendedQuestions.length).toBeGreaterThan(2); // Expect at least 3 questions

// Fill search input, expecting AI search option
await searchInput.fill('What is gitbook?');
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
const aiSearchResult = page.getByTestId('search-ask-question');
await expect(aiSearchResult).toBeVisible();
await aiSearchResult.click();
Expand All @@ -137,7 +143,7 @@ const searchTestCases: Test[] = [
screenshot: false,
run: async (page) => {
await expect(page.getByTestId('search-input')).toBeFocused();
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
const recommendedQuestions = await page
.getByTestId('search-recommended-question')
.all();
Expand All @@ -155,7 +161,7 @@ const searchTestCases: Test[] = [
run: async (page) => {
await expect(page.getByTestId('search-input')).toBeFocused();
await expect(page.getByTestId('search-input')).toHaveValue('gitbook');
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
},
},
{
Expand All @@ -168,7 +174,7 @@ const searchTestCases: Test[] = [
screenshot: false,
run: async (page) => {
await expect(page.getByTestId('search-input')).toBeFocused();
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
const recommendedQuestions = await page
.getByTestId('search-recommended-question')
.all();
Expand Down Expand Up @@ -204,7 +210,7 @@ const searchTestCases: Test[] = [

// Focus search input, expecting recommended questions
await searchInput.focus();
await expect(page.getByTestId('search-results')).toBeVisible();
await expectResultsToBeVisible(page);
const recommendedQuestions = await page
.getByTestId('search-recommended-question')
.all();
Expand Down
Loading