Skip to content

Commit 2df59b3

Browse files
committed
fix: increase code coverage
1 parent ebb1971 commit 2df59b3

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

tests/component/sections/dataset/dataset-action-buttons/publish-dataset-menu/ChangeCurationStatusMenu.spec.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ChangeCurationStatusMenu } from '../../../../../../src/sections/dataset
33
import { SettingMother } from '../../../../settings/domain/models/SettingMother'
44
import { SettingsProvider } from '../../../../../../src/sections/settings/SettingsProvider'
55
import { SettingRepository } from '../../../../../../src/settings/domain/repositories/SettingRepository'
6-
6+
import { NotImplementedModalProvider } from '../../../../../../src/sections/not-implemented/NotImplementedModalProvider'
77
describe('ChangeCurationStatusMenu', () => {
88
it('renders the ChangeCurationStatusMenu if external statuses are allowed and the user has update dataset permissions', () => {
99
const settingRepository = {} as SettingRepository
@@ -32,4 +32,25 @@ describe('ChangeCurationStatusMenu', () => {
3232

3333
cy.findByRole('button', { name: 'Change Curation Status' }).should('not.exist')
3434
})
35+
it('renders the Not Implemented Modal when button is clicked', () => {
36+
const settingRepository = {} as SettingRepository
37+
settingRepository.getByName = cy
38+
.stub()
39+
.resolves(SettingMother.createExternalStatusesAllowed(['Author Contacted', 'Privacy Review']))
40+
41+
cy.customMount(
42+
<SettingsProvider repository={settingRepository}>
43+
<NotImplementedModalProvider>
44+
<ChangeCurationStatusMenu />
45+
</NotImplementedModalProvider>
46+
</SettingsProvider>
47+
)
48+
49+
cy.findByRole('button', { name: 'Change Curation Status' })
50+
.should('exist')
51+
.should('be.enabled')
52+
.click()
53+
54+
cy.findByRole('button', { name: 'Author Contacted' }).should('exist').click()
55+
})
3556
})

tests/component/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.spec.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,51 @@ describe('PublishDatasetMenu', () => {
246246

247247
cy.findByRole('button', { name: 'Return to Author' }).should('exist')
248248
})
249+
250+
it('shows the PublishDatasetModal when the Publish button is clicked', () => {
251+
const dataset = DatasetMother.create({
252+
version: DatasetVersionMother.createDraftAsLatestVersion(),
253+
permissions: DatasetPermissionsMother.createWithPublishingDatasetAllowed(),
254+
locks: [],
255+
hasValidTermsOfAccess: true,
256+
isValid: true
257+
})
258+
259+
cy.mountAuthenticated(
260+
<PublishDatasetMenu
261+
datasetRepository={datasetRepository}
262+
collectionRepository={collectionRepository}
263+
dataset={dataset}
264+
/>
265+
)
266+
267+
cy.findByRole('button', { name: 'Publish Dataset' }).click()
268+
cy.findByRole('button', { name: 'Publish' }).click()
269+
cy.findByRole('dialog').should('exist')
270+
})
271+
272+
it('hides the PublishDatasetModal when handleClose is called', () => {
273+
const dataset = DatasetMother.create({
274+
version: DatasetVersionMother.createDraftAsLatestVersion(),
275+
permissions: DatasetPermissionsMother.createWithPublishingDatasetAllowed(),
276+
locks: [],
277+
hasValidTermsOfAccess: true,
278+
isValid: true
279+
})
280+
281+
cy.mountAuthenticated(
282+
<PublishDatasetMenu
283+
datasetRepository={datasetRepository}
284+
collectionRepository={collectionRepository}
285+
dataset={dataset}
286+
/>
287+
)
288+
289+
cy.findByRole('button', { name: 'Publish Dataset' }).click()
290+
cy.findByRole('button', { name: 'Publish' }).click()
291+
cy.findByRole('dialog').should('exist')
292+
293+
cy.findByRole('button', { name: 'Close' }).click()
294+
cy.findByRole('dialog').should('not.exist')
295+
})
249296
})

0 commit comments

Comments
 (0)