Skip to content

Commit 87c3919

Browse files
committed
fix: permission has to change in tests
1 parent 0a0a9f3 commit 87c3919

4 files changed

Lines changed: 27 additions & 25 deletions

File tree

tests/component/dataset/domain/models/DatasetMother.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ export class DatasetPermissionsMother {
158158
return this.create({ canDownloadFiles: true })
159159
}
160160

161+
static createWithFilesDownloadAllowedButNotUpdatePermissions(): DatasetPermissions {
162+
return this.create({
163+
canDownloadFiles: true,
164+
canUpdateDataset: false
165+
})
166+
}
161167
static createWithFilesDownloadNotAllowed(): DatasetPermissions {
162168
return this.create({ canDownloadFiles: false })
163169
}

tests/component/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.spec.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,8 @@ describe('AccessDatasetMenu', () => {
289289

290290
it('opens DownloadWithGuestbookModal when guestbook exists and download option is clicked', () => {
291291
const version = DatasetVersionMother.createReleased()
292-
const permissions = DatasetPermissionsMother.create({
293-
canDownloadFiles: true,
294-
canUpdateDataset: false
295-
})
292+
const permissions =
293+
DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions()
296294
const fileDownloadSizes = [
297295
DatasetFileDownloadSizeMother.createOriginal({ value: 2000, unit: FileSizeUnit.BYTES })
298296
]
@@ -347,10 +345,8 @@ describe('AccessDatasetMenu', () => {
347345

348346
it('does not fetch the guestbook until the modal is opened', () => {
349347
const version = DatasetVersionMother.createReleased()
350-
const permissions = DatasetPermissionsMother.create({
351-
canDownloadFiles: true,
352-
canUpdateDataset: false
353-
})
348+
const permissions =
349+
DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions()
354350
const fileDownloadSizes = [
355351
DatasetFileDownloadSizeMother.createOriginal({ value: 2000, unit: FileSizeUnit.BYTES })
356352
]
@@ -394,10 +390,8 @@ describe('AccessDatasetMenu', () => {
394390

395391
it('renders download option as a button and opens guestbook modal when guestbook exists', () => {
396392
const version = DatasetVersionMother.createReleased()
397-
const permissions = DatasetPermissionsMother.create({
398-
canDownloadFiles: true,
399-
canUpdateDataset: false
400-
})
393+
const permissions =
394+
DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions()
401395

402396
const fileDownloadSizes = [
403397
DatasetFileDownloadSizeMother.createOriginal({ value: 2000, unit: FileSizeUnit.BYTES })
@@ -441,7 +435,8 @@ describe('AccessDatasetMenu', () => {
441435

442436
it('closes DownloadWithGuestbookModal when cancel is clicked', () => {
443437
const version = DatasetVersionMother.createReleased()
444-
const permissions = DatasetPermissionsMother.createWithFilesDownloadAllowed()
438+
const permissions =
439+
DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions()
445440
const fileDownloadSizes = [
446441
DatasetFileDownloadSizeMother.createOriginal({ value: 2000, unit: FileSizeUnit.BYTES })
447442
]
@@ -484,7 +479,8 @@ describe('AccessDatasetMenu', () => {
484479

485480
it('opens guestbook modal from archival option when guestbook exists', () => {
486481
const version = DatasetVersionMother.createReleased()
487-
const permissions = DatasetPermissionsMother.createWithFilesDownloadAllowed()
482+
const permissions =
483+
DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions()
488484
const fileDownloadSizes = [
489485
DatasetFileDownloadSizeMother.createOriginal({ value: 2000, unit: FileSizeUnit.BYTES }),
490486
DatasetFileDownloadSizeMother.createArchival({ value: 4000, unit: FileSizeUnit.BYTES })

tests/component/sections/dataset/dataset-files/files-table/file-actions/download-files/DownloadFilesButton.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ describe('DownloadFilesButton', () => {
397397

398398
it('opens guestbook modal when guestbook exists and files are selected for non-tabular download', () => {
399399
const datasetWithGuestbook = DatasetMother.create({
400-
permissions: DatasetPermissionsMother.createWithFilesDownloadAllowed(),
400+
permissions: DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions(),
401401
hasOneTabularFileAtLeast: false,
402402
guestbookId: 10
403403
})
@@ -423,7 +423,7 @@ describe('DownloadFilesButton', () => {
423423

424424
it('opens guestbook modal when guestbook exists and tabular option is clicked', () => {
425425
const datasetWithGuestbook = DatasetMother.create({
426-
permissions: DatasetPermissionsMother.createWithFilesDownloadAllowed(),
426+
permissions: DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions(),
427427
hasOneTabularFileAtLeast: true,
428428
guestbookId: 10
429429
})
@@ -449,7 +449,7 @@ describe('DownloadFilesButton', () => {
449449

450450
it('does not fetch the guestbook until the modal is opened', () => {
451451
const datasetWithGuestbook = DatasetMother.create({
452-
permissions: DatasetPermissionsMother.createWithFilesDownloadAllowed(),
452+
permissions: DatasetPermissionsMother.createWithFilesDownloadAllowedButNotUpdatePermissions(),
453453
hasOneTabularFileAtLeast: true,
454454
guestbookId: 10
455455
})

tests/e2e-integration/e2e/sections/collection/CollectionItemsPanel.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('Collection Items Panel', () => {
7474
})
7575

7676
it('performs different search, filtering and respond to back and forward navigation', () => {
77-
cy.visit(`/spa/collections/${collectionId}`)
77+
cy.visit(`/spa/collections`)
7878

7979
cy.wait('@getCollectionItems').then((interception) => {
8080
const { totalItemsInResponse, collectionsInResponse, datasetsInResponse, filesInResponse } =
@@ -124,7 +124,7 @@ describe('Collection Items Panel', () => {
124124
].join(',')
125125
}).toString()
126126

127-
cy.url().should('include', `/collections/${collectionId}?${firstExpectedURL}`)
127+
cy.url().should('include', `/collections?${firstExpectedURL}`)
128128
})
129129

130130
// 2 - Now perform a search in the input
@@ -157,7 +157,7 @@ describe('Collection Items Panel', () => {
157157
[CollectionItemsQueryParams.QUERY]: 'Darwin'
158158
}).toString()
159159

160-
cy.url().should('include', `/collections/${collectionId}?${secondExpectedURL}`)
160+
cy.url().should('include', `/collections?${secondExpectedURL}`)
161161
})
162162

163163
// 3 - Clear the search and assert that the search is performed correctly and the url is updated correctly
@@ -190,7 +190,7 @@ describe('Collection Items Panel', () => {
190190
].join(',')
191191
}).toString()
192192

193-
cy.url().should('include', `/collections/${collectionId}?${thirdExpectedURL}`)
193+
cy.url().should('include', `/collections?${thirdExpectedURL}`)
194194
})
195195

196196
// 4 - Uncheck the Collections checkbox
@@ -222,7 +222,7 @@ describe('Collection Items Panel', () => {
222222
].join(',')
223223
}).toString()
224224

225-
cy.url().should('include', `/collections/${collectionId}?${fourthExpectedURL}`)
225+
cy.url().should('include', `/collections?${fourthExpectedURL}`)
226226
})
227227

228228
// 5 - Uncheck the Dataset checkbox
@@ -250,7 +250,7 @@ describe('Collection Items Panel', () => {
250250
[CollectionItemsQueryParams.TYPES]: [CollectionItemType.FILE].join(',')
251251
}).toString()
252252

253-
cy.url().should('include', `/collections/${collectionId}?${fifthExpectedURL}`)
253+
cy.url().should('include', `/collections?${fifthExpectedURL}`)
254254
})
255255

256256
// 6 - Navigate back with the browser and assert that the url is updated correctly and the items are displayed correctly as in step 4
@@ -281,7 +281,7 @@ describe('Collection Items Panel', () => {
281281
].join(',')
282282
}).toString()
283283

284-
cy.url().should('include', `/collections/${collectionId}?${fourthExpectedURL}`)
284+
cy.url().should('include', `/collections?${fourthExpectedURL}`)
285285
})
286286

287287
// 7 - Selects a facet filter
@@ -315,7 +315,7 @@ describe('Collection Items Panel', () => {
315315
].join(',')
316316
}).toString()
317317

318-
cy.url().should('include', `/collections/${collectionId}?${expectedURL}`)
318+
cy.url().should('include', `/collections?${expectedURL}`)
319319

320320
// Assert that the selected facet filter is displayed
321321
cy.findAllByRole('button', { name: /Finch, Fiona/ })

0 commit comments

Comments
 (0)