Repository navigation
fix(indexedDB): close the database when the editor closes #9630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+283
−32
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5936b4a
fix(sync): clear hasConnectionIssue when the server rejects the session
mejo- 3edf685
fix(indexedDB): close the database when the editor closes
mejo- 1a73296
fix(sync): do not push steps twice or drop the autosave after reconne…
mejo- 07872e4
fix(sync): stop the send interval and unload listener of a closed editor
mejo- 39aa315
refactor(indexedDB): rely on ydoc.isDestroyed instead of a destroy li…
mejo- a32b2db
fix(save): do not save if pushing the changes invalidated the session
mejo- 40d6400
fix(a11y): announce document status changes to screen readers
mejo- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
playwright/e2e/synchronize-content/session-rejected-offline.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import type { Route } from '@playwright/test' | ||
|
|
||
| import { expect, mergeTests } from '@playwright/test' | ||
| import { test as editorTest } from '../../support/fixtures/editor.ts' | ||
| import { test as uploadFileTest } from '../../support/fixtures/upload-file.ts' | ||
|
|
||
| const test = mergeTests(editorTest, uploadFileTest) | ||
|
|
||
| const PUSH = /\/apps\/text\/session\/\d+\/push$/ | ||
| const SESSION_REQUESTS = /\/apps\/text\/session\/\d+\/(sync|push)$/ | ||
|
|
||
| test.beforeEach(async ({ open }) => { | ||
| await open() | ||
| }) | ||
|
|
||
| test('stays read-only when the session is rejected after a connection issue', async ({ | ||
| editor, | ||
| page, | ||
| }) => { | ||
| test.slow() | ||
| await page.clock.install() | ||
| const status = page.locator('.document-status') | ||
| const content = editor.el.locator('.ProseMirror') | ||
| await expect(content).toHaveAttribute('contenteditable', 'true') | ||
|
|
||
| // One handler for the whole test, so no request slips through while switching. | ||
| let network: 'online' | 'offline' | 'rejected' = 'online' | ||
| let releaseSyncs = () => {} | ||
| const syncsReleased = new Promise<void>((resolve) => { | ||
| releaseSyncs = resolve | ||
| }) | ||
| await page.route(SESSION_REQUESTS, async (route: Route) => { | ||
| if (network === 'online') { | ||
| return route.continue() | ||
| } | ||
| if (network === 'offline') { | ||
| return route.abort('internetdisconnected') | ||
| } | ||
| if (PUSH.test(route.request().url())) { | ||
| // Answer like SessionMiddleware does for a session it no longer knows. | ||
| return route.fulfill({ status: 403, contentType: 'application/json', body: '[]' }) | ||
| } | ||
| // Hold the syncs so that only the rejected push changes the state. | ||
| await syncsReleased | ||
| return route.abort('internetdisconnected') | ||
| }) | ||
|
|
||
| network = 'offline' | ||
| const failedPush = page.waitForEvent('requestfailed', (request) => PUSH.test(request.url())) | ||
| await editor.type('Hello') | ||
| // The connection issue only starts counting once the push failed. | ||
| await failedPush | ||
| const delay = await page.evaluate(() => window.OCP.InitialState.loadState('text', 'offline_readonly_delay') as number) | ||
| await page.clock.fastForward(delay * 1000 + 1000) | ||
| await expect(status).toContainText('The document could not be loaded.') | ||
| await expect(content).toHaveAttribute('contenteditable', 'false') | ||
|
|
||
| network = 'rejected' | ||
| // The autosave retries the push, which is rejected. | ||
| await page.clock.fastForward(60_000) | ||
| await expect(status).toContainText("You've been disconnected from the server.") | ||
| // Clearing the connection issue takes effect after 200 ms. | ||
| await page.waitForTimeout(1000) | ||
| await expect(content).toHaveAttribute('contenteditable', 'false') | ||
|
|
||
| network = 'online' | ||
| releaseSyncs() | ||
| await status.getByRole('button', { name: 'Reconnect' }).click() | ||
| await expect(status).not.toContainText("You've been disconnected from the server.") | ||
| await expect(content).toHaveAttribute('contenteditable', 'true') | ||
| await expect(editor.content).toContainText('Hello') | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.