Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1311

Merged
merged 113 commits into from
Nov 2, 2020
Merged

Develop #1311

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
2b0cec2
don't display tag noscript in google referer
baudointran Sep 11, 2020
fce0007
add nosnippet for google reference
baudointran Sep 14, 2020
3a7d02c
Merge pull request #1303 from LAB-MI/fix/not-tag-noscipt-in-google-ref
baudointran Sep 16, 2020
bc54fd9
:bug: fix locale date to fr
baudointran Sep 14, 2020
f4a0cda
Merge pull request #1304 from LAB-MI/fix/locale-date
baudointran Sep 16, 2020
9b2f89d
:sparkles: userid send by api to add in header http request
baudointran Sep 15, 2020
e8bb0e4
:sparkles: userid send to api in header http request
baudointran Sep 15, 2020
a39c684
unit test for user-id in header
baudointran Sep 15, 2020
62f4895
:bug: test e2e disconnect in candidatFront
baudointran Sep 16, 2020
96788b9
Merge pull request #1306 from LAB-MI/feat/user-id-in-header-http
baudointran Sep 17, 2020
8c5f0d0
Merge pull request #1308 from LAB-MI/qualif/v2.9.6-rc1
pli01 Sep 17, 2020
5f51276
add nosnippet of google referencement for icon
baudointran Sep 21, 2020
60362db
Merge pull request #1313 from LAB-MI/fix/not-icon-in-google-ref
baudointran Sep 21, 2020
056fdb5
:arrow_up: upgrade dependencies api
baudointran Sep 17, 2020
0993eeb
:arrow_up: updrade dependencies front
baudointran Sep 17, 2020
6c9ab54
:arrow_up: Update express-fileupload
jclaudan Sep 21, 2020
7e3e6b4
Merge pull request #1310 from LAB-MI/fix/upgrade-dependencies-v2.9.6
jclaudan Sep 21, 2020
56dd316
data-nosnippet for pre-signup form
jclaudan Sep 24, 2020
f6a484c
Merge pull request #1321 from LAB-MI/fix/google-refs
jclaudan Sep 24, 2020
e02efc7
limit on user id
pli01 Sep 25, 2020
f6514bd
fix: test:e2e disconnect by candidat
baudointran Sep 28, 2020
328104b
Merge pull request #1323 from LAB-MI/tech/rate_limit_on_user_id
pli01 Sep 29, 2020
e35a4ae
Merge pull request #1315 from LAB-MI/qualif/v2.9.6-rc2
pli01 Sep 30, 2020
2d4df5f
remove sources in prod
baudointran Sep 24, 2020
b35867c
Merge pull request #1322 from LAB-MI/feat/not--sourcesmap-in-prod
baudointran Oct 2, 2020
f633bdb
add visible at in model place
baudointran Sep 21, 2020
cd7da06
get places booking canceled at 12h
baudointran Sep 21, 2020
dc05cda
unit test remove place by candidat with visibleAt
baudointran Sep 21, 2020
df05222
reuse createdAt to get places
baudointran Sep 30, 2020
1a687c4
can book places updated which is visible after 12h
baudointran Sep 22, 2020
dcfb0c4
visible place is defined by visibleAt
baudointran Sep 23, 2020
ea70837
add millisecond at 0 in date to display
baudointran Sep 22, 2020
ed307a6
unit test display places updated and book
baudointran Sep 22, 2020
a6a9639
unit test for visible places by visibleAt
baudointran Sep 23, 2020
69e4393
unit test for reuse createdAt to get places
baudointran Sep 30, 2020
c6f043b
fix test:e2e for the visible places at 12h
baudointran Sep 23, 2020
3aab283
:bug: snack-bar for error to create place for inspecteur
baudointran Sep 25, 2020
30f91df
:bug: close snackbar after to check
baudointran Sep 25, 2020
8428560
:ok_hand: remove console.log
baudointran Sep 28, 2020
ec0b63a
add init DB after restart API
baudointran Sep 29, 2020
2b4c444
run initDB on one process pm2
baudointran Sep 29, 2020
2d007a6
Merge pull request #1328 from LAB-MI/fix/display-canceled-places-opti…
baudointran Oct 5, 2020
17b1eb4
:bug: import places with one digit in hour
baudointran Oct 5, 2020
720aa99
unit test to import places with one digit on hours
baudointran Oct 5, 2020
1e5f258
Merge pull request #1330 from LAB-MI/fix/hour-with-one-digit-import-p…
baudointran Oct 5, 2020
834e0be
:bug: fix add authorize delegue to create center
jclaudan Oct 6, 2020
d92c2fe
Merge pull request #1332 from LAB-MI/fix/authorize-delegue-create-cen…
jclaudan Oct 6, 2020
92d2fd2
:sparkles: Add route api front
jclaudan Sep 29, 2020
70551cc
:sparkles: Add store action in front
jclaudan Sep 29, 2020
a7f98b9
:sparkles: Refactor update users component
jclaudan Sep 29, 2020
655e351
:sparkles: Add update admin controller business and queries
jclaudan Sep 29, 2020
0ac241d
fix error in front
jclaudan Sep 30, 2020
6ab8758
:white_check_mark: Add test e2e and test unit
jclaudan Sep 30, 2020
545e055
Fix some issue in front
jclaudan Oct 2, 2020
66c31db
Fix some issue in backend
jclaudan Oct 2, 2020
b2a5e5c
Merge pull request #1325 from LAB-MI/feat/unarchive-an-agent-by-admin…
jclaudan Oct 6, 2020
21c4180
Merge pull request #1329 from LAB-MI/qualif/v2.9.6-rc3
pli01 Oct 6, 2020
d27e21a
:heavy_plus_sign: Add Tailwind
jclaudan Sep 23, 2020
d6eb1c5
modify purge css
jclaudan Oct 9, 2020
dd8d412
Merge pull request #1326 from LAB-MI/tech/add-tailwind
jclaudan Oct 9, 2020
792f915
Add front components and route to call api
jclaudan Sep 24, 2020
484fefc
:sparkles: Add controller server
jclaudan Oct 8, 2020
7a7d841
:white_check_mark: add text e2e and unit
jclaudan Oct 8, 2020
23fca26
refactor createPlaceForInspector
jclaudan Oct 8, 2020
82f90ab
Fix test e2e adminPlanning and wording and rename some variable
jclaudan Oct 9, 2020
4795cd6
:loud_sound: Add countNumberCreatedPlaces in log
jclaudan Oct 10, 2020
8aefc28
:pencil2: wording
jclaudan Oct 12, 2020
938f485
Merge pull request #1337 from LAB-MI/feat/create-publisher-places-int…
jclaudan Oct 12, 2020
c3725bd
Fix nginx log format
pli01 Oct 9, 2020
527b7e0
Merge pull request #1339 from LAB-MI/tech/rate_limit_on_user_id
jclaudan Oct 13, 2020
29960c5
:memo: doc pour initDB
baudointran Oct 7, 2020
f8291a2
Merge pull request #1334 from LAB-MI/doc/initDB
jclaudan Oct 13, 2020
515c81c
:memo: rename candidats.controlles
baudointran Oct 7, 2020
c94e105
Merge pull request #1336 from LAB-MI/doc/rename-candidats-controllers
jclaudan Oct 13, 2020
b85dbdb
:memo: rename admin-controllers and remove log
baudointran Oct 7, 2020
d03fdee
Merge pull request #1335 from LAB-MI/doc/rename-admin-contollers
jclaudan Oct 13, 2020
448c437
:bug: add a missing param in leanPlace variable
jclaudan Oct 14, 2020
773c332
Merge pull request #1341 from LAB-MI/fix/add-missing-param-at-create-…
jclaudan Oct 14, 2020
2f6b798
:bug: Add departement in modal schedule inspector
jclaudan Oct 14, 2020
72b110b
Merge pull request #1342 from LAB-MI/fix/add-params-api-admin-client
jclaudan Oct 15, 2020
7b80364
Merge pull request #1338 from LAB-MI/qualif/v2.9.6-rc4
baudointran Oct 15, 2020
ac6ad1d
:bug: add await for syncIndexes
baudointran Oct 16, 2020
c0d0e39
Merge pull request #1347 from LAB-MI/fix/syncIndexes
baudointran Oct 16, 2020
f24f83c
add candidat_id in model archivedCandidat
baudointran Oct 16, 2020
72e9a5b
add methode to create archivedCandidat from candidat
baudointran Oct 16, 2020
c5957ac
archived candidat with id candidat
baudointran Oct 16, 2020
a558a16
Merge pull request #1346 from LAB-MI/fix/archive_id_candidat
baudointran Oct 19, 2020
3a81140
:pencil2: Update Mentions legal
jclaudan Oct 19, 2020
f0fe5e7
Merge pull request #1351 from LAB-MI/feat/typos-update-legal-mentions…
baudointran Oct 19, 2020
4987520
:sparkles: Update authorization for delegue when get departements
jclaudan Oct 19, 2020
f3b6d19
:sparkles: Add in front store for get all departements to update Ipcs…
jclaudan Oct 19, 2020
cb12595
:lock: Limit authorize status for inspecteur route
jclaudan Oct 19, 2020
70918e5
Merge pull request #1348 from LAB-MI/feat/authorize-delegue-to-update…
jclaudan Oct 19, 2020
13bb885
:bug: display default value when actions dont translate
baudointran Oct 16, 2020
892faad
:bug: add no candilib in reason dictionnary
baudointran Oct 16, 2020
c7ce33c
Merge pull request #1344 from LAB-MI/fix/history-actions-empty
baudointran Oct 20, 2020
ea55252
:memo: rename statistic-controllers
baudointran Oct 16, 2020
4f0cfee
:memo: mise a jours de jsdoc de statistique controllers
baudointran Oct 16, 2020
f008751
Merge pull request #1345 from LAB-MI/doc/rename-statistics-controllers
baudointran Oct 20, 2020
a9d4336
:pencil: Add some swagger and js docs
jclaudan Oct 13, 2020
12c5f6c
Merge pull request #1340 from LAB-MI/tech/complete-some-swagger-doc
jclaudan Oct 20, 2020
9535a5d
:lock: audit fix in a dev dependencie
jclaudan Oct 20, 2020
c155360
Merge pull request #1354 from LAB-MI/tech/audit-fix-browser-sync
jclaudan Oct 21, 2020
1fc8065
:pencil2: Update Faq section
jclaudan Oct 21, 2020
83418de
Merge pull request #1355 from LAB-MI/feat/update-faq-#1103
jclaudan Oct 22, 2020
1841c3c
:bulb: Add jsdoc in places business
jclaudan Oct 21, 2020
bbfd64e
Merge pull request #1357 from LAB-MI/doc/add-jsdoc-admin-places-buisi…
jclaudan Oct 23, 2020
0708ef1
:pencil: Modify tag for google ref
jclaudan Oct 22, 2020
ce00e42
Merge pull request #1356 from LAB-MI/fix/modify-tag-for-google-ref
jclaudan Oct 23, 2020
183be3a
:memo: rename candidat controllers
baudointran Oct 20, 2020
1f91d4b
fix test:e2e to go selection places
baudointran Oct 21, 2020
0a72577
Merge pull request #1352 from LAB-MI/doc/remane-candidat-controller
baudointran Oct 26, 2020
fd28693
Merge pull request #1350 from LAB-MI/qualif/v2.9.6-rc6
baudointran Oct 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unit test display places updated and book
  • Loading branch information
