Skip to content

Commit

Permalink
Préavis - Correction du téléchargement des autorisations de débarquem…
Browse files Browse the repository at this point in the history
…ent (#3518)

## Linked issues

- Préavis - Correction du téléchargement des autorisations de
débarquement

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron committed Aug 9, 2024
2 parents 62d9ae7 + 8b37bec commit 5b598dc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { editSideWindowPriorNotification } from '../manual_prior_notification_fo

context('Side Window > Logbook Prior Notification Form > Form', () => {
it('Should not update the form with a PUT request on first render', () => {
cy.intercept('PUT', '/bff/v1/prior_notifications/logbook/FAKE_OPERATION_109*', cy.spy().as('updateForm'))
cy.intercept('PUT', '/bff/v1/prior_notifications/logbook/FAKE_OPERATION_114*', cy.spy().as('updateForm'))

editSideWindowPriorNotification(`L'ANCRE`, 'FAKE_OPERATION_109')
editSideWindowPriorNotification(`LA MER À BOIRE`, 'FAKE_OPERATION_114')

cy.contains(`L'ANCRE SÈCHE (CFR106)`).should('be.visible')
cy.contains(`LA MER À BOIRE (CFR110)`).should('be.visible')

cy.get('@updateForm').should('not.have.been.called')

Expand All @@ -17,7 +17,7 @@ context('Side Window > Logbook Prior Notification Form > Form', () => {
cy.get('@updateForm').should('have.been.calledOnce')

// Reset
cy.request('PUT', `/bff/v1/prior_notifications/logbook/FAKE_OPERATION_109?operationDate=${dayjs().toISOString()}`, {
cy.request('PUT', `/bff/v1/prior_notifications/logbook/FAKE_OPERATION_114?operationDate=${dayjs().toISOString()}`, {
body: {
authorTrigram: null,
note: null
Expand Down
1 change: 0 additions & 1 deletion frontend/src/features/Logbook/LogbookMessage.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export namespace LogbookMessage {
ircs: string | undefined
isCorrectedByNewerMessage: boolean
isDeleted: boolean
isManuallyCreated: boolean
isSentByFailoverSoftware: boolean
message: MessageBase | undefined
messageType: MessageType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export function Content({ detail, isValidatingOnChange, onClose, onSubmit, onVer
{!!detail && (
<DownloadButton
isDisabled={isPriorNotificationFormDirty}
isManuallyCreated={detail.isManuallyCreated}
pnoLogbookMessage={detail.logbookMessage}
reportId={detail.reportId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ export function PriorNotificationCard({
Fermer
</Button>

<DownloadButton pnoLogbookMessage={detail.logbookMessage} reportId={detail.reportId} />
<DownloadButton
isManuallyCreated={detail.isManuallyCreated}
pnoLogbookMessage={detail.logbookMessage}
reportId={detail.reportId}
/>

{footerChildren}
</Footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('PriorNotificationCard/utils.getHtmlContent()', () => {
ircs: undefined,
isCorrectedByNewerMessage: false,
isDeleted: false,
isManuallyCreated: true,
isSentByFailoverSoftware: false,
message: {
authorTrigram: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ import type { LogbookMessage } from '@features/Logbook/LogbookMessage.types'

type DownloadButtonProps = Readonly<{
isDisabled?: boolean
isManuallyCreated: boolean
pnoLogbookMessage: LogbookMessage.PnoLogbookMessage
reportId: string
}>
export function DownloadButton({ isDisabled = false, pnoLogbookMessage, reportId }: DownloadButtonProps) {
export function DownloadButton({
isDisabled = false,
isManuallyCreated,
pnoLogbookMessage,
reportId
}: DownloadButtonProps) {
const isSuperUser = useIsSuperUser()
const getGearsApiQuery = useGetGearsQuery()
const { isError } = useGetPriorNotificationPDFQuery(reportId, RTK_ONE_MINUTE_POLLING_QUERY_OPTIONS)
Expand All @@ -28,7 +34,7 @@ export function DownloadButton({ isDisabled = false, pnoLogbookMessage, reportId
getAlpha2CodeFromAlpha2or3Code(pnoLogbookMessage.flagState),
pnoLogbookMessage.externalReferenceNumber
) &&
pnoLogbookMessage.isManuallyCreated
isManuallyCreated
const pdfUrl = `/api/v1/prior_notifications/pdf/${reportId}`

const gearsWithName = useMemo(() => {
Expand Down

0 comments on commit 5b598dc

Please sign in to comment.