Skip to content

Commit 29b40c8

Browse files
committed
test(redirect): update RedirectService tests to reflect direct redirect behavior for ogUrl matches
1 parent 567eb21 commit 29b40c8

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/server/modules/redirect/services/__tests__/RedirectService.test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { RedirectType } from '../..'
88
const ogUrl = 'https://go.gov.sg'
99

1010
// Mock the config module
11-
jest.mock('../../../../config', () => ({
12-
logger: {
13-
warn: jest.fn(),
14-
},
15-
ogUrl,
16-
}))
11+
jest.mock('../../../../config', () => {
12+
return {
13+
logger: {
14+
warn: jest.fn(),
15+
},
16+
ogUrl: 'https://go.gov.sg',
17+
}
18+
})
1719

1820
// Mock dependencies
1921
const mockUrlRepository = {
@@ -58,37 +60,37 @@ describe('RedirectService', () => {
5860
})
5961

6062
describe('referrer validation', () => {
61-
it('should show transition page for exact ogUrl match when user has not visited before', async () => {
63+
it('should allow direct redirect for exact ogUrl match when user has not visited before', async () => {
6264
const result = await redirectService.redirectFor(
6365
'test',
6466
undefined,
6567
'Mozilla/5.0',
6668
ogUrl,
6769
)
6870

69-
expect(result.redirectType).toBe(RedirectType.TransitionPage)
71+
expect(result.redirectType).toBe(RedirectType.Direct)
7072
})
7173

72-
it('should show transition page for ogUrl with path when user has not visited before', async () => {
74+
it('should allow direct redirect for ogUrl with path when user has not visited before', async () => {
7375
const result = await redirectService.redirectFor(
7476
'test',
7577
undefined,
7678
'Mozilla/5.0',
7779
`${ogUrl}/some-path`,
7880
)
7981

80-
expect(result.redirectType).toBe(RedirectType.TransitionPage)
82+
expect(result.redirectType).toBe(RedirectType.Direct)
8183
})
8284

83-
it('should show transition page for ogUrl with query params when user has not visited before', async () => {
85+
it('should allow direct redirect for ogUrl with query params when user has not visited before', async () => {
8486
const result = await redirectService.redirectFor(
8587
'test',
8688
undefined,
8789
'Mozilla/5.0',
8890
`${ogUrl}?param=value`,
8991
)
9092

91-
expect(result.redirectType).toBe(RedirectType.TransitionPage)
93+
expect(result.redirectType).toBe(RedirectType.Direct)
9294
})
9395

9496
it('should show transition page for ogUrl with different protocol when user has not visited before', async () => {

0 commit comments

Comments
 (0)