-
Notifications
You must be signed in to change notification settings - Fork 103
fix(Action): await navigation and handle router rejections #4586
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
Open
solracsf
wants to merge
5
commits into
master
Choose a base branch
from
hardenNavigation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+107
−4
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7e74fae
fix(Action): await navigation and handle router rejections
solracsf fa4f4cd
test(cypress): cover team folder navigation from the Team folders view
solracsf 020a37e
test(cypress): locate team folder rows by fileid
solracsf 766d191
test(cypress): assert dir query with literal slash
solracsf 4bfefe4
fix(Action): drop router-rejection catch, rely on server-side router
solracsf 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
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,104 @@ | ||
| /*! | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import type { User } from '@nextcloud/e2e-test-server/cypress' | ||
|
|
||
| import { | ||
| PERMISSION_READ, | ||
| PERMISSION_WRITE, | ||
| addUserToGroup, | ||
| createGroup, | ||
| createGroupFolder, | ||
| deleteGroupFolder, | ||
| fileOrFolderExists, | ||
| } from './groupfoldersUtils.ts' | ||
| import { randHash } from '../utils/index.js' | ||
|
|
||
| // Regression coverage for https://github.com/nextcloud/groupfolders/issues/4499: | ||
| // clicking a team folder from the Team folders view must navigate to the | ||
| // target route *with* the fileid segment (PR #4524) and render content — including | ||
| // on repeated navigation, which is where the stale-route / abort-race failures | ||
| // used to surface. | ||
| describe('Team folders view navigation', () => { | ||
| let user: User | ||
| let groupFolderId: string | ||
| let groupName: string | ||
| let groupFolderName: string | ||
|
|
||
| beforeEach(() => { | ||
| if (groupFolderId) { | ||
| deleteGroupFolder(groupFolderId) | ||
| } | ||
| groupName = `test_group_${randHash()}` | ||
| groupFolderName = `test_group_folder_${randHash()}` | ||
|
|
||
| cy.createRandomUser().then(_user => { | ||
| user = _user | ||
| createGroup(groupName).then(() => { | ||
| addUserToGroup(groupName, user.userId) | ||
| createGroupFolder(groupFolderName, groupName, [PERMISSION_READ, PERMISSION_WRITE]) | ||
| .then(_id => { | ||
| groupFolderId = _id | ||
| }) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| it('clicking a team folder navigates to /apps/files/files/<fileid> with dir query and renders content', () => { | ||
| cy.uploadContent(user, new Blob(['hello']), 'text/plain', `/${groupFolderName}/file1.txt`) | ||
|
|
||
| cy.login(user) | ||
| cy.visit('/apps/files/groupfolders') | ||
| cy.location('pathname').should('include', '/apps/files/groupfolders') | ||
|
|
||
| // The Team folders view is served by the groupfolders DAV endpoint and keys | ||
| // rows by group-folder id rather than mount-point name — locate by fileid. | ||
| cy.get('[data-cy-files-list-row-fileid]').should('have.length.at.least', 1) | ||
|
|
||
| cy.intercept({ method: 'PROPFIND', url: `**/dav/files/**/${groupFolderName}` }).as('propFindFolder') | ||
| cy.get('[data-cy-files-list-row-fileid]').first() | ||
| .find('[data-cy-files-list-row-name-link]') | ||
| .click({ force: true }) | ||
| cy.wait('@propFindFolder') | ||
|
|
||
| // PR 4524: route must include the fileid segment, not just /apps/files/files?dir=... | ||
| cy.location('pathname').should('match', /\/apps\/files\/files\/\d+$/) | ||
| cy.location('search').should('contain', `dir=/${groupFolderName}`) | ||
|
|
||
| // If exec returns before navigation settles or lets a router rejection bubble, | ||
| // the file list stays empty / shows "folder not found". | ||
| fileOrFolderExists('file1.txt') | ||
| }) | ||
|
|
||
| it('navigating back to the Team folders view and re-entering the same folder still works', () => { | ||
| cy.uploadContent(user, new Blob(['hello']), 'text/plain', `/${groupFolderName}/file1.txt`) | ||
|
|
||
| cy.login(user) | ||
| cy.visit('/apps/files/groupfolders') | ||
| cy.location('pathname').should('include', '/apps/files/groupfolders') | ||
| cy.get('[data-cy-files-list-row-fileid]').should('have.length.at.least', 1) | ||
|
|
||
| cy.intercept({ method: 'PROPFIND', url: `**/dav/files/**/${groupFolderName}` }).as('propFind1') | ||
| cy.get('[data-cy-files-list-row-fileid]').first() | ||
| .find('[data-cy-files-list-row-name-link]') | ||
| .click({ force: true }) | ||
| cy.wait('@propFind1') | ||
| fileOrFolderExists('file1.txt') | ||
|
|
||
| cy.visit('/apps/files/groupfolders') | ||
| cy.location('pathname').should('include', '/apps/files/groupfolders') | ||
| cy.get('[data-cy-files-list-row-fileid]').should('have.length.at.least', 1) | ||
|
|
||
| // Second click — the stale-router path from the bug report. | ||
| cy.intercept({ method: 'PROPFIND', url: `**/dav/files/**/${groupFolderName}` }).as('propFind2') | ||
| cy.get('[data-cy-files-list-row-fileid]').first() | ||
| .find('[data-cy-files-list-row-name-link]') | ||
| .click({ force: true }) | ||
| cy.wait('@propFind2') | ||
|
|
||
| cy.location('pathname').should('match', /\/apps\/files\/files\/\d+$/) | ||
| fileOrFolderExists('file1.txt') | ||
| }) | ||
| }) |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those should already be handled by file router in server (if not fixed there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NavigationDuplicatedis handled at the server router layer (so my original catch for it was redundant), butRedirectedis not handled anywhere, it bubbles as an uncaught promise rejection from everygoToRoutecall in every app. Neverthless, it should be handled there too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up: nextcloud/server#59842