Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
susnux committed Jan 15, 2025
1 parent 653e4f8 commit edc5811
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions cypress/e2e/files_sharing/expiry-date.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { User } from '@nextcloud/cypress'
import { closeSidebar } from '../files/FilesUtils.ts'
import { createShare, openSharingDetails, openSharingPanel, updateShare } from './filesSharingUtils.ts'
import { randomUUID } from 'crypto'

describe('files_sharing: Expiry date', () => {
const expectedDefaultDate = new Date(Date.now() + 2 * 24 * 60 * 60 * 1000)
Expand Down Expand Up @@ -43,8 +44,7 @@ describe('files_sharing: Expiry date', () => {
it('See default expiry date is set and enforced', () => {
// Enforce the date
cy.runOccCommand('config:app:set --value yes core shareapi_enforce_internal_expire_date')
const dir = 'defaultExpiryDateEnforced'
prepareDirectory(dir)
const dir = prepareDirectory()

validateExpiryDate(dir, expectedDefaultDateString)
cy.findByRole('checkbox', { name: /expiration date/i })
Expand All @@ -53,8 +53,7 @@ describe('files_sharing: Expiry date', () => {
})

it('See default expiry date is set also if not enforced', () => {
const dir = 'defaultExpiryDate'
prepareDirectory(dir)
const dir = prepareDirectory()

validateExpiryDate(dir, expectedDefaultDateString)
cy.findByRole('checkbox', { name: /expiration date/i })
Expand All @@ -64,15 +63,13 @@ describe('files_sharing: Expiry date', () => {
})

it('Can set custom expiry date', () => {
const dir = 'customExpiryDate'
prepareDirectory(dir)
const dir = prepareDirectory()
updateShare(dir, 0, { expiryDate: fortnight })
validateExpiryDate(dir, fortnightString)
})

it('Custom expiry date survives reload', () => {
const dir = 'customExpiryDateReload'
prepareDirectory(dir)
const dir = prepareDirectory()
updateShare(dir, 0, { expiryDate: fortnight })
validateExpiryDate(dir, fortnightString)

Expand All @@ -85,8 +82,7 @@ describe('files_sharing: Expiry date', () => {
* Ensure that admin default settings do not always override the user set value.
*/
it('Custom expiry date survives unrelated update', () => {
const dir = 'customExpiryUnrelatedChanges'
prepareDirectory(dir)
const dir = prepareDirectory()
updateShare(dir, 0, { expiryDate: fortnight })
validateExpiryDate(dir, fortnightString)

Expand All @@ -100,14 +96,14 @@ describe('files_sharing: Expiry date', () => {

/**
* Prepare directory, login and share to bob
*
* @param name The directory name
*/
function prepareDirectory(name: string) {
function prepareDirectory(): string {
const name = randomUUID()
cy.mkdir(alice, `/${name}`)
cy.login(alice)
cy.visit('/apps/files')
createShare(name, bob.userId)
return name
}

/**
Expand Down

0 comments on commit edc5811

Please sign in to comment.