|
| 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 uploadFileTest } from '../support/fixtures/upload-file' |
| 10 | + |
| 11 | +const test = mergeTests(editorTest, offlineTest, uploadFileTest) |
| 12 | + |
| 13 | +// As we switch on and off the network |
| 14 | +// we cannot run tests in parallel. |
| 15 | +test.describe.configure({ mode: 'serial' }) |
| 16 | + |
| 17 | +test.beforeEach(async ({ open }) => { |
| 18 | + await open() |
| 19 | +}) |
| 20 | + |
| 21 | +test('saves after 30 seconds', async ({ editor, page }) => { |
| 22 | + await page.clock.install() |
| 23 | + await expect(editor.el).toBeVisible() |
| 24 | + await editor.typeHeading('Hello world') |
| 25 | + await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) |
| 26 | + await page.clock.fastForward(30_000) |
| 27 | + await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) |
| 28 | + // TODO: Why does this not work? await expect(await file.getContent()).toBe('## Hello world') |
| 29 | +}) |
| 30 | + |
| 31 | +test('saves after being disconnected for 20 sec.', async ({ |
| 32 | + editor, |
| 33 | + page, |
| 34 | + setOffline, |
| 35 | + setOnline, |
| 36 | +}) => { |
| 37 | + await page.clock.install() |
| 38 | + await expect(editor.el).toBeVisible() |
| 39 | + await editor.typeHeading('Hello world') |
| 40 | + await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) |
| 41 | + setOffline() |
| 42 | + await page.clock.fastForward(20_000) |
| 43 | + setOnline() |
| 44 | + await page.clock.fastForward(20_000) |
| 45 | + await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) |
| 46 | + // TODO: Why does this not work? await expect(await file.getContent()).toBe('## Hello world') |
| 47 | +}) |
| 48 | + |
| 49 | +test('saves after being disconnected for 2 minutes', async ({ |
| 50 | + editor, |
| 51 | + page, |
| 52 | + setOffline, |
| 53 | + setOnline, |
| 54 | +}) => { |
| 55 | + await page.clock.install() |
| 56 | + await expect(editor.el).toBeVisible() |
| 57 | + await editor.typeHeading('Hello world') |
| 58 | + await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) |
| 59 | + setOffline() |
| 60 | + await page.clock.fastForward(120_000) |
| 61 | + setOnline() |
| 62 | + await page.clock.fastForward(40_000) |
| 63 | + await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) |
| 64 | + // TODO: Why does this not work? await expect(await file.getContent()).toBe('## Hello world') |
| 65 | +}) |
0 commit comments