Skip to content

Commit a3e410d

Browse files
committed
Add a test for post with url encoded url
1 parent 1375b9c commit a3e410d

File tree

7 files changed

+52
-12
lines changed

7 files changed

+52
-12
lines changed
19.8 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "testing post with space"
3+
author: "Harlow Malloc"
4+
date: "2024-12-28"
5+
categories: [news, code, analysis]
6+
image: "image.jpg"
7+
---
8+
9+
This is a post folder name with space
10+
11+
```{r}
12+
1 + 1
13+
```
19.8 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "testing post with space"
3+
author: "Harlow Malloc"
4+
date: "2024-12-28"
5+
categories: [news, code, analysis]
6+
image: "image.jpg"
7+
---
8+
9+
This is a post folder name with space
10+
11+
```{r}
12+
1 + 1
13+
```
19.8 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "testing post with space"
3+
author: "Harlow Malloc"
4+
date: "2024-12-28"
5+
categories: [news, code, analysis]
6+
image: "image.jpg"
7+
---
8+
9+
This is a post folder name with space
10+
11+
```{r}
12+
1 + 1
13+
```

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,41 @@ Object.entries(testPages).forEach(([postDir, pageName]) => {
2828
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeHidden();
2929
});
3030

31-
const checkCategoryLink = async (page: Page, category: string, pageName: string) => {
31+
const checkCategoryLink = async (page: Page, category: string, pageName: string, postTitle: string) => {
3232
await page.getByText(category, { exact: true }).click();
3333
await expect(page).toHaveURL(getUrl(`blog/simple-blog/_site/${pageName}#category=${encodeURIComponent(category)}`));
3434
await expect(page.locator(`div.category[data-category="${btoa(encodeURIComponent(category))}"]`)).toHaveClass(/active/);
35+
await expect(page.getByRole('link', { name: postTitle })).toBeVisible();
3536
};
3637

3738
test(`All Categories links are clickable ${postDir} pages`,
3839
async ({ page }) => {
3940
// Checking link is working
4041
await page.goto(`./blog/simple-blog/_site/${postDir}/welcome/`);
41-
await checkCategoryLink(page, 'news', pageName);
42+
await checkCategoryLink(page, 'news', pageName, 'Welcome To My Blog');
4243
// Including for special characters
4344
await page.getByRole('link', { name: 'Welcome To My Blog' }).click();
44-
await checkCategoryLink(page, 'euros (€)', pageName);
45+
await checkCategoryLink(page, 'euros (€)', pageName, 'Welcome To My Blog');
4546
await page.getByRole('link', { name: 'Welcome To My Blog' }).click();
46-
await checkCategoryLink(page, '免疫', pageName);
47+
await checkCategoryLink(page, '免疫', pageName, 'Welcome To My Blog');
4748
await page.goto(`./blog/simple-blog/_site/${postDir}/post-with-code/`);
48-
await checkCategoryLink(page, "apos'trophe", pageName);
49+
await checkCategoryLink(page, "apos'trophe", pageName, 'Post With Code');
4950
// special check for when a page is not loaded from non root path
5051
await page.goto(`./blog/simple-blog/_site/${postDir}/welcome/#img-lst`);
51-
await checkCategoryLink(page, 'news', pageName);
52+
await checkCategoryLink(page, 'news', pageName, 'Welcome To My Blog');
53+
// special check for post with space in page name
54+
await page.goto(`./blog/simple-blog/_site/${postDir}/post with space/`);
55+
await checkCategoryLink(page, 'news', pageName, 'testing post with space');
5256
});
5357

5458
if (pageName !== 'table.html') {
5559
test(`Categories link on listing page works for ${pageName}`, async ({ page }) => {
5660
await page.goto(`./blog/simple-blog/_site/${pageName}`);
57-
await checkCategoryLink(page, 'apos\'trophe', pageName);
58-
await expect(page.getByRole('link', { name: 'Post With Code' })).toBeVisible();
61+
await checkCategoryLink(page, 'apos\'trophe', pageName, 'Post With Code');
5962
await page.goto(`./blog/simple-blog/_site/${pageName}`);
60-
await checkCategoryLink(page, 'euros (€)', pageName);
61-
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeVisible();
63+
await checkCategoryLink(page, 'euros (€)', pageName, 'Welcome To My Blog');
6264
await page.goto(`./blog/simple-blog/_site/${pageName}`);
63-
await checkCategoryLink(page, '免疫', pageName);
64-
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeVisible();
65+
await checkCategoryLink(page, '免疫', pageName, 'Welcome To My Blog');
6566
});
6667
}
6768
});

0 commit comments

Comments
 (0)