-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hotfix] Fixe la sélection de période sur la liste des unités (#918)
## Related Pull Requests & Issues None ---- - [x] Tests E2E (Cypress)
- Loading branch information
Showing
9 changed files
with
276 additions
and
37 deletions.
There are no files selected for viewing
145 changes: 145 additions & 0 deletions
145
frontend/cypress/e2e/side_window/mission_list/filters.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import { customDayjs } from '../../utils/customDayjs' | ||
import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats' | ||
|
||
context('Side Window > Mission List > Filter Bar', () => { | ||
beforeEach(() => { | ||
cy.viewport(1280, 1024) | ||
|
||
cy.visit(`/side_window`).wait(1000) | ||
}) | ||
|
||
it('Should filter missions for the current day', () => { | ||
const currentDay = encodeURIComponent(customDayjs().utc().startOf('day').toISOString()) | ||
cy.intercept('GET', `/bff/v1/missions?&startedAfterDateTime=${currentDay}*`).as('getMissions') | ||
|
||
cy.fill('Période', 'Aujourd’hui') | ||
cy.wait('@getMissions') | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
}) | ||
|
||
it('Should filter missions for the current month', () => { | ||
const currentDay = encodeURIComponent(customDayjs().utc().subtract(1, 'month').startOf('day').toISOString()) | ||
cy.intercept('GET', `/bff/v1/missions?&startedAfterDateTime=${currentDay}*`).as('getMissions') | ||
|
||
cy.fill('Période', 'Un mois') | ||
cy.wait('@getMissions') | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
}) | ||
|
||
it('Should filter missions for the custom date range', () => { | ||
const expectedStartDate = getUtcDateInMultipleFormats('2023-05-01T00:00:00.000Z') | ||
const expectedEndDate = getUtcDateInMultipleFormats('2023-05-31T23:59:59.000Z') | ||
cy.intercept( | ||
'GET', | ||
`/bff/v1/missions?&startedAfterDateTime=${expectedStartDate.utcDateAsEncodedString}&startedBeforeDateTime=${expectedEndDate.utcDateAsEncodedString}*` | ||
).as('getMissions') | ||
|
||
cy.fill('Période', 'Période spécifique') | ||
cy.fill('Période spécifique', [expectedStartDate.utcDateTuple, expectedEndDate.utcDateTuple]) | ||
cy.wait('@getMissions') | ||
}) | ||
|
||
it('Should filter missions by source', () => { | ||
cy.intercept('GET', `*missionSource=MONITORENV*`).as('getMissions') | ||
cy.fill('Origine', 'CACEM') | ||
cy.wait('@getMissions') | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
cy.get('.Table-SimpleTable tr').each((row, index) => { | ||
if (index === 0) { | ||
return | ||
} | ||
|
||
cy.wrap(row).should('contain', 'CACEM') | ||
}) | ||
}) | ||
|
||
it('Should filter missions by administrations', () => { | ||
cy.getDataCy('select-administration-filter').click().wait(100) | ||
cy.get('.rs-picker-search-bar-input').type('DDTM').wait(100) | ||
cy.get('[data-key="DDTM"]').click().wait(100).clickOutside() | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
cy.get('.Table-SimpleTable tr').each((row, index) => { | ||
if (index === 0) { | ||
return | ||
} | ||
|
||
cy.wrap(row).should('contain', 'DDTM') | ||
}) | ||
}) | ||
|
||
it('Should filter missions by units', () => { | ||
cy.getDataCy('select-units-filter').click().wait(100) | ||
cy.get('.rs-picker-search-bar-input').type('BSN').wait(100) | ||
cy.get('[data-key="10015"]').click().wait(100).clickOutside() | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
cy.get('.Table-SimpleTable tr').each((row, index) => { | ||
if (index === 0) { | ||
return | ||
} | ||
|
||
cy.wrap(row).should('contain', 'BSN Ste Maxime') | ||
}) | ||
}) | ||
|
||
it('Should filter missions by types', () => { | ||
cy.getDataCy('select-types-filter').click().wait(100) | ||
cy.get('[data-key="SEA"]').click().wait(100).clickOutside() | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
cy.get('.Table-SimpleTable tr').each((row, index) => { | ||
if (index === 0) { | ||
return | ||
} | ||
|
||
cy.wrap(row).should('contain', 'Mer') | ||
}) | ||
}) | ||
|
||
it('Should filter missions by sea fronts', () => { | ||
cy.getDataCy('select-seaFronts-filter').click().wait(100) | ||
cy.get('[data-key="MED"]').click().wait(100).clickOutside() | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
cy.get('.Table-SimpleTable tr').each((row, index) => { | ||
if (index === 0) { | ||
return | ||
} | ||
|
||
cy.wrap(row).should('contain', 'MED') | ||
}) | ||
}) | ||
|
||
it('Should filter missions by statuses', () => { | ||
cy.getDataCy('select-statuses-filter').click().wait(100) | ||
cy.get('[data-key="PENDING"]').click().wait(100).clickOutside() | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
cy.get('.Table-SimpleTable tr').each((row, index) => { | ||
if (index === 0) { | ||
return | ||
} | ||
|
||
cy.wrap(row).should('contain', 'En cours') | ||
}) | ||
}) | ||
|
||
it('Should filter missions by themes', () => { | ||
cy.getDataCy('select-theme-filter').click().wait(100) | ||
cy.get('.rs-picker-search-bar-input').type('Police').wait(100) | ||
cy.get('[data-key="Police des activités de cultures marines"]').click().wait(100).clickOutside() | ||
|
||
cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) | ||
cy.get('.Table-SimpleTable tr').each((row, index) => { | ||
if (index === 0) { | ||
return | ||
} | ||
|
||
cy.wrap(row).should('contain', 'Police des activités de cultures marines') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import dayjs from 'dayjs' | ||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter' | ||
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore' | ||
import localeData from 'dayjs/plugin/localeData' | ||
import quarterOfYear from 'dayjs/plugin/quarterOfYear' | ||
import timezone from 'dayjs/plugin/timezone' | ||
import updateLocale from 'dayjs/plugin/updateLocale' | ||
import utc from 'dayjs/plugin/utc' | ||
|
||
import 'dayjs/locale/fr' | ||
|
||
dayjs.extend(isSameOrAfter) | ||
dayjs.extend(isSameOrBefore) | ||
dayjs.extend(localeData) | ||
dayjs.extend(quarterOfYear) | ||
dayjs.extend(timezone) | ||
dayjs.extend(updateLocale) | ||
dayjs.extend(utc) | ||
|
||
dayjs.locale('fr') | ||
|
||
export { dayjs as customDayjs } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function expectPathToBe(expectedPath: string) { | ||
cy.location().should(location => { | ||
assert.equal(location.pathname, expectedPath) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { sortBy } from 'lodash/fp' | ||
|
||
import type { CollectionItem } from '@mtes-mct/monitor-ui' | ||
|
||
export function getLastIdFromCollection(collection: CollectionItem[]) { | ||
return (sortBy('id', collection)[collection.length - 1] as CollectionItem).id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { customDayjs } from './customDayjs' | ||
|
||
export function getUtcDateInMultipleFormats(date?: string) { | ||
const utcDateAsDayjs = customDayjs(date).utc() | ||
|
||
return { | ||
utcDateAsDayjs, | ||
utcDateAsEncodedString: encodeURIComponent(utcDateAsDayjs.toISOString()), | ||
/** | ||
* ISO string without seconds, milliseconds, and timezone offset. | ||
* | ||
* @example | ||
* `2023-06-08T13:54` | ||
*/ | ||
utcDateAsShortString: utcDateAsDayjs.toISOString().substring(0, 16), | ||
utcDateAsString: utcDateAsDayjs.toISOString(), | ||
utcDateTuple: [utcDateAsDayjs.year(), utcDateAsDayjs.month() + 1, utcDateAsDayjs.date()] as [ | ||
number, | ||
number, | ||
number | ||
], | ||
utcDateTupleWithTime: [ | ||
utcDateAsDayjs.year(), | ||
utcDateAsDayjs.month() + 1, | ||
utcDateAsDayjs.date(), | ||
utcDateAsDayjs.hour(), | ||
utcDateAsDayjs.minute() | ||
] as [number, number, number, number, number] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.