Skip to content

Commit 1ed464c

Browse files
committed
chore(test): add initial test for indexed db
Signed-off-by: Max <max@nextcloud.com>
1 parent 073a747 commit 1ed464c

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

playwright/e2e/indexed-db.spec.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { expect, mergeTests } from '@playwright/test'
7+
import { test as editorTest } from '../support/fixtures/editor'
8+
import { test as offlineTest } from '../support/fixtures/offline'
9+
import { test as randomUserTest } from '../support/fixtures/random-user'
10+
import { test as uploadFileTest } from '../support/fixtures/upload-file'
11+
12+
const test = mergeTests(editorTest, offlineTest, randomUserTest, uploadFileTest)
13+
14+
// As we switch on and off the network
15+
// we cannot run tests in parallel.
16+
test.describe.configure({ mode: 'serial' });
17+
18+
test.beforeEach(async ({ file }) => {
19+
await file.open()
20+
})
21+
22+
test('recovering from indexed db', async ({
23+
editor,
24+
file,
25+
setOffline,
26+
setOnline,
27+
}) => {
28+
await expect(editor.locator).toBeVisible()
29+
await setOffline()
30+
await editor.typeHeading('Hello world')
31+
await file.close()
32+
await setOnline()
33+
await file.open()
34+
await expect(editor.getHeading('Hello world')).toBeVisible()
35+
await expect(editor.offlineState).not.toBeVisible()
36+
await expect(editor.saveIndicator).toHaveAttribute('title', /Unsaved changes/)
37+
})
38+
39+
test('conflict when recovering from indexed db', async ({
40+
editor,
41+
file,
42+
setOffline,
43+
setOnline,
44+
}) => {
45+
await expect(editor.locator).toBeVisible()
46+
await setOffline()
47+
await editor.typeHeading('Hello world')
48+
await file.close()
49+
await setOnline()
50+
await file.upload('Good bye')
51+
await file.open()
52+
await expect(editor.getHeading('Hello world')).toBeVisible()
53+
await expect(editor.offlineState).not.toBeVisible()
54+
await expect(editor.saveIndicator).toHaveAttribute('title', /Unsaved changes/)
55+
})
56+

0 commit comments

Comments
 (0)