-
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
1 parent
5ad4fff
commit 203c8cf
Showing
109 changed files
with
2,341 additions
and
1,923 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
build | ||
coverage | ||
.github/ | ||
report/ | ||
test-results/ | ||
*.log | ||
*.yml | ||
*.json | ||
**/.git | ||
**/node_modules | ||
*.scss | ||
|
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"trailingComma": "none", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": false, | ||
"bracketSpacing": true, | ||
"bracketSameLine": true, | ||
"arrowParens": "always" | ||
} |
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,61 +1,100 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:3000/archives/'); | ||
await page.goto("http://localhost:3000/archives/"); | ||
}); | ||
|
||
test.describe('Archives', () => { | ||
test.describe("Archives", () => { | ||
// NOTE: Next.js generateMetadata is unflexible, I compromised this page metadata same with home page. | ||
test('should exists and set collect values in head meta', async ({ page }) => { | ||
await expect(page.locator('meta[name="author"]')).toHaveAttribute('content', 'john doe'); | ||
test("should exists and set collect values in head meta", async ({ | ||
page | ||
}) => { | ||
await expect(page.locator('meta[name="author"]')).toHaveAttribute( | ||
"content", | ||
"john doe" | ||
); | ||
// TODO: maybe wrong property. I'll be delete it. | ||
// await expect(page.locator('meta[property="article:author"]')).toHaveAttribute('content', 'john doe'); | ||
await expect(page.locator('meta[property="og:title"]')).toHaveAttribute('content', 'E2E Test Site'); | ||
await expect(page.locator('meta[property="og:type"]')).toHaveAttribute('content', 'website'); | ||
await expect(page.locator('meta[property="og:url"]')).toHaveAttribute('content', 'http://localhost:3000/'); | ||
await expect(page.locator('meta[property="og:site_name"]')).toHaveAttribute('content', 'E2E Test Site'); | ||
await expect(page.locator('meta[property="og:locale"]')).toHaveAttribute('content', 'ja_JP'); | ||
await expect(page.locator('meta[property="og:image"]')).toHaveAttribute('content', 'http://localhost:3000/defaultImage.jpg'); | ||
await expect(page.locator('meta[name="injectedMetaName"]')).toHaveAttribute('content', 'injectedMetaContent'); | ||
|
||
const robots = await page.locator('meta[name="robots"]').getAttribute('content'); | ||
const sortedRobots = robots.split(',').sort().map(r => r.trim()); | ||
expect(sortedRobots.join(', ')).toBe('noarchive, nofollow, noimageindex, noindex'); | ||
await expect(page.locator('meta[property="og:title"]')).toHaveAttribute( | ||
"content", | ||
"E2E Test Site" | ||
); | ||
await expect(page.locator('meta[property="og:type"]')).toHaveAttribute( | ||
"content", | ||
"website" | ||
); | ||
await expect(page.locator('meta[property="og:url"]')).toHaveAttribute( | ||
"content", | ||
"http://localhost:3000/" | ||
); | ||
await expect(page.locator('meta[property="og:site_name"]')).toHaveAttribute( | ||
"content", | ||
"E2E Test Site" | ||
); | ||
await expect(page.locator('meta[property="og:locale"]')).toHaveAttribute( | ||
"content", | ||
"ja_JP" | ||
); | ||
await expect(page.locator('meta[property="og:image"]')).toHaveAttribute( | ||
"content", | ||
"http://localhost:3000/defaultImage.jpg" | ||
); | ||
await expect(page.locator('meta[name="injectedMetaName"]')).toHaveAttribute( | ||
"content", | ||
"injectedMetaContent" | ||
); | ||
|
||
const robots = await page | ||
.locator('meta[name="robots"]') | ||
.getAttribute("content"); | ||
const sortedRobots = robots | ||
.split(",") | ||
.sort() | ||
.map((r) => r.trim()); | ||
expect(sortedRobots.join(", ")).toBe( | ||
"noarchive, nofollow, noimageindex, noindex" | ||
); | ||
}); | ||
|
||
test('should display all articles when text input is empty', async ({ page }) => { | ||
await expect(page.getByText('posts')).toHaveText('10 posts'); | ||
test("should display all articles when text input is empty", async ({ | ||
page | ||
}) => { | ||
await expect(page.getByText("posts")).toHaveText("10 posts"); | ||
}); | ||
|
||
test('should display filterd articles when input text field - with screenshot', async ({ page }, testInfo) => { | ||
await page.getByRole('textbox').fill('With'); | ||
test("should display filterd articles when input text field - with screenshot", async ({ | ||
page | ||
}, testInfo) => { | ||
await page.getByRole("textbox").fill("With"); | ||
|
||
await expect(page.getByText('posts')).toHaveText('3 posts'); | ||
await expect(page.getByText("posts")).toHaveText("3 posts"); | ||
|
||
const archives = await page.locator('main>section'); | ||
await expect(archives).toContainText('With externalResources'); | ||
await expect(archives).toContainText('Without tags'); | ||
await expect(archives).toContainText('Without robots'); | ||
await expect(archives).not.toContainText('Standard nested post'); | ||
const archives = await page.locator("main>section"); | ||
await expect(archives).toContainText("With externalResources"); | ||
await expect(archives).toContainText("Without tags"); | ||
await expect(archives).toContainText("Without robots"); | ||
await expect(archives).not.toContainText("Standard nested post"); | ||
|
||
const screenshot = await page.screenshot({ fullPage: true }); | ||
await testInfo.attach('screenshot', { | ||
body: screenshot, | ||
contentType: 'image/png', | ||
await testInfo.attach("screenshot", { | ||
body: screenshot, | ||
contentType: "image/png" | ||
}); | ||
}); | ||
|
||
test('should display all articles after clear text field - with screenshot', async ({ page }, testInfo) => { | ||
await page.getByRole('textbox').fill('Empty'); | ||
await expect(page.getByText('posts')).toHaveText('2 posts'); | ||
test("should display all articles after clear text field - with screenshot", async ({ | ||
page | ||
}, testInfo) => { | ||
await page.getByRole("textbox").fill("Empty"); | ||
await expect(page.getByText("posts")).toHaveText("2 posts"); | ||
|
||
await page.getByRole('textbox').clear(); | ||
await expect(page.getByText('posts')).toHaveText('10 posts'); | ||
await page.getByRole("textbox").clear(); | ||
await expect(page.getByText("posts")).toHaveText("10 posts"); | ||
|
||
const screenshot = await page.screenshot({ fullPage: true }); | ||
await testInfo.attach('screenshot', { | ||
body: screenshot, | ||
contentType: 'image/png', | ||
await testInfo.attach("screenshot", { | ||
body: screenshot, | ||
contentType: "image/png" | ||
}); | ||
}); | ||
}); |
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,54 +1,93 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { assert } from 'console'; | ||
import { test, expect } from "@playwright/test"; | ||
import { assert } from "console"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:3000/articles/'); | ||
await page.goto("http://localhost:3000/articles/"); | ||
}); | ||
|
||
test.describe('Articles', () => { | ||
test.describe("Articles", () => { | ||
// NOTE: Next.js generateMetadata is unflexible, I compromised this page metadata same with home page. | ||
test('should exists and set collect values in head meta', async ({ page }) => { | ||
await expect(page.locator('meta[name="author"]')).toHaveAttribute('content', 'john doe'); | ||
test("should exists and set collect values in head meta", async ({ | ||
page | ||
}) => { | ||
await expect(page.locator('meta[name="author"]')).toHaveAttribute( | ||
"content", | ||
"john doe" | ||
); | ||
// TODO: maybe wrong property. I'll be delete it. | ||
// await expect(page.locator('meta[property="article:author"]')).toHaveAttribute('content', 'john doe'); | ||
await expect(page.locator('meta[property="og:title"]')).toHaveAttribute('content', 'E2E Test Site'); | ||
await expect(page.locator('meta[property="og:type"]')).toHaveAttribute('content', 'website'); | ||
await expect(page.locator('meta[property="og:url"]')).toHaveAttribute('content', 'http://localhost:3000/'); | ||
await expect(page.locator('meta[property="og:site_name"]')).toHaveAttribute('content', 'E2E Test Site'); | ||
await expect(page.locator('meta[property="og:locale"]')).toHaveAttribute('content', 'ja_JP'); | ||
await expect(page.locator('meta[property="og:image"]')).toHaveAttribute('content', 'http://localhost:3000/defaultImage.jpg'); | ||
await expect(page.locator('meta[name="injectedMetaName"]')).toHaveAttribute('content', 'injectedMetaContent'); | ||
|
||
const robots = await page.locator('meta[name="robots"]').getAttribute('content'); | ||
const sortedRobots = robots.split(',').sort().map(r => r.trim()); | ||
expect(sortedRobots.join(', ')).toBe('noarchive, nofollow, noimageindex, noindex'); | ||
await expect(page.locator('meta[property="og:title"]')).toHaveAttribute( | ||
"content", | ||
"E2E Test Site" | ||
); | ||
await expect(page.locator('meta[property="og:type"]')).toHaveAttribute( | ||
"content", | ||
"website" | ||
); | ||
await expect(page.locator('meta[property="og:url"]')).toHaveAttribute( | ||
"content", | ||
"http://localhost:3000/" | ||
); | ||
await expect(page.locator('meta[property="og:site_name"]')).toHaveAttribute( | ||
"content", | ||
"E2E Test Site" | ||
); | ||
await expect(page.locator('meta[property="og:locale"]')).toHaveAttribute( | ||
"content", | ||
"ja_JP" | ||
); | ||
await expect(page.locator('meta[property="og:image"]')).toHaveAttribute( | ||
"content", | ||
"http://localhost:3000/defaultImage.jpg" | ||
); | ||
await expect(page.locator('meta[name="injectedMetaName"]')).toHaveAttribute( | ||
"content", | ||
"injectedMetaContent" | ||
); | ||
|
||
const robots = await page | ||
.locator('meta[name="robots"]') | ||
.getAttribute("content"); | ||
const sortedRobots = robots | ||
.split(",") | ||
.sort() | ||
.map((r) => r.trim()); | ||
expect(sortedRobots.join(", ")).toBe( | ||
"noarchive, nofollow, noimageindex, noindex" | ||
); | ||
}); | ||
|
||
test('should display 10 articles - with screenshot', async ({ page }, testInfo ) => { | ||
const articles = await page.locator('main>section>article').all(); | ||
test("should display 10 articles - with screenshot", async ({ | ||
page | ||
}, testInfo) => { | ||
const articles = await page.locator("main>section>article").all(); | ||
|
||
await assert(articles.length === 10); | ||
await expect(articles[0].getByRole('time')).toHaveAttribute('datetime'); | ||
await expect(articles[0].getByRole('time')).toContainText('2023.12.20'); | ||
await expect(articles[0].getByRole('heading')).toHaveText('Standard nested post'); | ||
await expect(articles[0].getByRole("time")).toHaveAttribute("datetime"); | ||
await expect(articles[0].getByRole("time")).toContainText("2023.12.20"); | ||
await expect(articles[0].getByRole("heading")).toHaveText( | ||
"Standard nested post" | ||
); | ||
// TODO | ||
// await expect(articles[0].getAttribute('datetime')).toBe('1703069944'); | ||
// const firstArticleLink = await articles[0].locator('div>a'); | ||
// await expect(firstArticleLink.getAttribute('href')).toBe('/articles/nested/standard/'); | ||
|
||
await expect(articles[9].getByRole('time')).toHaveAttribute('datetime'); | ||
await expect(articles[9].getByRole("time")).toHaveAttribute("datetime"); | ||
|
||
await expect(articles[9].getByRole('time')).toContainText('2023.12.07'); | ||
await expect(articles[9].getByRole('heading')).toHaveText('Suspendisse quis tellus vestibulum, vestibulum est non, tincidunt orci.'); | ||
await expect(articles[9].getByRole("time")).toContainText("2023.12.07"); | ||
await expect(articles[9].getByRole("heading")).toHaveText( | ||
"Suspendisse quis tellus vestibulum, vestibulum est non, tincidunt orci." | ||
); | ||
// TODO | ||
// await expect(articles[9].getAttribute('datetime')).toBe('1701948427'); | ||
// const lastArticleLink = await articles[9].locator('div>a'); | ||
// await expect(lastArticleLink.getAttribute('href')).toBe('/articles/2023/12/07/vestibulum/'); | ||
|
||
const screenshot = await page.screenshot({ fullPage: true }); | ||
await testInfo.attach('screenshot', { | ||
body: screenshot, | ||
contentType: 'image/png', | ||
await testInfo.attach("screenshot", { | ||
body: screenshot, | ||
contentType: "image/png" | ||
}); | ||
}); | ||
}); |
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,14 +1,20 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:3000/articles/nested/empty-robots/'); | ||
await page.goto("http://localhost:3000/articles/nested/empty-robots/"); | ||
}); | ||
|
||
test.describe('Article - Empty Robots', () => { | ||
|
||
test('should fallback to default robots in head meta', async ({ page } ) => { | ||
const robots = await page.locator('meta[name="robots"]').getAttribute('content'); | ||
const sortedRobots = robots.split(',').sort().map(r => r.trim()); | ||
expect(sortedRobots.join(', ')).toBe('noarchive, nofollow, noimageindex, noindex'); | ||
test.describe("Article - Empty Robots", () => { | ||
test("should fallback to default robots in head meta", async ({ page }) => { | ||
const robots = await page | ||
.locator('meta[name="robots"]') | ||
.getAttribute("content"); | ||
const sortedRobots = robots | ||
.split(",") | ||
.sort() | ||
.map((r) => r.trim()); | ||
expect(sortedRobots.join(", ")).toBe( | ||
"noarchive, nofollow, noimageindex, noindex" | ||
); | ||
}); | ||
}); |
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,11 +1,13 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:3000/articles/nested/empty-tags/'); | ||
await page.goto("http://localhost:3000/articles/nested/empty-tags/"); | ||
}); | ||
|
||
test.describe('Article - Empty Tags', () => { | ||
test('should invisible `articles:tag` meta in head', async ({ page } ) => { | ||
await expect(page.locator('meta[property="article:tag"]')).not.toBeVisible(); | ||
test.describe("Article - Empty Tags", () => { | ||
test("should invisible `articles:tag` meta in head", async ({ page }) => { | ||
await expect( | ||
page.locator('meta[property="article:tag"]') | ||
).not.toBeVisible(); | ||
}); | ||
}); |
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,13 +1,18 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:3000/articles/nested/partially-robots/'); | ||
await page.goto("http://localhost:3000/articles/nested/partially-robots/"); | ||
}); | ||
|
||
test.describe('Article - Partially Robots', () => { | ||
test('should not overwrite by default robots in head', async ({ page } ) => { | ||
const robots = await page.locator('meta[name="robots"]').getAttribute('content'); | ||
const sortedRobots = robots.split(',').sort().map(r => r.trim()); | ||
expect(sortedRobots.join(', ')).toBe('noarchive, nofollow'); | ||
test.describe("Article - Partially Robots", () => { | ||
test("should not overwrite by default robots in head", async ({ page }) => { | ||
const robots = await page | ||
.locator('meta[name="robots"]') | ||
.getAttribute("content"); | ||
const sortedRobots = robots | ||
.split(",") | ||
.sort() | ||
.map((r) => r.trim()); | ||
expect(sortedRobots.join(", ")).toBe("noarchive, nofollow"); | ||
}); | ||
}); |
Oops, something went wrong.