-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
chore : Comprehensive e2e testing for public sharing #50260
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
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c0db548
refactor: Modularize setup-public-share.ts
nfebe d0a018b
test(files_sharing): add e2e tests for public link sharing
nfebe 667fb8b
fix(files_sharing): Adjust wrong labeling identified by test
nfebe 6d37e16
chore(assets): Recompile assets
nextcloud-command 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
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,18 @@ | ||
| /*! | ||
| * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| export type ShareOptions = { | ||
| enforcePassword?: boolean | ||
| enforceExpirationDate?: boolean | ||
| alwaysAskForPassword?: boolean | ||
| defaultExpirationDateSet?: boolean | ||
| } | ||
|
|
||
| export const defaultShareOptions: ShareOptions = { | ||
| enforcePassword: false, | ||
| enforceExpirationDate: false, | ||
| alwaysAskForPassword: false, | ||
| defaultExpirationDateSet: false, | ||
| } | ||
192 changes: 192 additions & 0 deletions
192
cypress/e2e/files_sharing/public-share/required-before-create.cy.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,192 @@ | ||
| /*! | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import type { ShareContext } from './setup-public-share.ts' | ||
| import type { ShareOptions } from '../ShareOptionsType.ts' | ||
| import { defaultShareOptions } from '../ShareOptionsType.ts' | ||
| import { setupData, createShare } from './setup-public-share.ts' | ||
|
|
||
| describe('files_sharing: Before create checks', () => { | ||
|
|
||
| let shareContext: ShareContext | ||
|
|
||
| before(() => { | ||
| // Setup data for the shared folder once before all tests | ||
| cy.createRandomUser().then((randomUser) => { | ||
| shareContext = { | ||
| user: randomUser, | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| cy.runOccCommand('config:app:delete core shareapi_enable_link_password_by_default') | ||
| cy.runOccCommand('config:app:delete core shareapi_enforce_links_password') | ||
| cy.runOccCommand('config:app:delete core shareapi_default_expire_date') | ||
| cy.runOccCommand('config:app:delete core shareapi_enforce_expire_date') | ||
| cy.runOccCommand('config:app:delete core shareapi_expire_after_n_days') | ||
| }) | ||
|
|
||
| const applyShareOptions = (options: ShareOptions = defaultShareOptions): void => { | ||
| cy.runOccCommand(`config:app:set --value ${options.alwaysAskForPassword ? 'yes' : 'no'} core shareapi_enable_link_password_by_default`) | ||
| cy.runOccCommand(`config:app:set --value ${options.enforcePassword ? 'yes' : 'no'} core shareapi_enforce_links_password`) | ||
| cy.runOccCommand(`config:app:set --value ${options.enforceExpirationDate ? 'yes' : 'no'} core shareapi_enforce_expire_date`) | ||
| cy.runOccCommand(`config:app:set --value ${options.defaultExpirationDateSet ? 'yes' : 'no'} core shareapi_default_expire_date`) | ||
| if (options.defaultExpirationDateSet) { | ||
| cy.runOccCommand('config:app:set --value 2 core shareapi_expire_after_n_days') | ||
| } | ||
| } | ||
|
|
||
| it('Checks if user can create share when both password and expiration date are enforced', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| enforcePassword: true, | ||
| enforceExpirationDate: true, | ||
| defaultExpirationDateSet: true, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'passwordAndExpireEnforced' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share when password is enforced and expiration date has a default set', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| enforcePassword: true, | ||
| defaultExpirationDateSet: true, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'passwordEnforcedDefaultExpire' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share when password is optionally requested and expiration date is enforced', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| defaultExpirationDateSet: true, | ||
| enforceExpirationDate: true, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'defaultPasswordExpireEnforced' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share when password is optionally requested and expiration date have defaults set', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| defaultExpirationDateSet: true, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'defaultPasswordAndExpire' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share with password enforced and expiration date set but not enforced', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| enforcePassword: true, | ||
| defaultExpirationDateSet: true, | ||
| enforceExpirationDate: false, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'passwordEnforcedExpireSetNotEnforced' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create a share when both password and expiration date have default values but are both not enforced', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| enforcePassword: false, | ||
| defaultExpirationDateSet: true, | ||
| enforceExpirationDate: false, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'defaultPasswordAndExpirationNotEnforced' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share with password not enforced but expiration date enforced', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| enforcePassword: false, | ||
| defaultExpirationDateSet: true, | ||
| enforceExpirationDate: true, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'noPasswordExpireEnforced' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share with password not enforced and expiration date has a default set', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| enforcePassword: false, | ||
| defaultExpirationDateSet: true, | ||
| enforceExpirationDate: false, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
| const shareName = 'defaultExpireNoPasswordEnforced' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share with expiration date set and password not enforced', () => { | ||
| const shareOptions : ShareOptions = { | ||
| alwaysAskForPassword: true, | ||
| enforcePassword: false, | ||
| defaultExpirationDateSet: true, | ||
| } | ||
| applyShareOptions(shareOptions) | ||
|
|
||
| const shareName = 'noPasswordExpireDefault' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, shareOptions).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| it('Checks if user can create share with password not enforced, expiration date not enforced, and no defaults set', () => { | ||
| applyShareOptions() | ||
| const shareName = 'noPasswordNoExpireNoDefaults' | ||
| setupData(shareContext.user, shareName) | ||
| createShare(shareContext, shareName, null).then((shareUrl) => { | ||
| shareContext.url = shareUrl | ||
| cy.log(`Created share with URL: ${shareUrl}`) | ||
| }) | ||
| }) | ||
|
|
||
| }) |
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.