Skip to content

Commit

Permalink
fix: use ADMIN_LOGIN_SESSION_COOKIE_NAME constant for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wanlingt committed Nov 14, 2023
1 parent 847ea1f commit 2d814f4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/app/routes/api/v3/auth/__tests__/auth.routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { errAsync, okAsync } from 'neverthrow'
import supertest, { Session } from 'supertest-session'
import validator from 'validator'

import { ADMIN_LOGIN_SESSION_COOKIE_NAME } from 'src/app/loaders/express/session'
import MailService from 'src/app/services/mail/mail.service'
import { HashingError } from 'src/app/utils/hash'
import * as OtpUtils from 'src/app/utils/otp'
Expand Down Expand Up @@ -511,7 +512,7 @@ describe('auth.routes', () => {
})
// Should have session cookie returned.
const sessionCookie = request.cookies.find(
(cookie) => cookie.name === 'formsg.connect.sid',
(cookie) => cookie.name === ADMIN_LOGIN_SESSION_COOKIE_NAME,
)
expect(sessionCookie).toBeDefined()
})
Expand All @@ -538,7 +539,7 @@ describe('auth.routes', () => {
})
// Should have session cookie returned.
const sessionCookie = request.cookies.find(
(cookie) => cookie.name === 'formsg.connect.sid',
(cookie) => cookie.name === ADMIN_LOGIN_SESSION_COOKIE_NAME,
)
expect(sessionCookie).toBeDefined()
})
Expand Down Expand Up @@ -591,9 +592,9 @@ describe('auth.routes', () => {
// Assert
expect(response.status).toEqual(200)
expect(response.body).toEqual({ message: 'Sign out successful' })
// formsg.connect.sid should now be empty.
// Login cookie should now be empty.
expect(response.header['set-cookie'][0]).toEqual(
expect.stringContaining('formsg.connect.sid=;'),
expect.stringContaining(`${ADMIN_LOGIN_SESSION_COOKIE_NAME}=;`),
)
})

Expand Down Expand Up @@ -629,7 +630,7 @@ describe('auth.routes', () => {
// Assert
// Should have session cookie returned.
const sessionCookie = request.cookies.find(
(cookie) => cookie.name === 'formsg.connect.sid',
(cookie) => cookie.name === ADMIN_LOGIN_SESSION_COOKIE_NAME,
)
expect(sessionCookie).toBeDefined()
return response.body
Expand Down

0 comments on commit 2d814f4

Please sign in to comment.