-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): switch to playwright (#108)
- Loading branch information
1 parent
5143ed5
commit de55e4d
Showing
37 changed files
with
1,068 additions
and
1,764 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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,29 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
import { BASE, BUNDLER, isCI, isDev } from './utils/env.js' | ||
|
||
const commandPart1 = isDev ? 'docs:dev' : 'docs:build' | ||
const commandPart2 = BUNDLER === 'vite' ? '' : `-${BUNDLER}` | ||
const commandPart3 = isDev ? '' : ' && pnpm docs:serve' | ||
|
||
export default defineConfig({ | ||
testDir: 'tests', | ||
forbidOnly: isCI, | ||
reporter: isCI ? 'github' : 'line', | ||
retries: isCI ? 2 : 0, | ||
workers: isDev ? 1 : undefined, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
use: { | ||
baseURL: `http://127.0.0.1:9080${BASE}`, | ||
trace: 'on-first-retry', | ||
}, | ||
webServer: { | ||
command: `pnpm docs:clean && pnpm ${commandPart1}${commandPart2}${commandPart3}`, | ||
url: 'http://127.0.0.1:9080', | ||
reuseExistingServer: !isCI, | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
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,39 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test.describe('plugin-blog', () => { | ||
test('generate type page', async ({ page }) => { | ||
const types = ['article', 'timeline'] | ||
|
||
for (const type of types) { | ||
await page.goto(`${type}/`) | ||
await expect(page.locator('main')).not.toHaveText('404') | ||
await expect(page.locator('article').first()).toBeVisible() | ||
} | ||
}) | ||
|
||
test('generate category main page', async ({ page }) => { | ||
const categories = ['category', 'tag'] | ||
|
||
for (const category of categories) { | ||
await page.goto(`${category}/`) | ||
await expect(page.locator('main')).not.toHaveText('404') | ||
await expect(page.locator('.article-wrapper')).toBeVisible() | ||
await expect(page.locator('article')).toHaveCount(0) | ||
} | ||
}) | ||
|
||
test('generate category item page', async ({ page }) => { | ||
const categoryConfig = { | ||
category: ['category-a', 'category-b', 'category-c', '分类-1', '分类-2'], | ||
tag: ['tag-a', 'tag-b', 'tag-c', 'tag-d', '标签-1', '标签-2'], | ||
} | ||
|
||
for (const [name, items] of Object.entries(categoryConfig)) { | ||
for (const item of items) { | ||
await page.goto(`${name}/${encodeURI(item)}/`) | ||
|
||
await expect(page.locator('main')).not.toHaveText('404') | ||
} | ||
} | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test.describe('copy-code', () => { | ||
test('have copy code button', async ({ context, page }) => { | ||
await context.grantPermissions(['clipboard-read', 'clipboard-write']) | ||
|
||
await page.goto('copy-code/') | ||
await new Promise((resolve) => setTimeout(resolve, 1000)) | ||
|
||
const locator = page.locator('.vp-copy-code-button') | ||
|
||
await expect(locator).toHaveCount(1) | ||
|
||
await locator.first().click() | ||
|
||
expect(locator.first()).toHaveAttribute('class', /copied/) | ||
|
||
const content = await page.evaluate(() => navigator.clipboard.readText()) | ||
|
||
expect(content).toMatch(/const a = 1\r?\nconst b = 2\r?\n/) | ||
|
||
await page.evaluate(() => navigator.clipboard.writeText('')) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test.describe('plugin-copyright', () => { | ||
test('disable selection', async ({ page }) => { | ||
await page.goto('') | ||
|
||
await expect(page.locator('#app')).toHaveCSS('user-select', 'auto') | ||
|
||
await page.goto('copyright/selection.html') | ||
|
||
await expect(page.locator('#app')).toHaveCSS('user-select', 'none') | ||
}) | ||
}) |
Oops, something went wrong.