fix(api): remove redirects from api

They should be handled either by nginx or by the client. Turned out a
lot of code, including the path migration, existed to support them.
Hence the large number of removals
This commit is contained in:
Oliver Eyton-Williams
2020-08-21 18:55:28 +02:00
committed by Mrugesh Mohapatra
parent 4a45b5ac1c
commit 1ad5f756e0
12 changed files with 3 additions and 234 deletions

View File

@ -9,8 +9,7 @@ import {
createChallengeUrlResolver,
createRedirectToCurrentChallenge,
getFirstChallenge,
isValidChallengeCompletion,
createRedirectToLearn
isValidChallengeCompletion
} from '../boot/challenge';
import {
@ -21,8 +20,7 @@ import {
mockUser,
mockGetFirstChallenge,
mockCompletedChallenge,
mockCompletedChallenges,
mockPathMigrationMap
mockCompletedChallenges
} from './fixtures';
describe('boot/challenge', () => {
@ -394,33 +392,4 @@ describe('boot/challenge', () => {
done();
});
});
describe('redirectToLearn', () => {
const mockHome = 'https://example.com';
const mockLearn = 'https://example.com/learn';
const redirectToLearn = createRedirectToLearn(
mockPathMigrationMap,
mockHome,
mockLearn
);
it('redirects to learn by default', () => {
const req = mockReq({ path: '/challenges' });
const res = mockRes();
redirectToLearn(req, res);
expect(res.redirect.calledWith(mockLearn)).toBe(true);
});
it('maps to the correct redirect if the path matches a challenge', () => {
const req = mockReq({ path: '/challenges/challenge-two' });
const res = mockRes();
const expectedRedirect =
'https://example.com/learn/superblock/block/challenge-two';
redirectToLearn(req, res);
expect(res.redirect.calledWith(expectedRedirect)).toBe(true);
});
});
});