Skip to content

Commit 7008890

Browse files
authored
test: 新增协同编辑冲突编辑用例、多浏览器测试 (#340)
* test: 新增冲突编辑用例 * test: 新增webkit浏览器测试 * refactor: 使用不同的浏览器启动页面
1 parent ad461c1 commit 7008890

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

packages/docs/fluent-editor/demos/collaborative-editing.spec.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { type Browser, chromium, expect, type Page, test } from '@playwright/test'
1+
import { type Browser, chromium, expect, firefox, type Page, test } from '@playwright/test'
22

33
const DEMO_URL = 'http://localhost:5173/tiny-editor/docs/demo/collaborative-editing'
44

55
test.describe.configure({ mode: 'serial' })
66

77
async function openTwoPages(): Promise<[Page, Page, Browser, Browser]> {
88
const browser1 = await chromium.launch()
9-
const browser2 = await chromium.launch()
9+
const browser2 = await firefox.launch()
1010

1111
const page1 = await browser1.newPage()
1212
const page2 = await browser2.newPage()
@@ -141,7 +141,6 @@ test('size collaborative-editing test', async () => {
141141
}
142142
})
143143

144-
// serif
145144
test('font collaborative-editing test', async () => {
146145
await typeSync(p1, p2, 'font')
147146
await p1.locator('.ql-editor').click()
@@ -296,3 +295,22 @@ test('fullscreen collaborative-editing test', async () => {
296295
await p1.getByLabel('fullscreen').click({ force: true })
297296
await expect(p1.getByLabel('fullscreen')).toBeVisible()
298297
})
298+
299+
test('edit conflict simultaneously test', async () => {
300+
await Promise.all([
301+
p1.locator('.ql-editor').click(),
302+
p2.locator('.ql-editor').click(),
303+
])
304+
await Promise.all([
305+
p1.keyboard.type('A'),
306+
p2.keyboard.type('B'),
307+
])
308+
await expect.poll(async () => {
309+
const text1 = await p1.locator('.ql-editor').textContent()
310+
const text2 = await p2.locator('.ql-editor').textContent()
311+
if (text1 === text2 && (text1 === 'AB' || text1 === 'BA')) {
312+
return true
313+
}
314+
return false
315+
}).toBeTruthy()
316+
})

0 commit comments

Comments
 (0)