Skip to content

Commit ac826f9

Browse files
Created HTML pub navigation tests
1 parent e253246 commit ac826f9

File tree

2 files changed

+110
-2
lines changed

2 files changed

+110
-2
lines changed

playwright/pageobjects/web-reader.page.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ class WebReaderPage {
9999
.locator('[data-page-number="2"]');
100100

101101
// footer
102-
this.previousPageButton = page.getByLabel('Previous Page');
103-
this.nextPageButton = page.getByLabel('Next Page');
102+
this.previousPageButton = page
103+
.getByRole('contentinfo')
104+
.getByRole('button', { name: 'Previous Page' });
105+
this.nextPageButton = page
106+
.getByRole('contentinfo')
107+
.getByRole('button', { name: 'Next Page' });
104108
}
105109

106110
// hopefully better handles slow load time (use load or networkidle)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { test, expect } from '@playwright/test';
2+
import { HtmlReaderPage } from '../pageobjects/web-reader.page.ts';
3+
4+
test.describe('Test navigation in HTML pub', () => {
5+
test('Displays reader navigation in HTML pub', async ({ page }) => {
6+
const htmlReaderPage = new HtmlReaderPage(page);
7+
await htmlReaderPage.loadPage('/html/moby-epub3');
8+
await expect(htmlReaderPage.backButton).toBeVisible();
9+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
10+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
11+
await expect(htmlReaderPage.tocButton).toBeVisible();
12+
await htmlReaderPage.tocButton.click();
13+
await expect(htmlReaderPage.firstChapter).toBeVisible();
14+
await expect(htmlReaderPage.lastChapter).toBeVisible();
15+
});
16+
17+
test('Click next/previous buttons on first page in paginated mode', async ({
18+
page,
19+
}) => {
20+
const htmlReaderPage = new HtmlReaderPage(page);
21+
await page.goto('/html/moby-epub3');
22+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
23+
await expect(htmlReaderPage.nextPageButton).toBeEnabled();
24+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
25+
await expect(htmlReaderPage.previousPageButton).toBeDisabled();
26+
await htmlReaderPage.nextPageButton.click();
27+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
28+
await expect(htmlReaderPage.nextPageButton).toBeEnabled();
29+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
30+
await expect(htmlReaderPage.previousPageButton).toBeEnabled();
31+
await htmlReaderPage.previousPageButton.click();
32+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
33+
await expect(htmlReaderPage.nextPageButton).toBeEnabled();
34+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
35+
await expect(htmlReaderPage.previousPageButton).toBeDisabled();
36+
});
37+
38+
test('Click next/previous buttons on first page in scrolling mode', async ({
39+
page,
40+
}) => {
41+
const htmlReaderPage = new HtmlReaderPage(page);
42+
await page.goto('/html/moby-epub3');
43+
await htmlReaderPage.settingsButton.click();
44+
await htmlReaderPage.scrollingStyle.click();
45+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
46+
await expect(htmlReaderPage.nextPageButton).toBeEnabled();
47+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
48+
await expect(htmlReaderPage.previousPageButton).toBeDisabled();
49+
await htmlReaderPage.nextPageButton.click();
50+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
51+
await expect(htmlReaderPage.nextPageButton).toBeEnabled();
52+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
53+
await expect(htmlReaderPage.previousPageButton).toBeEnabled();
54+
await htmlReaderPage.previousPageButton.click();
55+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
56+
await expect(htmlReaderPage.nextPageButton).toBeEnabled();
57+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
58+
await expect(htmlReaderPage.previousPageButton).toBeDisabled();
59+
});
60+
61+
test('Click next/previous buttons on last page in paginated mode', async ({
62+
page,
63+
}) => {
64+
const htmlReaderPage = new HtmlReaderPage(page);
65+
await page.goto('/html/moby-epub3');
66+
await expect(htmlReaderPage.tocButton).toBeVisible();
67+
await htmlReaderPage.tocButton.click();
68+
await htmlReaderPage.lastChapter.click();
69+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
70+
await expect(htmlReaderPage.previousPageButton).toBeEnabled();
71+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
72+
await expect(htmlReaderPage.nextPageButton).toBeDisabled();
73+
await htmlReaderPage.previousPageButton.click();
74+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
75+
await expect(htmlReaderPage.previousPageButton).toBeEnabled();
76+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
77+
await expect(htmlReaderPage.nextPageButton).toBeEnabled();
78+
await htmlReaderPage.nextPageButton.click();
79+
await expect(htmlReaderPage.previousPageButton).toBeVisible();
80+
await expect(htmlReaderPage.previousPageButton).toBeEnabled();
81+
await expect(htmlReaderPage.nextPageButton).toBeVisible();
82+
await expect(htmlReaderPage.nextPageButton).toBeDisabled();
83+
});
84+
});
85+
86+
// move scrolling here?
87+
// scroll to the bottom of the page in scrolling mode
88+
// scroll to the top of the page in scrolling mode
89+
90+
// change viewport
91+
// scroll to the bottom of the page, but if the screen is resized to be smaller, vertical scroll bar should re-appear to allow user to scroll down
92+
// small screen viewport 300x300 should disable next and previous buttons?
93+
94+
// click internal link in paginated mode
95+
// click internal link in scrolling mode
96+
// click external link
97+
98+
// remember last location when exit and reenter
99+
// remember last location when visit another remembering pub and return
100+
// do not remember last location in /html/moby-epub3-no-local-storage
101+
102+
// navigate in full screen
103+
104+
// missing TOC in /html/test/missing-toc

0 commit comments

Comments
 (0)