Skip to content

Commit 0c3dbd2

Browse files
committed
Wait for page cover shimmer to disappear in tests
1 parent e2f70c7 commit 0c3dbd2

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

packages/gitbook/e2e/internal.spec.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
headerLinks,
3434
runTestCases,
3535
waitForCookiesDialog,
36+
waitForCoverImages,
3637
waitForNotFound,
3738
} from './util';
3839

@@ -906,7 +907,10 @@ const testCases: TestsCase[] = [
906907
{
907908
name: 'With cover',
908909
url: 'page-options/page-with-cover',
909-
run: waitForCookiesDialog,
910+
run: async (page) => {
911+
await waitForCookiesDialog(page);
912+
await waitForCoverImages(page);
913+
},
910914
},
911915
{
912916
name: 'With cover for dark mode',
@@ -916,17 +920,26 @@ const testCases: TestsCase[] = [
916920
toggeable: false,
917921
},
918922
})}`,
919-
run: waitForCookiesDialog,
923+
run: async (page) => {
924+
await waitForCookiesDialog(page);
925+
await waitForCoverImages(page);
926+
},
920927
},
921928
{
922929
name: 'With hero cover',
923930
url: 'page-options/page-with-hero-cover',
924-
run: waitForCookiesDialog,
931+
run: async (page) => {
932+
await waitForCookiesDialog(page);
933+
await waitForCoverImages(page);
934+
},
925935
},
926936
{
927937
name: 'With cover and no TOC',
928938
url: 'page-options/page-with-cover-and-no-toc',
929-
run: waitForCookiesDialog,
939+
run: async (page) => {
940+
await waitForCookiesDialog(page);
941+
await waitForCoverImages(page);
942+
},
930943
screenshot: {
931944
waitForTOCScrolling: false,
932945
},

packages/gitbook/e2e/util.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ export async function waitForNotFound(_page: Page, response: Response | null) {
154154
expect(response?.status()).toBe(404);
155155
}
156156

157+
export async function waitForCoverImages(page: Page) {
158+
// Wait for cover images to exist (not the shimmer placeholder)
159+
await expect(page.locator('img[alt="Page cover"]').first()).toBeVisible({
160+
timeout: 10_000,
161+
});
162+
}
163+
157164
/**
158165
* Transform test cases into Playwright tests and run it.
159166
*/

0 commit comments

Comments
 (0)