baudointran committed Oct 5, 2020
commit ed307a66226bc88319d622d770466443c2b9b305
9 changes: 8 additions & 1 deletion server/src/models/__tests__/places.date.display.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCentres, createInspecteurs } from '../../models/__tests__'
import { getFrenchLuxonFromObject } from '../../util'
import { getFrenchLuxonFromObject, getFrenchLuxon } from '../../util'
import { createPlace } from '../../models/place'

export let centreDateDisplay
Expand Down Expand Up @@ -41,6 +41,13 @@ export const createPlacesWithCreatedAtDiff = async () => {
},
]

let placesUpdated = await createPlace({ ...places[0], date: basePlaceDateTime.set({ hour: 9 }).plus({ days: 1 }).toISO() })
placesUpdated.visibleAt = getFrenchLuxon().set({ hour: 12, minute: 0, second: 0, millisecond: 0 }).toISO()
placesUpdated = await placesUpdated.save()

const createdPlaces = await Promise.all(places.map(createPlace))

createdPlaces.push(placesUpdated)

return createdPlaces
}
136 changes: 74 additions & 62 deletions server/src/routes/candidat/places-controllers.date.display.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe('Get places available and display at 12h', () => {
let places
let placesCreatedBefore
let idCandidat
let placesUpdated

beforeAll(async () => {
setInitCreatedCentre()
resetCreatedInspecteurs()
Expand All @@ -42,117 +44,108 @@ describe('Get places available and display at 12h', () => {
require('../middlewares/verify-token').__setIdCandidat(idCandidat)

places = await createPlacesWithCreatedAtDiff()
placesCreatedBefore = places.find(({ createdAt }) =>
getFrenchLuxonFromJSDate(createdAt).equals(createdAtBefore),
placesCreatedBefore = places.find(({ updatedAt }) =>
getFrenchLuxonFromJSDate(updatedAt).equals(createdAtBefore),
)
placesUpdated = places.find(({ createdAt, updatedAt }) => createdAt !== updatedAt)
})

afterAll(async () => {
await disconnect()
setNowAtNow()
})

it('Should get 1 place for 75 when now is before 12h', async () => {
setNowBefore12h()
async function expectedPlaces (nbplaces) {
const { body } = await request(app)
.get(
`${apiPrefix}/candidat/places?geoDepartement=${centreDateDisplay.geoDepartement}&nomCentre=${centreDateDisplay.nom}`,
)
.set('Accept', 'application/json')
.expect(200)

expect(body).toBeDefined()
expect(body).toHaveLength(1)
})
it('Should get 3 places for 75 when now is after 12h', async () => {
setNowAfter12h()

const { body } = await request(app)
.get(
`${apiPrefix}/candidat/places?geoDepartement=${centreDateDisplay.geoDepartement}&nomCentre=${centreDateDisplay.nom}`,
)
.set('Accept', 'application/json')
.expect(200)
expect(body).toHaveLength(nbplaces)
}

expect(body).toBeDefined()
expect(body).toHaveLength(3)
it('Should get 1 place for 75 when now is before 12h', async () => {
setNowBefore12h()
await expectedPlaces(1)
})

it('Should 200 with an available place before 12h when it is after 12h by centreId', async () => {
it('Should get 3 places for 75 when now is after 12h', async () => {
setNowAfter12h()
await expectedPlaces(4)
})

const date = placesCreatedBefore.date
const expectedPlaceByCentreId = async (date, nbPlaces) => {
const placeSelected = encodeURIComponent(date)
const { body } = await request(app)
.get(
`${apiPrefix}/candidat/places/${centreDateDisplay._id}?dateTime=${placeSelected}`,
)
.set('Accept', 'application/json')
.expect(200)

expect(body).toBeDefined()
expect(body).toHaveLength(1)
expect(body[0]).toBe(getFrenchLuxonFromJSDate(date).toISO())
})
it('Should 200 with an available place before 12h when it is after 12h by center name and geo-departement', async () => {
setNowAfter12h()
expect(body).toHaveLength(nbPlaces)
nbPlaces && expect(body[0]).toBe(getFrenchLuxonFromJSDate(date).toISO())
}

const date = placesCreatedBefore.date
const placeSelected = encodeURIComponent(date)
const { body } = await request(app)
.get(
`${apiPrefix}/candidat/places/?geoDepartement=${centreDateDisplay.geoDepartement}&nomCentre=${centreDateDisplay.nom}&dateTime=${placeSelected}`,
)
.set('Accept', 'application/json')
.expect(200)
it('Should 200 with an available place created before 12h when it is after 12h by centreId', async () => {
setNowAfter12h()
await expectedPlaceByCentreId(placesCreatedBefore.date, 1)
})

expect(body).toBeDefined()
expect(body).toHaveLength(1)
expect(body[0]).toBe(getFrenchLuxonFromJSDate(date).toISO())
it('Should 200 with an available place updated now when it is after 12h by centreId', async () => {
setNowAfter12h()
await expectedPlaceByCentreId(placesUpdated.date, 1)
})

it('Should 200 with no available place before 12h when it is before 12h by centreId', async () => {
it('Should 200 with no available place updated now when it is before 12h by centreId', async () => {
setNowBefore12h()
await expectedPlaceByCentreId(placesUpdated.date, 0)
})

const date = placesCreatedBefore.date
const expectedPlaceByNameCentreAndGeoDep = async (date, nbPlaces) => {
const placeSelected = encodeURIComponent(date)
const { body } = await request(app)
.get(
`${apiPrefix}/candidat/places/${centreDateDisplay._id}?dateTime=${placeSelected}`,
`${apiPrefix}/candidat/places/?geoDepartement=${centreDateDisplay.geoDepartement}&nomCentre=${centreDateDisplay.nom}&dateTime=${placeSelected}`,
)
.set('Accept', 'application/json')
.expect(200)

expect(body).toBeDefined()
expect(body).toHaveLength(0)
expect(body).toHaveLength(nbPlaces)
nbPlaces && expect(body[0]).toBe(getFrenchLuxonFromJSDate(date).toISO())
}

it('Should 200 with an available place before 12h when it is after 12h by center name and geo-departement', async () => {
setNowAfter12h()
await expectedPlaceByNameCentreAndGeoDep(placesCreatedBefore.date, 1)
})

it('Should 200 with an available place updated now when it is after 12h by center name and geo-departement', async () => {
setNowAfter12h()
await expectedPlaceByNameCentreAndGeoDep(placesUpdated.date, 1)
})

it('Should 200 with no available place before 12h when it is after 12h by center name and geo-departement', async () => {
setNowBefore12h()

const date = placesCreatedBefore.date
const placeSelected = encodeURIComponent(date)
const { body } = await request(app)
.get(
`${apiPrefix}/candidat/places/?geoDepartement=${centreDateDisplay.geoDepartement}&nomCentre=${centreDateDisplay.nom}&dateTime=${placeSelected}`,
)
.set('Accept', 'application/json')
.expect(200)

expect(body).toBeDefined()
expect(body).toHaveLength(0)
await expectedPlaceByNameCentreAndGeoDep(placesCreatedBefore.date, 0)
})

it('should booked place by candidat with info bookedAt when it is after 12h', async () => {
setNowAfter12h()
it('Should 200 with no available place updated now when it is after 12h by center name and geo-departement', async () => {
setNowBefore12h()
await expectedPlaceByNameCentreAndGeoDep(placesUpdated.date, 0)
})

const expectedBooked = async (placeSelected) => {
const { body } = await request(app)
.patch(`${apiPrefix}/candidat/places`)
.set('Accept', 'application/json')
.send({
nomCentre: centreDateDisplay.nom,
geoDepartement: centreDateDisplay.geoDepartement,
date: placesCreatedBefore.date,
date: placeSelected.date,
isAccompanied: true,
hasDualControlCar: true,
})
Expand All @@ -164,23 +157,27 @@ describe('Get places available and display at 12h', () => {
const placefounded = await findPlaceByCandidatId(idCandidat)
expect(placefounded).toBeDefined()
expect(placefounded).toHaveProperty('bookedAt')
expect(placefounded).toHaveProperty('date', placesCreatedBefore.date)
expect(placefounded).toHaveProperty('centre', placesCreatedBefore.centre)
expect(placefounded).toHaveProperty('date', placeSelected.date)
expect(placefounded).toHaveProperty('centre', placeSelected.centre)

placefounded.candidat = undefined
placefounded.booked = undefined
await placefounded.save()
})
}

it('should not booked place by candidat with info bookedAt when it is before 12h', async () => {
setNowBefore12h()
it('should booked place by candidat with info bookedAt when it is after 12h', async () => {
setNowAfter12h()
await expectedBooked(placesCreatedBefore)
})

const expectedBookedFailed = async (placeSelected) => {
const { body } = await request(app)
.patch(`${apiPrefix}/candidat/places`)
.set('Accept', 'application/json')
.send({
nomCentre: centreDateDisplay.nom,
geoDepartement: centreDateDisplay.geoDepartement,
date: placesCreatedBefore.date,
date: placeSelected.date,
isAccompanied: true,
hasDualControlCar: true,
})
Expand All @@ -195,5 +192,20 @@ describe('Get places available and display at 12h', () => {

const placefounded = await findPlaceByCandidatId(idCandidat)
expect(placefounded).toBeNull()
}

it('should not booked place by candidat with info bookedAt when it is before 12h', async () => {
setNowBefore12h()
await expectedBookedFailed(placesCreatedBefore)
})

it('should booked place updated now by candidat with info bookedAt when it is after 12h', async () => {
setNowAfter12h()
await expectedBooked(placesUpdated)
})

it('should not booked place updated now by candidat with info bookedAt when it is before 12h', async () => {
setNowBefore12h()
await expectedBookedFailed(placesUpdated)
})
})
1 change: 1 addition & 0 deletions server/src/routes/candidat/places-controllers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ describe('Test to book and to delete reservation by candidat', () => {
expect(place).toHaveProperty('date', date)
expect(place).toHaveProperty('centre', centre)

// To display places at 12h
const placeUpdated = await findPlaceById(placeSelected._id)
expect(placeUpdated).toHaveProperty('visibleAt')
const visibleAt = getFrenchLuxonFromJSDate(placeUpdated.visibleAt).set({ millisecond: 0 })
Expand Down