-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,59 @@ | ||
import { test, expect } from "@playwright/test" | ||
import { waitForSpineItemReady } from "../utils" | ||
|
||
test.describe("Given a prepaginated book with first page on spread right", () => { | ||
test("should render first document on right page", async ({ page }) => { | ||
await page.setViewportSize({ | ||
width: 400, | ||
height: 300, | ||
test.describe("and numberOfAdjacentSpineItemToPreLoad as 0", () => { | ||
test("should render first document on right page", async ({ page }) => { | ||
await page.setViewportSize({ | ||
width: 400, | ||
height: 300, | ||
}) | ||
|
||
await page.goto("http://localhost:3333/tests/prepaginated/index.html") | ||
|
||
await page.waitForSelector(".prose-spineItem-ready") | ||
|
||
expect(await page.screenshot()).toMatchSnapshot(`page-spread-right.png`) | ||
}) | ||
|
||
await page.goto("http://localhost:3333/tests/prepaginated/index.html") | ||
/** | ||
* - Make sure layout is correct | ||
* - Make sure layout are not infinite and looping. | ||
*/ | ||
test("should have a stable layout after navigating right", async ({ page }) => { | ||
await page.setViewportSize({ | ||
width: 400, | ||
height: 300, | ||
}) | ||
|
||
await page.goto("http://localhost:3333/tests/prepaginated/index.html") | ||
|
||
await page.waitForSelector(".prose-spineItem-ready") | ||
|
||
await page.keyboard.press("ArrowRight") | ||
|
||
await page.waitForSelector(".prose-spineItem-ready") | ||
await waitForSpineItemReady(page, [1, 2]) | ||
|
||
expect(await page.screenshot()).toMatchSnapshot(`page-spread-right.png`) | ||
expect(await page.screenshot()).toMatchSnapshot(`right-navigation-layout.png`) | ||
|
||
const numberOfLayout = await page.evaluate(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (window as any).layoutNumber as number | ||
}) | ||
|
||
// that's a long timeout but layout are being debounced a bit. | ||
await page.waitForTimeout(1000) | ||
|
||
const numberOfLayoutAfterAWhile = await page.evaluate(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (window as any).layoutNumber as number | ||
}) | ||
|
||
// make sure the value is correctly set on app side | ||
expect(numberOfLayout).toBeGreaterThan(1) | ||
|
||
// we make sure we don't have yolo renders | ||
expect(numberOfLayoutAfterAWhile).toBe(numberOfLayout) | ||
}) | ||
}) | ||
}) |
Binary file added
BIN
+24.7 KB
...ted/layout-spread.spec.ts-snapshots/right-navigation-layout-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.2 KB
...ated/layout-spread.spec.ts-snapshots/right-navigation-layout-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+83.7 KB
...nated/layout-spread.spec.ts-snapshots/right-navigation-layout-webkit-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.