Skip to content

Commit 6b4a6af

Browse files
committed
fix: viewports change
1 parent 16f97cd commit 6b4a6af

File tree

5 files changed

+57
-77
lines changed

5 files changed

+57
-77
lines changed

public/locales/en/dataset.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@
347347
"tabs": {
348348
"datasetTerms": "Dataset Terms",
349349
"restrictedFilesTerms": "Restricted Files + Terms of Access",
350-
"guestBook": "Guest Book"
350+
"guestBook": "GuestBook"
351351
},
352352
"datasetTerms": {
353353
"title": "Dataset Terms",
@@ -364,7 +364,7 @@
364364
"description": "Set up access restrictions and terms for restricted files in this dataset."
365365
},
366366
"guestBook": {
367-
"title": "Guest Book",
367+
"title": "GuestBook",
368368
"description": "Select a guestbook to have a user provide additional information when downloading a file.",
369369
"testGuestbook": "Test Guestbook",
370370
"previewButton": "Preview Guestbook"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DatasetLicense } from '../../../../../src/dataset/domain/models/Dataset'
2+
23
export class LicenseMother {
34
static create(props?: Partial<DatasetLicense>): DatasetLicense {
45
const defaultLicense: DatasetLicense = {

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

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,10 @@ export class TermsOfAccessMother {
2929
availabilityStatus: undefined,
3030
contactForAccess: undefined,
3131
sizeOfCollection: undefined,
32-
studyCompletion: undefined
32+
studyCompletion: undefined,
33+
termsOfAccessForRestrictedFiles: undefined
3334
}
3435
}
35-
36-
static createRealistic(props?: Partial<TermsOfAccess>): TermsOfAccess {
37-
const defaultTerms: TermsOfAccess = {
38-
termsOfAccessForRestrictedFiles: 'Restricted files require special access permissions.',
39-
fileAccessRequest: true,
40-
dataAccessPlace: 'Data can be accessed at the main office.',
41-
originalArchive: 'Original archive is available upon request.',
42-
availabilityStatus: 'Available for research purposes.',
43-
contactForAccess: '[email protected]',
44-
sizeOfCollection: '50 GB',
45-
studyCompletion: '2023-10-01'
46-
}
47-
return { ...defaultTerms, ...props }
48-
}
4936
}
5037

5138
export class CustomTermsMother {
@@ -63,21 +50,6 @@ export class CustomTermsMother {
6350

6451
return { ...defaultTerms, ...props }
6552
}
66-
67-
static createRealistic(props?: Partial<CustomTerms>): CustomTerms {
68-
const defaultTerms: CustomTerms = {
69-
termsOfUse: 'Be nice to each other.',
70-
confidentialityDeclaration: 'Keep the data confidential.',
71-
specialPermissions: 'Special permissions may be granted upon request.',
72-
restrictions: 'No commercial use allowed.',
73-
citationRequirements: 'Please cite the dataset as per the guidelines.',
74-
depositorRequirements: 'Depositors must comply with the data management plan.',
75-
conditions: 'Conditions apply as per the dataset agreement.',
76-
disclaimer: 'The dataset is provided "as is" without warranties of any kind.'
77-
}
78-
79-
return { ...defaultTerms, ...props }
80-
}
8153
}
8254

8355
export class TermsOfUseMother {
@@ -99,8 +71,8 @@ export class TermsOfUseMother {
9971

10072
static createRealistic(props?: Partial<DatasetTermsOfUse>): DatasetTermsOfUse {
10173
const defaultTerms: DatasetTermsOfUse = {
102-
termsOfAccess: TermsOfAccessMother.createRealistic(),
103-
customTerms: CustomTermsMother.createRealistic()
74+
termsOfAccess: TermsOfAccessMother.create(),
75+
customTerms: CustomTermsMother.create()
10476
}
10577
return { ...defaultTerms, ...props }
10678
}

tests/component/sections/edit-dataset-terms/EditDatasetTerms.spec.tsx

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { EditDatasetTermsHelper } from '@/sections/edit-dataset-terms/EditDatase
77
import { DatasetMother } from '@tests/component/dataset/domain/models/DatasetMother'
88
import {
99
TermsOfUseMother,
10-
TermsOfAccessMother,
11-
CustomTermsMother
10+
TermsOfAccessMother
1211
} from '@tests/component/dataset/domain/models/TermsOfUseMother'
1312
import { Dataset } from '@/dataset/domain/models/Dataset'
1413
import { License } from '@/licenses/domain/models/License'
@@ -47,7 +46,7 @@ const mockLicenses: License[] = [
4746
}
4847
]
4948

50-
describe('EditDatasetTerms Integration', () => {
49+
describe('EditDatasetTerms', () => {
5150
const withProviders = (component: ReactNode, dataset: Dataset) => {
5251
datasetRepository.getByPersistentId = cy.stub().resolves(dataset)
5352
datasetRepository.getByPrivateUrlToken = cy.stub().resolves(dataset)
@@ -61,14 +60,15 @@ describe('EditDatasetTerms Integration', () => {
6160
}
6261

6362
beforeEach(() => {
63+
cy.viewport(1920, 1080)
6464
licenseRepository.getAvailableStandardLicenses = cy.stub().resolves(mockLicenses)
6565
})
6666

6767
describe('Tab Navigation', () => {
6868
it('renders all three tabs', () => {
6969
const dataset = DatasetMother.create({
7070
license: mockLicenses[0],
71-
termsOfUse: TermsOfUseMother.create()
71+
termsOfUse: TermsOfUseMother.withoutCustomTerms()
7272
})
7373

7474
cy.customMount(
@@ -84,13 +84,13 @@ describe('EditDatasetTerms Integration', () => {
8484

8585
cy.findByRole('tab', { name: 'Dataset Terms' }).should('exist')
8686
cy.findByRole('tab', { name: 'Restricted Files + Terms of Access' }).should('exist')
87-
cy.findByRole('tab', { name: 'Guest Book' }).should('exist')
87+
cy.findByRole('tab', { name: 'GuestBook' }).should('exist')
8888
})
8989

9090
it('switches between tabs correctly', () => {
9191
const dataset = DatasetMother.create({
9292
license: mockLicenses[0],
93-
termsOfUse: TermsOfUseMother.create()
93+
termsOfUse: TermsOfUseMother.withoutCustomTerms()
9494
})
9595

9696
cy.customMount(
@@ -115,14 +115,13 @@ describe('EditDatasetTerms Integration', () => {
115115

116116
cy.findByLabelText('Enable access request').should('exist')
117117

118-
cy.findByRole('tab', { name: 'Guest Book' }).click()
119-
cy.findByRole('tab', { name: 'Guest Book' }).should('have.attr', 'aria-selected', 'true')
118+
cy.findByRole('tab', { name: 'GuestBook' }).should('not.be.selected')
120119
})
121120

122121
it('starts with the correct default tab', () => {
123122
const dataset = DatasetMother.create({
124123
license: mockLicenses[0],
125-
termsOfUse: TermsOfUseMother.create()
124+
termsOfUse: TermsOfUseMother.withoutCustomTerms()
126125
})
127126

128127
cy.customMount(
@@ -167,7 +166,7 @@ describe('EditDatasetTerms Integration', () => {
167166
})
168167
})
169168

170-
describe.only('Dataset Terms Tab Integration', () => {
169+
describe('Dataset Terms Tab Integration', () => {
171170
it('displays dataset terms tab with license data', () => {
172171
const dataset = DatasetMother.create({
173172
license: mockLicenses[0]
@@ -189,9 +188,9 @@ describe('EditDatasetTerms Integration', () => {
189188
})
190189

191190
it('displays custom terms when dataset has custom terms', () => {
192-
const customTerms = CustomTermsMother.create({ termsOfUse: 'Custom terms text' })
193191
const dataset = DatasetMother.create({
194-
termsOfUse: TermsOfUseMother.create({ customTerms })
192+
license: undefined,
193+
termsOfUse: TermsOfUseMother.create()
195194
})
196195

197196
cy.customMount(
@@ -219,7 +218,7 @@ describe('EditDatasetTerms Integration', () => {
219218
})
220219
const dataset = DatasetMother.create({
221220
license: mockLicenses[0],
222-
termsOfUse: TermsOfUseMother.create({ termsOfAccess })
221+
termsOfUse: TermsOfUseMother.withoutCustomTerms({ termsOfAccess })
223222
})
224223

225224
cy.customMount(
@@ -239,39 +238,13 @@ describe('EditDatasetTerms Integration', () => {
239238
cy.findByDisplayValue('Access requires approval').should('exist')
240239
cy.findByText(/Restricting limits access to published files/).should('exist')
241240
})
242-
243-
it('handles empty terms of access', () => {
244-
const termsOfAccess = TermsOfAccessMother.createEmpty()
245-
const dataset = DatasetMother.create({
246-
license: mockLicenses[0],
247-
termsOfUse: TermsOfUseMother.create({ termsOfAccess })
248-
})
249-
250-
cy.customMount(
251-
withProviders(
252-
<EditDatasetTerms
253-
defaultActiveTabKey={
254-
EditDatasetTermsHelper.EDIT_DATASET_TERMS_TABS_KEYS.restrictedFilesTerms
255-
}
256-
licenseRepository={licenseRepository}
257-
datasetRepository={datasetRepository}
258-
/>,
259-
dataset
260-
)
261-
)
262-
263-
cy.findByLabelText('Enable access request').should('exist')
264-
cy.findByLabelText('Terms of Access for Restricted Files').should('exist')
265-
266-
cy.findByText(/Restricting limits access to published files/).should('not.exist')
267-
})
268241
})
269242

270243
describe('Breadcrumbs', () => {
271244
it('displays correct breadcrumbs', () => {
272245
const dataset = DatasetMother.create({
273246
license: mockLicenses[0],
274-
termsOfUse: TermsOfUseMother.create()
247+
termsOfUse: TermsOfUseMother.withoutCustomTerms()
275248
})
276249

277250
cy.customMount(
@@ -289,3 +262,39 @@ describe('EditDatasetTerms Integration', () => {
289262
})
290263
})
291264
})
265+
266+
describe('EditDatasetTerms Mobile View', () => {
267+
const withProviders = (component: ReactNode, dataset: Dataset) => {
268+
datasetRepository.getByPersistentId = cy.stub().resolves(dataset)
269+
datasetRepository.getByPrivateUrlToken = cy.stub().resolves(dataset)
270+
return (
271+
<DatasetProvider
272+
searchParams={{ persistentId: 'some-persistent-id', version: 'some-version' }}
273+
repository={datasetRepository}>
274+
{component}
275+
</DatasetProvider>
276+
)
277+
}
278+
279+
it('displays accordion sections in mobile view', () => {
280+
cy.viewport(500, 1080)
281+
licenseRepository.getAvailableStandardLicenses = cy.stub().resolves(mockLicenses)
282+
const dataset = DatasetMother.create({
283+
license: mockLicenses[0],
284+
termsOfUse: TermsOfUseMother.withoutCustomTerms()
285+
})
286+
cy.customMount(
287+
withProviders(
288+
<EditDatasetTerms
289+
defaultActiveTabKey={EditDatasetTermsHelper.EDIT_DATASET_TERMS_TABS_KEYS.datasetTerms}
290+
licenseRepository={licenseRepository}
291+
datasetRepository={datasetRepository}
292+
/>,
293+
dataset
294+
)
295+
)
296+
297+
cy.findByText('Dataset Terms').should('exist')
298+
cy.findByText('Restricted Files + Terms of Access').should('exist')
299+
})
300+
})

tests/component/sections/edit-dataset-terms/RestrictedFilesTab.spec.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ describe('RestrictedFilesTab', () => {
281281
)
282282

283283
cy.findByLabelText('Enable access request').check()
284-
cy.findByLabelText('Terms of Access for Restricted Files').type(
285-
'Please contact for access'
286-
)
284+
cy.findByLabelText('Terms of Access for Restricted Files').type('Please contact for access')
287285

288286
cy.findByRole('button', { name: 'Save Changes' }).click()
289287

0 commit comments

Comments
 (0)