diff --git a/tests/integration/accountRouter.test.js b/tests/integration/accountRouter.test.js index e500e807..3a266d22 100644 --- a/tests/integration/accountRouter.test.js +++ b/tests/integration/accountRouter.test.js @@ -26,27 +26,18 @@ describe('Account Routes', function () { expect(response.statusCode).toBe(200) }) - test('redirect to reset request page if missing username parameter with flash parameter', async () => { + test('render request content if missing username parameter with flash', async () => { const response = await testSession.get('/account/password/confirmReset?token=XXXXX') - expect(response.statusCode).toBe(302) - expect(response.headers.location).toContain('/account/requestPasswordReset?flash=') - - const redirectResponse = await testSession.get(response.headers.location) - - expect(redirectResponse.text).toContain('Missing username') + expect(response.statusCode).toBe(200) + expect(response.text).toContain('Missing username') }) - test('redirect to reset request page if missing token parameter with flash parameter', async () => { - const response = await testSession.get('/account/password/confirmReset?username=turbo2') - - const flashValue = response.headers.location.match(/flash=([^&]+)/)[1] - const buff = Buffer.from(flashValue, 'base64') - const text = JSON.parse(buff.toString('ascii')).messages[0].msg + test('render request content if missing token parameter with flash', async () => { + const response = await testSession.get('/account/password/confirmReset?token=XXXXX') - expect(response.statusCode).toBe(302) - expect(response.headers.location).toContain('/account/requestPasswordReset?flash=') - expect(text).toBe('Missing token') + expect(response.statusCode).toBe(200) + expect(response.text).toContain('Missing username') }) test('redirect old pw-reset routes', async () => { diff --git a/tests/setup.js b/tests/setup.js index a2ad4ad8..87089a37 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -1,6 +1,7 @@ const fs = require('fs') const { WordpressService } = require('../src/backend/services/WordpressService') const { LeaderboardService } = require('../src/backend/services/LeaderboardService') +const { JavaApiM2MClient } = require('../src/backend/services/JavaApiM2MClient') const appConfig = require('../src/backend/config/app') const nock = require('nock') nock.disableNetConnect() @@ -36,10 +37,6 @@ beforeEach(() => { throw new Error('do we need to change the mock?') }) - nock(appConfig.apiUrl) - .post('/users/buildSteamPasswordResetUrl') - .reply(200, { steamUrl: 'http://localhost/test-steam-reset' }) - jest.spyOn(JavaApiM2MClient, 'getToken').mockResolvedValue({ token: { refresh: () => {}, @@ -47,6 +44,10 @@ beforeEach(() => { } }) + nock(appConfig.apiUrl) + .post('/users/buildSteamPasswordResetUrl') + .reply(200, { steamUrl: 'http://localhost/test-steam-reset' }) + nock(appConfig.apiUrl) .get('/data/clan?include=leader&fields[clan]=name,tag,description,leader,memberships,createTime&fields[player]=login&page[number]=1&page[size]=3000') .reply(200, fs.readFileSync('tests/integration/testData/clan/clans.json', { encoding: 'utf8', flag: 'r' })) @@ -54,9 +55,6 @@ beforeEach(() => { nock(appConfig.apiUrl) .get('/data/clan/2741?include=memberships.player') .reply(200, fs.readFileSync('tests/integration/testData/clan/clan.json', { encoding: 'utf8', flag: 'r' })) - nock(appConfig.apiUrl) - .post('/users/buildSteamPasswordResetUrl') - .reply(200, { steamUrl: 'http://localhost/test-steam-reset' }) }) afterEach(() => {