Skip to content

Commit 8c16590

Browse files
committed
tests - add tests for categories link on listing page
1 parent 0f0ee25 commit 8c16590

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/integration/playwright/tests/blog-simple-blog.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,23 @@ Object.entries(testPages).forEach(([postDir, pageName]) => {
4949
await page.goto(`./blog/simple-blog/_site/${postDir}/welcome/#img-lst`);
5050
await checkCategoryLink('news', pageName);
5151
});
52+
53+
if (pageName !== 'table.html') {
54+
test(`Categories link on listing page works for ${pageName}`, async ({ page }) => {
55+
const checkCategoryLink = async (category: string, pageName: string) => {
56+
await page.goto(`./blog/simple-blog/_site/${pageName}`);
57+
await page.getByText(category, { exact: true }).click();
58+
await expect(page).toHaveURL(getUrl(`blog/simple-blog/_site/${pageName}#category=${encodeURIComponent(category)}`));
59+
await expect(page.locator(`div.category[data-category="${btoa(encodeURIComponent(category))}"]`)).toHaveClass(/active/);
60+
};
61+
await checkCategoryLink('apos\'trophe', pageName);
62+
await expect(page.getByRole('link', { name: 'Post With Code' })).toBeVisible();
63+
await checkCategoryLink('euros (€)', pageName);
64+
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeVisible();
65+
await checkCategoryLink('免疫', pageName);
66+
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeVisible();
67+
});
68+
}
5269
});
70+
71+

0 commit comments

Comments
 (0)