-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rich-text-editor): tiny-tiptap unit test
- Loading branch information
Showing
9 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
examples/sites/demos/pc/app/rich-text-editor/basic-usage.spec.ts
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,17 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('基本用法', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#basic-usage') | ||
|
||
const wrap = page.locator('#basic-usage') | ||
const editor = wrap.locator('.tiny-rich-text-editor > .tiny-rich-text-editor__container .ProseMirror') | ||
|
||
await expect(editor).toBeVisible() | ||
await expect(editor).toHaveAttribute('contenteditable', 'true') | ||
|
||
await editor.focus() | ||
await expect(editor).toHaveClass('ProseMirror-focused') | ||
|
||
await editor.fill('hello') | ||
}) |
17 changes: 17 additions & 0 deletions
17
examples/sites/demos/pc/app/rich-text-editor/bubble-menu-usage.spec.ts
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,17 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('气泡菜单', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#bubble-menu-usage') | ||
|
||
const wrap = page.locator('#bubble-menu-usage') | ||
const editor = wrap.locator('.tiny-rich-text-editor > .tiny-rich-text-editor__container .ProseMirror') | ||
|
||
await expect(editor).toBeVisible() | ||
|
||
const content = editor.locator('p') | ||
await content.selectText() | ||
const bubbleMenu = editor.locator('div[data-tippy-root]') | ||
|
||
await expect(bubbleMenu).toBeDefined() | ||
}) |
17 changes: 17 additions & 0 deletions
17
examples/sites/demos/pc/app/rich-text-editor/collaboration-usage.spec.ts
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,17 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('协同编辑', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#collaboration-usage') | ||
|
||
const wrap = page.locator('#collaboration-usage') | ||
const editor = wrap.locator('.tiny-rich-text-editor > .tiny-rich-text-editor__container .ProseMirror') | ||
|
||
await expect(editor).toBeVisible() | ||
|
||
const contents = editor.locator('p') | ||
const content = contents.nth(0) | ||
content.selectText() | ||
const selection = editor.locator('.ProseMirror-yjs-selection') | ||
await expect(selection).toBeDefined() | ||
}) |
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
13 changes: 13 additions & 0 deletions
13
examples/sites/demos/pc/app/rich-text-editor/custom-bar-usage.spec.ts
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 { test, expect } from '@playwright/test' | ||
|
||
test('自定义工具栏', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#custom-bar-usage') | ||
|
||
const wrap = page.locator('#custom-bar-usage') | ||
const toolbarMenu = wrap.locator('.tiny-rich-text-editor > .tiny-toolbar-menu__view') | ||
const menuItems = toolbarMenu.locator('.tiny-toolbar-menu__item') | ||
|
||
await expect(toolbarMenu).toBeVisible() | ||
await expect(menuItems).toHaveCount(2) | ||
}) |
24 changes: 24 additions & 0 deletions
24
examples/sites/demos/pc/app/rich-text-editor/event-usage.spec.ts
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 { test, expect } from '@playwright/test' | ||
|
||
test('事件', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#event-usage') | ||
|
||
const wrap = page.locator('#event-usage') | ||
const editor = wrap.locator('.tiny-rich-text-editor > .tiny-rich-text-editor__container .ProseMirror') | ||
|
||
await expect(editor).toBeVisible() | ||
|
||
editor.focus() | ||
editor.blur() | ||
|
||
const logs: string[] = [] | ||
// 将消息填充到 logs | ||
page.on('console', (msg) => logs.push(msg.text())) | ||
await expect(logs).toContain('beforeCreate') | ||
await expect(logs).toContain('transaction') | ||
await expect(logs).toContain('create') | ||
|
||
await expect(logs).toContain('focus') | ||
await expect(logs).toContain('blur') | ||
}) |
15 changes: 15 additions & 0 deletions
15
examples/sites/demos/pc/app/rich-text-editor/options-usage.spec.ts
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,15 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('自定义配置', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#options-usage') | ||
|
||
const wrap = page.locator('#options-usage') | ||
const editor = wrap.locator('.tiny-rich-text-editor > .tiny-rich-text-editor__container .ProseMirror') | ||
|
||
await expect(editor).toBeVisible() | ||
await expect(editor).toHaveAttribute('contenteditable', 'true') | ||
|
||
await expect(editor).toBeFocused() | ||
await expect(editor).toHaveClass('ProseMirror-focused') | ||
}) |
13 changes: 13 additions & 0 deletions
13
examples/sites/demos/pc/app/rich-text-editor/placeholder-usage.spec.ts
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 { test, expect } from '@playwright/test' | ||
|
||
test('placeholder', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#placeholder-usage') | ||
|
||
const wrap = page.locator('#placeholder-usage') | ||
const editor = wrap.locator('.tiny-rich-text-editor > .tiny-rich-text-editor__container .ProseMirror') | ||
const placeholder = editor.locator('.is-editor-empty.is-empty') | ||
|
||
await expect(placeholder).toBeVisible() | ||
await expect(placeholder).toHaveAttribute('data-placeholder', '自定义placeholder') | ||
}) |
17 changes: 17 additions & 0 deletions
17
examples/sites/demos/pc/app/rich-text-editor/slash-menu-usage.spec.ts
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,17 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('斜杠菜单', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('rich-text-editor#slash-menu-usage') | ||
|
||
const wrap = page.locator('#slash-menu-usage') | ||
const editor = wrap.locator('.tiny-rich-text-editor > .tiny-rich-text-editor__container .ProseMirror') | ||
|
||
await expect(editor).toBeVisible() | ||
|
||
await editor.focus() | ||
await editor.fill('/') | ||
|
||
const slashMenu = page.locator('.tiny-slash-menu__view') | ||
await expect(slashMenu).toBeDefined() | ||
}) |