@@ -7,8 +7,7 @@ import { EditDatasetTermsHelper } from '@/sections/edit-dataset-terms/EditDatase
77import { DatasetMother } from '@tests/component/dataset/domain/models/DatasetMother'
88import {
99 TermsOfUseMother ,
10- TermsOfAccessMother ,
11- CustomTermsMother
10+ TermsOfAccessMother
1211} from '@tests/component/dataset/domain/models/TermsOfUseMother'
1312import { Dataset } from '@/dataset/domain/models/Dataset'
1413import { 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 ( / R e s t r i c t i n g l i m i t s a c c e s s t o p u b l i s h e d f i l e s / ) . 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 ( / R e s t r i c t i n g l i m i t s a c c e s s t o p u b l i s h e d f i l e s / ) . 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+ } )
0 commit comments