Repository navigation
feat: add e2e #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: add e2e #476
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,19 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('has toolbar AI button and opens AI input dialog', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/ai') | ||
|
|
||
| const toolbar = page.locator('.ql-toolbar').first() | ||
| const editor = page.locator('#editor-add-toolbar-item .ql-editor') | ||
| const aiBtn = toolbar.locator('.ql-ai') | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toContainText('我曾经跨过山和大海') | ||
| await expect(aiBtn).toBeVisible() | ||
|
|
||
| await editor.click() | ||
| await aiBtn.click() | ||
| await expect(page.locator('.ql-ai-dialog')).toBeVisible() | ||
| await expect(page.locator('.ql-ai-input')).toBeVisible() | ||
| }) |
This file contains hidden or 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
24 changes: 24 additions & 0 deletions
24
packages/docs/fluent-editor/demos/code-block-highlight.spec.ts
This file contains hidden or 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('has toolbar, code-block button and golang language option', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/code-block-highlight') | ||
|
|
||
| const toolbar = page.locator('.ql-toolbar').first() | ||
| const editor = page.locator('#editor .ql-editor') | ||
| const codeBlockBtn = toolbar.locator('.ql-code-block') | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toBeVisible({ timeout: 30_000 }) | ||
| await expect(codeBlockBtn).toBeVisible() | ||
|
|
||
| await editor.click() | ||
| await codeBlockBtn.click() | ||
|
|
||
| const codeBlock = editor.locator('.ql-code-block-container').first() | ||
| await expect(codeBlock).toBeVisible() | ||
| await expect(codeBlock.locator('option[value="go"]')).toHaveText('Golang') | ||
|
|
||
| await editor.locator('.ql-code-block').first().click() | ||
| await page.keyboard.type('func main() {}') | ||
| await expect(editor.locator('.ql-code-block').first()).toContainText('func main() {}') | ||
| }) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,19 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('renders full custom toolbar with extra tools and placeholder', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/custom-toolbar') | ||
|
|
||
| const block = page.locator('.vp-raw').first() | ||
| const toolbar = block.locator('.ql-toolbar').first() | ||
| const editor = block.locator('.ql-editor').first() | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toHaveAttribute('data-placeholder', '请输入内容...') | ||
| await expect(toolbar.locator('.ql-undo')).toBeVisible() | ||
| await expect(toolbar.locator('.ql-redo')).toBeVisible() | ||
| await expect(toolbar.locator('.ql-emoji')).toBeVisible() | ||
| await expect(toolbar.locator('.ql-screenshot')).toBeVisible() | ||
| await expect(toolbar.locator('.ql-format-painter')).toBeVisible() | ||
| await expect(toolbar.locator('.ql-picker.ql-font')).toBeVisible() | ||
| }) |
This file contains hidden or 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,17 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('has toolbar emoji button and opens emoji picker', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/emoji') | ||
|
|
||
| const toolbar = page.locator('.ql-toolbar').first() | ||
| const editor = page.locator('#editor .ql-editor') | ||
| const emojiBtn = toolbar.locator('.ql-emoji') | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toBeVisible({ timeout: 30_000 }) | ||
| await expect(emojiBtn).toBeVisible() | ||
|
|
||
| await editor.click() | ||
| await emojiBtn.click() | ||
| await expect(page.locator('#emoji-picker')).toBeVisible() | ||
| }) |
31 changes: 31 additions & 0 deletions
31
packages/docs/fluent-editor/demos/file-upload-handle.spec.ts
This file contains hidden or 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,31 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| const pngBuffer = Buffer.from( | ||
| 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', | ||
| 'base64', | ||
| ) | ||
|
wuyiping0628 marked this conversation as resolved.
|
||
|
|
||
| test('uploads image and uses fail handler placeholder', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/file-upload') | ||
|
|
||
| const block = page.locator('.vp-raw').nth(1) | ||
| const toolbar = block.locator('.ql-toolbar').first() | ||
| const editor = block.locator('.ql-editor').first() | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toBeVisible({ timeout: 30_000 }) | ||
| await expect(toolbar.getByLabel('image')).toBeVisible() | ||
| await expect(toolbar.getByLabel('video')).toBeVisible() | ||
| await expect(toolbar.getByLabel('file')).toBeVisible() | ||
|
|
||
| await toolbar.getByLabel('image').click() | ||
| await toolbar.locator('input.ql-image').setInputFiles({ | ||
| name: 'a.png', | ||
| mimeType: 'image/png', | ||
| buffer: pngBuffer, | ||
| }) | ||
|
|
||
| const image = editor.getByRole('img').first() | ||
| await expect(image).toBeVisible({ timeout: 10_000 }) | ||
| await expect(image).toHaveAttribute('src', /edge/) | ||
| }) | ||
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
packages/docs/fluent-editor/demos/flow-chart-background.spec.ts
This file contains hidden or 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,16 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('renders flow chart background demo with initial nodes', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/flow-chart') | ||
|
|
||
| const block = page.locator('.vp-raw').nth(2) | ||
| const toolbar = block.locator('.ql-toolbar').first() | ||
| const editor = block.locator('.ql-editor').first() | ||
| const chart = editor.locator('.ql-flow-chart-item') | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(toolbar.locator('.ql-flow-chart')).toBeVisible() | ||
| await expect(chart).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor.locator('.lf-node')).toHaveCount(2) | ||
| await expect(editor.locator('.lf-edge')).toHaveCount(1) | ||
|
wuyiping0628 marked this conversation as resolved.
|
||
| }) | ||
This file contains hidden or 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,15 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('renders flow chart grid demo with initial nodes', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/flow-chart') | ||
|
|
||
| const block = page.locator('.vp-raw').nth(1) | ||
| const toolbar = block.locator('.ql-toolbar').first() | ||
| const editor = block.locator('.ql-editor').first() | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(toolbar.locator('.ql-flow-chart')).toBeVisible() | ||
| await expect(editor.locator('.ql-flow-chart-item')).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor.locator('.lf-node')).toHaveCount(2) | ||
| await expect(editor.locator('.lf-edge')).toHaveCount(1) | ||
| }) |
15 changes: 15 additions & 0 deletions
15
packages/docs/fluent-editor/demos/flow-chart-resize.spec.ts
This file contains hidden or 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,15 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('renders flow chart with resize handles', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/flow-chart') | ||
|
|
||
| const block = page.locator('.vp-raw').nth(3) | ||
| const toolbar = block.locator('.ql-toolbar').first() | ||
| const editor = block.locator('.ql-editor').first() | ||
| const chart = editor.locator('.ql-flow-chart-item') | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(toolbar.locator('.ql-flow-chart')).toBeVisible() | ||
| await expect(chart).toBeVisible({ timeout: 30_000 }) | ||
| await expect(chart.locator('.ql-flow-chart-resize-handle')).toHaveCount(4) | ||
| }) |
This file contains hidden or 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 hidden or 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,25 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('copies bold format with format painter', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/format-painter') | ||
|
|
||
| const toolbar = page.locator('.ql-toolbar').first() | ||
| const editor = page.locator('#editor .ql-editor') | ||
| const painterBtn = toolbar.locator('.ql-format-painter') | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toBeVisible({ timeout: 30_000 }) | ||
| await expect(painterBtn).toBeVisible() | ||
|
|
||
| await editor.click() | ||
| await toolbar.locator('.ql-bold').click() | ||
| await page.keyboard.type('Bold') | ||
| await page.keyboard.press('ControlOrMeta+a') | ||
| await painterBtn.click() | ||
| await expect(painterBtn).toHaveClass(/ql-active/) | ||
|
|
||
| await page.keyboard.press('End') | ||
| await page.keyboard.type(' Text') | ||
| await expect(editor.locator('strong')).toContainText('Bold') | ||
| await expect(editor.locator('strong')).toContainText('Text') | ||
| }) |
22 changes: 22 additions & 0 deletions
22
packages/docs/fluent-editor/demos/formula-chemistry.spec.ts
This file contains hidden or 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,22 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('inserts chemistry formula with mhchem', async ({ page }) => { | ||
| await page.goto('/tiny-editor/docs/demo/formula') | ||
|
|
||
| const block = page.locator('.vp-raw').filter({ has: page.locator('#chemistry-editor') }) | ||
| const toolbar = block.locator('.ql-toolbar').first() | ||
| const editor = page.locator('#chemistry-editor .ql-editor') | ||
| const formulaBtn = toolbar.locator('.ql-formula') | ||
|
|
||
| await expect(toolbar).toBeVisible({ timeout: 30_000 }) | ||
| await expect(editor).toBeVisible({ timeout: 30_000 }) | ||
| await expect(formulaBtn).toBeVisible() | ||
|
|
||
| await editor.click() | ||
| await formulaBtn.click() | ||
| const input = page.locator('.ql-tooltip[data-mode="formula"] input[data-formula]') | ||
| await expect(input).toBeVisible() | ||
| await input.fill('\\ce{H2O}') | ||
| await input.blur() | ||
| await expect(editor.locator('.katex')).toBeVisible() | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.