Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/docs/fluent-editor/demos/collaborative-editing.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type Browser, chromium, expect, type Page, test } from '@playwright/test'
import { type Browser, chromium, expect, firefox, type Page, test } from '@playwright/test'

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

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

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

const page1 = await browser1.newPage()
const page2 = await browser2.newPage()
Expand Down Expand Up @@ -141,7 +141,6 @@ test('size collaborative-editing test', async () => {
}
})

// serif
test('font collaborative-editing test', async () => {
await typeSync(p1, p2, 'font')
await p1.locator('.ql-editor').click()
Expand Down Expand Up @@ -296,3 +295,22 @@ test('fullscreen collaborative-editing test', async () => {
await p1.getByLabel('fullscreen').click({ force: true })
await expect(p1.getByLabel('fullscreen')).toBeVisible()
})

test('edit conflict simultaneously test', async () => {
await Promise.all([
p1.locator('.ql-editor').click(),
p2.locator('.ql-editor').click(),
])
await Promise.all([
p1.keyboard.type('A'),
p2.keyboard.type('B'),
])
await expect.poll(async () => {
const text1 = await p1.locator('.ql-editor').textContent()
const text2 = await p2.locator('.ql-editor').textContent()
if (text1 === text2 && (text1 === 'AB' || text1 === 'BA')) {
return true
}
return false
}).toBeTruthy()
})