|
1 | | -import { createResearchOutputResponse } from '@asap-hub/fixtures'; |
2 | 1 | import { render, screen, within } from '@testing-library/react'; |
3 | 2 | import userEvent from '@testing-library/user-event'; |
4 | 3 | import { startOfTomorrow } from 'date-fns'; |
@@ -46,52 +45,26 @@ it('conditionally shows date published field', async () => { |
46 | 45 | expect(screen.queryByLabelText(/date made public/i)).toBeVisible(); |
47 | 46 | }); |
48 | 47 |
|
49 | | -it('enables the date made public field when creating an output', () => { |
50 | | - render(<ResearchOutputPublishingCard {...props} sharingStatus={'Public'} />); |
51 | | - expect(screen.getByLabelText(/date made public/i)).toBeEnabled(); |
52 | | -}); |
53 | | - |
54 | | -it('disables the date made public field when editing an output that already has a date', () => { |
55 | | - render( |
56 | | - <ResearchOutputPublishingCard |
57 | | - {...props} |
58 | | - sharingStatus={'Public'} |
59 | | - researchOutputData={{ |
60 | | - ...createResearchOutputResponse(), |
61 | | - publishDate: '2022-03-24', |
62 | | - }} |
63 | | - />, |
64 | | - ); |
65 | | - expect(screen.getByLabelText(/date made public/i)).toBeDisabled(); |
66 | | -}); |
67 | | - |
68 | | -it('enables the date made public field when editing an output without a date', () => { |
| 48 | +it('enables the date made public field when disableDateMadePublic is false', () => { |
69 | 49 | render( |
70 | 50 | <ResearchOutputPublishingCard |
71 | 51 | {...props} |
72 | 52 | sharingStatus={'Public'} |
73 | | - researchOutputData={{ |
74 | | - ...createResearchOutputResponse(), |
75 | | - publishDate: undefined, |
76 | | - }} |
| 53 | + disableDateMadePublic={false} |
77 | 54 | />, |
78 | 55 | ); |
79 | 56 | expect(screen.getByLabelText(/date made public/i)).toBeEnabled(); |
80 | 57 | }); |
81 | 58 |
|
82 | | -it('enables the date made public field when duplicating an output that has a date', () => { |
| 59 | +it('disables the date made public field when disableDateMadePublic is true', () => { |
83 | 60 | render( |
84 | 61 | <ResearchOutputPublishingCard |
85 | 62 | {...props} |
86 | 63 | sharingStatus={'Public'} |
87 | | - researchOutputData={{ |
88 | | - ...createResearchOutputResponse(), |
89 | | - id: '', |
90 | | - publishDate: '2022-03-24', |
91 | | - }} |
| 64 | + disableDateMadePublic={true} |
92 | 65 | />, |
93 | 66 | ); |
94 | | - expect(screen.getByLabelText(/date made public/i)).toBeEnabled(); |
| 67 | + expect(screen.getByLabelText(/date made public/i)).toBeDisabled(); |
95 | 68 | }); |
96 | 69 |
|
97 | 70 | it('triggers an on change for date published', async () => { |
@@ -167,33 +140,6 @@ describe('getPublishDateValidationMessage returns', () => { |
167 | 140 | }); |
168 | 141 | }); |
169 | 142 |
|
170 | | -it('disables the date field when imported from a manuscript with a date', () => { |
171 | | - render( |
172 | | - <ResearchOutputPublishingCard |
173 | | - {...props} |
174 | | - sharingStatus={'Public'} |
175 | | - isImportedFromManuscript |
176 | | - researchOutputData={createResearchOutputResponse()} |
177 | | - />, |
178 | | - ); |
179 | | - expect(screen.getByLabelText(/date made public/i)).toBeDisabled(); |
180 | | -}); |
181 | | - |
182 | | -it('enables the date field when imported from a manuscript without a date', () => { |
183 | | - render( |
184 | | - <ResearchOutputPublishingCard |
185 | | - {...props} |
186 | | - sharingStatus={'Public'} |
187 | | - isImportedFromManuscript |
188 | | - researchOutputData={{ |
189 | | - ...createResearchOutputResponse(), |
190 | | - publishDate: undefined, |
191 | | - }} |
192 | | - />, |
193 | | - ); |
194 | | - expect(screen.getByLabelText(/date made public/i)).toBeEnabled(); |
195 | | -}); |
196 | | - |
197 | 143 | it('prompts for the date when editing a public output that has no date', async () => { |
198 | 144 | // Suppress act() warnings from TextField's internal async validation state updates |
199 | 145 | const consoleMock = mockActErrorsInConsole(); |
|
0 commit comments