[E2E][Meta] Change to use better mock date

This commit is contained in:
Aaro Koivukangas
2026-08-09 01:48:41 +03:00
committed by Aaro Koivukangas
parent 7c5148646c
commit 62bb09e0b5
5 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ export const userHeaders = [
onlyStudyGuidanceGroupsUser,
]
export const testMockTime = '2026-03-01'
export const testMockTime = '2026-03-06'
export type UserId =
| 'admin'
@@ -11,9 +11,9 @@ describe('test time middleware', () => {
app.use(testTimeMiddleware)
app.get('/', (_request, response) => response.send(now().toISOString()))
const response = await request(app).get('/').set('x-test-now', '2026-03-01T12:00:00.000Z')
const response = await request(app).get('/').set('x-test-now', '2026-03-06T12:00:00.000Z')
assert.strictEqual(response.text, '2026-03-01T12:00:00.000Z')
assert.strictEqual(response.text, '2026-03-06T12:00:00.000Z')
})
it('the acual current date if x-test-now header missing', async () => {
@@ -23,7 +23,7 @@ describe('test time middleware', () => {
const response = await request(app).get('/')
assert.notStrictEqual(response.text, '2026-03-01T12:00:00.000Z')
assert.notStrictEqual(response.text, '2026-03-06T12:00:00.000Z')
})
it('the acual current date if x-test-now header has incorrect date', async () => {
@@ -33,6 +33,6 @@ describe('test time middleware', () => {
const response = await request(app).get('/').set('x-test-now', 'moimoi mitä kuuluu')
assert.notStrictEqual(response.text, '2026-03-01T12:00:00.000Z')
assert.notStrictEqual(response.text, '2026-03-06T12:00:00.000Z')
})
})
@@ -36,7 +36,7 @@ void describe('Get years object', () => {
void describe('Get years array', () => {
beforeAll(() => {
const mockedCurrentDate = new Date('2026-03-01')
const mockedCurrentDate = new Date('2026-03-06')
vi.useFakeTimers()
vi.setSystemTime(mockedCurrentDate)
@@ -6,7 +6,7 @@ import { ReduxWrapper } from '../../ReduxWrapper'
test.describe('Course statistics search', () => {
test.beforeEach(async ({ page, router }) => {
// Set time to spring 2026 so that curriculums work
await page.clock.setSystemTime('2026-03-01')
await page.clock.setSystemTime('2026-03-06')
void (await router.route('**/api/login', async route => {
const json = { user: { roles: ['admin'] } }
@@ -125,7 +125,7 @@ const testProgrammes = {
test.describe('StudyProgrammeSelector', () => {
test.beforeEach(async ({ page, router }) => {
// Set time to spring 2026 so that curriculums work
await page.clock.setSystemTime('2026-03-01')
await page.clock.setSystemTime('2026-03-06')
void (await router.route('**/api/populationstatistics/studyprogrammes', async route => {
const json = {}