test: Navigate to page 2

This commit is contained in:
Leni Aniva 2024-10-18 11:16:44 -07:00
parent 2471a5beb1
commit 62485531e5
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 16 additions and 0 deletions

View File

@ -26,10 +26,12 @@
<hr class="separator" />
<div id="page-navigator">
<a
aria-label="First Page"
class="nav-link icon"
class:disabled-link={disableLinkPrev}
href={firstPageLink}><DoubleArrowLeft /></a>
<a
aria-label="Prev Page"
class="nav-link icon"
class:disabled-link={disableLinkPrev}
href={prevLink}><ChevronLeft /></a>
@ -37,10 +39,12 @@
<p id="page-num">{pageN}/{maxPageN}</p>
</div>
<a
aria-label="Next Page"
class="nav-link icon"
class:disabled-link={disableLinkNext}
href="/page/{Math.min(maxPageN, pageN+1)}"><ChevronRight /></a>
<a
aria-label="Last Page"
class="nav-link icon"
class:disabled-link={disableLinkNext}
href="/page/{maxPageN}"><DoubleArrowRight /></a>

View File

@ -5,3 +5,15 @@ test('Navigate to blog post', async ({ page }) => {
await page.getByText('The Perfect Math Class').click();
await expect(page).toHaveURL("/post/the-perfect-math-class/");
});
test('Navigate to page 2', async ({ page }) => {
await page.goto('/post');
await page.getByRole('link', { name: 'Next Page' }).click();
await expect(page).toHaveURL("/page/2/");
await page.getByRole('link', { name: 'Prev Page' }).click();
await expect(page).toHaveURL("/post/");
await page.getByRole('link', { name: 'Last Page' }).click();
await expect(page).toHaveURL("/page/2/");
await page.getByRole('link', { name: 'First Page' }).click();
await expect(page).toHaveURL("/post/");
});