|
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' |
2 | 2 |
|
3 | 3 | const DEMO_URL = 'http://localhost:5173/tiny-editor/docs/demo/collaborative-editing' |
4 | 4 |
|
5 | 5 | test.describe.configure({ mode: 'serial' }) |
6 | 6 |
|
7 | 7 | async function openTwoPages(): Promise<[Page, Page, Browser, Browser]> { |
8 | 8 | const browser1 = await chromium.launch() |
9 | | - const browser2 = await chromium.launch() |
| 9 | + const browser2 = await firefox.launch() |
10 | 10 |
|
11 | 11 | const page1 = await browser1.newPage() |
12 | 12 | const page2 = await browser2.newPage() |
@@ -141,7 +141,6 @@ test('size collaborative-editing test', async () => { |
141 | 141 | } |
142 | 142 | }) |
143 | 143 |
|
144 | | -// serif |
145 | 144 | test('font collaborative-editing test', async () => { |
146 | 145 | await typeSync(p1, p2, 'font') |
147 | 146 | await p1.locator('.ql-editor').click() |
@@ -296,3 +295,22 @@ test('fullscreen collaborative-editing test', async () => { |
296 | 295 | await p1.getByLabel('fullscreen').click({ force: true }) |
297 | 296 | await expect(p1.getByLabel('fullscreen')).toBeVisible() |
298 | 297 | }) |
| 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