mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor(api): DRY out route tests (#52193)
This commit is contained in:
committed by
GitHub
parent
d177afa037
commit
30667f3b0d
@@ -58,6 +58,13 @@ export function superRequest(
|
||||
return req;
|
||||
}
|
||||
|
||||
export function createSuperRequest(config: {
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
||||
setCookies?: string[];
|
||||
}): (resource: string, options?: Options) => request.Test {
|
||||
return (resource, options) => superRequest(resource, config, options);
|
||||
}
|
||||
|
||||
export function setupServer(): void {
|
||||
let fastify: FastifyTestInstance;
|
||||
beforeAll(async () => {
|
||||
|
||||
+102
-241
@@ -12,7 +12,8 @@ import {
|
||||
setupServer,
|
||||
superRequest,
|
||||
seedExam,
|
||||
defaultUserEmail
|
||||
defaultUserEmail,
|
||||
createSuperRequest
|
||||
} from '../../jest.utils';
|
||||
import { completedTrophyChallenges } from '../../__mocks__/exam';
|
||||
import { GeneratedAnswer } from '../utils/exam-types';
|
||||
@@ -129,18 +130,19 @@ describe('challengeRoutes', () => {
|
||||
setupServer();
|
||||
describe('Authenticated user', () => {
|
||||
let setCookies: string[];
|
||||
let superPost: ReturnType<typeof createSuperRequest>;
|
||||
let superGet: ReturnType<typeof createSuperRequest>;
|
||||
|
||||
// Authenticate user
|
||||
beforeAll(async () => {
|
||||
setCookies = await devLogin();
|
||||
superPost = createSuperRequest({ method: 'POST', setCookies });
|
||||
superGet = createSuperRequest({ method: 'GET', setCookies });
|
||||
});
|
||||
|
||||
describe('POST /coderoad-challenge-completed', () => {
|
||||
test('should return 400 if no tutorialId', async () => {
|
||||
const response = await superRequest('/coderoad-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/coderoad-challenge-completed');
|
||||
expect(response.body).toEqual({
|
||||
msg: `'tutorialId' not found in request body`,
|
||||
type: 'error'
|
||||
@@ -149,10 +151,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('should return 400 if no user token', async () => {
|
||||
const response = await superRequest('/coderoad-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/coderoad-challenge-completed').send({
|
||||
tutorialId: 'freeCodeCamp/learn-bash-by-building-a-boilerplate:v1.0.0'
|
||||
});
|
||||
expect(response.body).toEqual({
|
||||
@@ -163,10 +162,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('should return 400 if invalid user token', async () => {
|
||||
const response = await superRequest('/coderoad-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
})
|
||||
const response = await superPost('/coderoad-challenge-completed')
|
||||
.set('coderoad-user-token', 'invalid')
|
||||
.send({
|
||||
tutorialId:
|
||||
@@ -180,19 +176,13 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('should return 400 if invalid tutorialId', async () => {
|
||||
const tokenResponse = await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const tokenResponse = await superPost('/user/user-token');
|
||||
expect(tokenResponse.body).toHaveProperty('userToken');
|
||||
expect(tokenResponse.status).toBe(200);
|
||||
|
||||
const token = (tokenResponse.body as { userToken: string }).userToken;
|
||||
|
||||
const response = await superRequest('/coderoad-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
})
|
||||
const response = await superPost('/coderoad-challenge-completed')
|
||||
.set('coderoad-user-token', token)
|
||||
.send({ tutorialId: 'invalid' });
|
||||
|
||||
@@ -204,19 +194,13 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('should return 400 if invalid tutorialId but is hosted on freeCodeCamp', async () => {
|
||||
const tokenResponse = await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const tokenResponse = await superPost('/user/user-token');
|
||||
expect(tokenResponse.body).toHaveProperty('userToken');
|
||||
expect(tokenResponse.status).toBe(200);
|
||||
|
||||
const token = (tokenResponse.body as { userToken: string }).userToken;
|
||||
|
||||
const response = await superRequest('/coderoad-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
})
|
||||
const response = await superPost('/coderoad-challenge-completed')
|
||||
.set('coderoad-user-token', token)
|
||||
.send({ tutorialId: 'freeCodeCamp/invalid:V1.0.0' });
|
||||
|
||||
@@ -228,19 +212,13 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('Should complete challenge with code 200', async () => {
|
||||
const tokenResponse = await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const tokenResponse = await superPost('/user/user-token');
|
||||
expect(tokenResponse.body).toHaveProperty('userToken');
|
||||
expect(tokenResponse.status).toBe(200);
|
||||
|
||||
const token = (tokenResponse.body as { userToken: string }).userToken;
|
||||
|
||||
const response = await superRequest('/coderoad-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
})
|
||||
const response = await superPost('/coderoad-challenge-completed')
|
||||
.set('coderoad-user-token', token)
|
||||
.send({
|
||||
tutorialId:
|
||||
@@ -265,19 +243,13 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('Should complete project with code 200', async () => {
|
||||
const tokenResponse = await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const tokenResponse = await superPost('/user/user-token');
|
||||
expect(tokenResponse.body).toHaveProperty('userToken');
|
||||
expect(tokenResponse.status).toBe(200);
|
||||
|
||||
const token = (tokenResponse.body as { userToken: string }).userToken;
|
||||
|
||||
const response = await superRequest('/coderoad-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
})
|
||||
const response = await superPost('/coderoad-challenge-completed')
|
||||
.set('coderoad-user-token', token)
|
||||
.send({
|
||||
tutorialId: 'freeCodeCamp/learn-celestial-bodies-database:v1.0.0'
|
||||
@@ -310,10 +282,7 @@ describe('challengeRoutes', () => {
|
||||
describe('/project-completed', () => {
|
||||
describe('validation', () => {
|
||||
it('POST rejects requests without ids', async () => {
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({});
|
||||
const response = await superPost('/project-completed').send({});
|
||||
|
||||
expect(response.body).toStrictEqual(
|
||||
isValidChallengeCompletionErrorMsg
|
||||
@@ -322,13 +291,12 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
it('POST rejects requests without valid ObjectIDs', async () => {
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
const response = await superPost(
|
||||
'/project-completed'
|
||||
// This is a departure from api-server, which does not require a
|
||||
// solution to give this error. However, the validator will reject
|
||||
// based on the missing solution before it gets to the invalid id.
|
||||
}).send({ id: 'not-a-valid-id', solution: '' });
|
||||
).send({ id: 'not-a-valid-id', solution: '' });
|
||||
|
||||
expect(response.body).toStrictEqual(
|
||||
isValidChallengeCompletionErrorMsg
|
||||
@@ -337,10 +305,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
it('POST rejects requests with invalid challengeTypes', async () => {
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/project-completed').send({
|
||||
id: id1,
|
||||
challengeType: 'not-a-valid-challenge-type',
|
||||
// TODO(Post-MVP): drop these comments, since the api-server will not
|
||||
@@ -359,10 +324,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
it('POST rejects requests without solutions', async () => {
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/project-completed').send({
|
||||
id: id1,
|
||||
challengeType: 3
|
||||
});
|
||||
@@ -376,10 +338,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
it('POST rejects requests with solutions that are not urls', async () => {
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/project-completed').send({
|
||||
id: id1,
|
||||
challengeType: 3,
|
||||
solution: 'not-a-valid-solution'
|
||||
@@ -392,10 +351,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
it('POST rejects CodeRoad/CodeAlly projects when the user has not completed the required challenges', async () => {
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/project-completed').send({
|
||||
id: id1, // not a codeally challenge id, but does not matter
|
||||
challengeType: 13, // this does matter, however, since there's special logic for that challenge type
|
||||
solution: 'https://any.valid/url'
|
||||
@@ -437,10 +393,8 @@ describe('challengeRoutes', () => {
|
||||
|
||||
it('POST accepts CodeRoad/CodeAlly projects when the user has completed the required challenges', async () => {
|
||||
const now = Date.now();
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(codeallyProject);
|
||||
const response =
|
||||
await superPost('/project-completed').send(codeallyProject);
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirst({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -474,10 +428,8 @@ describe('challengeRoutes', () => {
|
||||
it('POST accepts backend projects', async () => {
|
||||
const now = Date.now();
|
||||
|
||||
const response = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(backendProject);
|
||||
const response =
|
||||
await superPost('/project-completed').send(backendProject);
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirst({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -509,23 +461,19 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
it('POST correctly handles multiple requests', async () => {
|
||||
const resOriginal = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(codeallyProject);
|
||||
const resOriginal =
|
||||
await superPost('/project-completed').send(codeallyProject);
|
||||
|
||||
const resBackend = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(backendProject);
|
||||
const resBackend =
|
||||
await superPost('/project-completed').send(backendProject);
|
||||
|
||||
// sending backendProject again should update its solution, but not
|
||||
// progressTimestamps or its completedDate
|
||||
|
||||
const resUpdate = await superRequest('/project-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({ ...codeallyProject, solution: 'https://any.other/url' });
|
||||
const resUpdate = await superPost('/project-completed').send({
|
||||
...codeallyProject,
|
||||
solution: 'https://any.other/url'
|
||||
});
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirst({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -569,10 +517,7 @@ describe('challengeRoutes', () => {
|
||||
describe('/backend-challenge-completed', () => {
|
||||
describe('validation', () => {
|
||||
test('POST rejects requests without ids', async () => {
|
||||
const response = await superRequest('/backend-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/backend-challenge-completed');
|
||||
|
||||
expect(response.body).toStrictEqual(
|
||||
isValidChallengeCompletionErrorMsg
|
||||
@@ -581,10 +526,9 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST rejects requests without valid ObjectIDs', async () => {
|
||||
const response = await superRequest('/backend-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({ id: 'not-a-valid-id', solution: '' });
|
||||
const response = await superPost('/backend-challenge-completed').send(
|
||||
{ id: 'not-a-valid-id', solution: '' }
|
||||
);
|
||||
|
||||
expect(response.body).toStrictEqual(
|
||||
isValidChallengeCompletionErrorMsg
|
||||
@@ -607,10 +551,9 @@ describe('challengeRoutes', () => {
|
||||
test('POST accepts backend challenges', async () => {
|
||||
const now = Date.now();
|
||||
|
||||
const response = await superRequest('/backend-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(backendChallengeBody1);
|
||||
const response = await superPost('/backend-challenge-completed').send(
|
||||
backendChallengeBody1
|
||||
);
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirst({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -638,25 +581,16 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST correctly handles multiple requests', async () => {
|
||||
const resOriginal = await superRequest(
|
||||
'/backend-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const resOriginal = await superPost(
|
||||
'/backend-challenge-completed'
|
||||
).send(backendChallengeBody1);
|
||||
|
||||
await superRequest('/backend-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(backendChallengeBody2);
|
||||
await superPost('/backend-challenge-completed').send(
|
||||
backendChallengeBody2
|
||||
);
|
||||
|
||||
const resUpdated = await superRequest(
|
||||
'/backend-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const resUpdated = await superPost(
|
||||
'/backend-challenge-completed'
|
||||
).send({
|
||||
...backendChallengeBody1
|
||||
});
|
||||
@@ -699,10 +633,7 @@ describe('challengeRoutes', () => {
|
||||
describe('/modern-challenge-completed', () => {
|
||||
describe('validation', () => {
|
||||
test('POST rejects requests without ids', async () => {
|
||||
const response = await superRequest('/modern-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/modern-challenge-completed');
|
||||
|
||||
expect(response.body).toStrictEqual(
|
||||
isValidChallengeCompletionErrorMsg
|
||||
@@ -711,10 +642,9 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST rejects requests without valid ObjectIDs', async () => {
|
||||
const response = await superRequest('/modern-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({ id: 'not-a-valid-id' });
|
||||
const response = await superPost('/modern-challenge-completed').send({
|
||||
id: 'not-a-valid-id'
|
||||
});
|
||||
|
||||
expect(response.body).toStrictEqual(
|
||||
isValidChallengeCompletionErrorMsg
|
||||
@@ -739,10 +669,9 @@ describe('challengeRoutes', () => {
|
||||
test('POST accepts challenges without files present', async () => {
|
||||
const now = Date.now();
|
||||
|
||||
const response = await superRequest('/modern-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(HtmlChallengeBody);
|
||||
const response = await superPost('/modern-challenge-completed').send(
|
||||
HtmlChallengeBody
|
||||
);
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirstOrThrow({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -774,10 +703,9 @@ describe('challengeRoutes', () => {
|
||||
test('POST accepts challenges with files present', async () => {
|
||||
const now = Date.now();
|
||||
|
||||
const response = await superRequest('/modern-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(JsProjectBody);
|
||||
const response = await superPost('/modern-challenge-completed').send(
|
||||
JsProjectBody
|
||||
);
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirstOrThrow({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -812,10 +740,9 @@ describe('challengeRoutes', () => {
|
||||
test('POST accepts challenges with saved solutions', async () => {
|
||||
const now = Date.now();
|
||||
|
||||
const response = await superRequest('/modern-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(multiFileCertProjectBody);
|
||||
const response = await superPost('/modern-challenge-completed').send(
|
||||
multiFileCertProjectBody
|
||||
);
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirstOrThrow({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -865,23 +792,17 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST correctly handles multiple requests', async () => {
|
||||
const resOriginal = await superRequest(
|
||||
'/modern-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const resOriginal = await superPost(
|
||||
'/modern-challenge-completed'
|
||||
).send(multiFileCertProjectBody);
|
||||
|
||||
await superRequest('/modern-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(HtmlChallengeBody);
|
||||
await superPost('/modern-challenge-completed').send(
|
||||
HtmlChallengeBody
|
||||
);
|
||||
|
||||
const resUpdate = await superRequest('/modern-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(updatedMultiFileCertProjectBody);
|
||||
const resUpdate = await superPost('/modern-challenge-completed').send(
|
||||
updatedMultiFileCertProjectBody
|
||||
);
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirstOrThrow({
|
||||
where: { email: 'foo@bar.com' }
|
||||
@@ -947,10 +868,7 @@ describe('challengeRoutes', () => {
|
||||
describe('/save-challenge', () => {
|
||||
describe('validation', () => {
|
||||
test('POST returns 403 status for unsavable challenges', async () => {
|
||||
const response = await superRequest('/save-challenge', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/save-challenge').send({
|
||||
savedChallenges: {
|
||||
// valid mongo id, but not a saveable one
|
||||
id: 'aaaaaaaaaaaaaaaaaaaaaaa',
|
||||
@@ -977,10 +895,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST update the user savedchallenges and return them', async () => {
|
||||
const response = await superRequest('/save-challenge', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/save-challenge').send({
|
||||
id: multiFileCertProjectId,
|
||||
files: updatedMultiFileCertProjectBody.files
|
||||
});
|
||||
@@ -1021,10 +936,7 @@ describe('challengeRoutes', () => {
|
||||
|
||||
describe('validation', () => {
|
||||
test('GET rejects requests without id param', async () => {
|
||||
const response = await superRequest('/exam/', {
|
||||
method: 'GET',
|
||||
setCookies
|
||||
});
|
||||
const response = await superGet('/exam/');
|
||||
|
||||
expect(response.body).toStrictEqual({
|
||||
error: `Valid 'id' not found in request parameters.`
|
||||
@@ -1033,10 +945,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('GET rejects requests when id param is not a 24-character string', async () => {
|
||||
const response = await superRequest('/exam/fake-id', {
|
||||
method: 'GET',
|
||||
setCookies
|
||||
});
|
||||
const response = await superGet('/exam/fake-id');
|
||||
|
||||
expect(response.body).toStrictEqual({
|
||||
error: `Valid 'id' not found in request parameters.`
|
||||
@@ -1045,13 +954,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('GET rejects requests with non-existent id param', async () => {
|
||||
const response = await superRequest(
|
||||
'/exam/123412341234123412341234',
|
||||
{
|
||||
method: 'GET',
|
||||
setCookies
|
||||
}
|
||||
);
|
||||
const response = await superGet('/exam/123412341234123412341234');
|
||||
|
||||
expect(response.body).toStrictEqual({
|
||||
error: 'An error occurred trying to get the exam from the database.'
|
||||
@@ -1060,13 +963,7 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('GET rejects requests where camper has not completed prerequisites', async () => {
|
||||
const response = await superRequest(
|
||||
'/exam/647e22d18acb466c97ccbef8',
|
||||
{
|
||||
method: 'GET',
|
||||
setCookies
|
||||
}
|
||||
);
|
||||
const response = await superGet('/exam/647e22d18acb466c97ccbef8');
|
||||
|
||||
expect(response.body).toStrictEqual({
|
||||
error: `You have not completed the required challenges to start the 'Exam Certification'.`
|
||||
@@ -1082,13 +979,7 @@ describe('challengeRoutes', () => {
|
||||
data: { completedChallenges: completedTrophyChallenges }
|
||||
});
|
||||
|
||||
const response = await superRequest(
|
||||
'/exam/647e22d18acb466c97ccbef8',
|
||||
{
|
||||
method: 'GET',
|
||||
setCookies
|
||||
}
|
||||
);
|
||||
const response = await superGet('/exam/647e22d18acb466c97ccbef8');
|
||||
|
||||
expect(response.body).toHaveProperty('generatedExam');
|
||||
|
||||
@@ -1143,23 +1034,13 @@ describe('challengeRoutes', () => {
|
||||
|
||||
describe('validation', () => {
|
||||
test('POST rejects requests without valid ids', async () => {
|
||||
const resNoId = await superRequest(
|
||||
'/ms-trophy-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
);
|
||||
const resNoId = await superPost('/ms-trophy-challenge-completed');
|
||||
|
||||
expect(resNoId.body).toStrictEqual(idIsMissingOrInvalid);
|
||||
expect(resNoId.statusCode).toBe(400);
|
||||
|
||||
const resBadId = await superRequest(
|
||||
'/ms-trophy-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const resBadId = await superPost(
|
||||
'/ms-trophy-challenge-completed'
|
||||
).send({ id: nonTrophyChallengeId });
|
||||
|
||||
expect(resBadId.body).toStrictEqual(idIsMissingOrInvalid);
|
||||
@@ -1168,12 +1049,8 @@ describe('challengeRoutes', () => {
|
||||
|
||||
// TODO(Post-MVP): give a more specific error message
|
||||
test('POST rejects requests without valid ObjectIDs', async () => {
|
||||
const response = await superRequest(
|
||||
'/ms-trophy-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const response = await superPost(
|
||||
'/ms-trophy-challenge-completed'
|
||||
).send({ id: 'not-a-valid-id' });
|
||||
|
||||
expect(response.body).toStrictEqual(idIsMissingOrInvalid);
|
||||
@@ -1205,10 +1082,9 @@ describe('challengeRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST rejects requests if the user does not have a Microsoft username', async () => {
|
||||
const res = await superRequest('/ms-trophy-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({ id: trophyChallengeId });
|
||||
const res = await superPost('/ms-trophy-challenge-completed').send({
|
||||
id: trophyChallengeId
|
||||
});
|
||||
|
||||
expect(res.body).toStrictEqual(userHasNotLinkedTheirAccount);
|
||||
expect(res.statusCode).toBe(403);
|
||||
@@ -1231,10 +1107,9 @@ describe('challengeRoutes', () => {
|
||||
Promise.resolve(verifyError)
|
||||
);
|
||||
|
||||
const res = await superRequest('/ms-trophy-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({ id: trophyChallengeId });
|
||||
const res = await superPost('/ms-trophy-challenge-completed').send({
|
||||
id: trophyChallengeId
|
||||
});
|
||||
|
||||
expect(res.body).toStrictEqual(verifyError);
|
||||
expect(res.statusCode).toBe(403);
|
||||
@@ -1247,10 +1122,9 @@ describe('challengeRoutes', () => {
|
||||
const msUsername = 'ANRandom';
|
||||
await createMSUsernameRecord(msUsername);
|
||||
|
||||
const res = await superRequest('/ms-trophy-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({ id: trophyChallengeId });
|
||||
const res = await superPost('/ms-trophy-challenge-completed').send({
|
||||
id: trophyChallengeId
|
||||
});
|
||||
|
||||
expect(res.body).toStrictEqual(unexpectedError);
|
||||
expect(res.statusCode).toBe(500);
|
||||
@@ -1267,10 +1141,9 @@ describe('challengeRoutes', () => {
|
||||
await createMSUsernameRecord(msUsername);
|
||||
const now = Date.now();
|
||||
|
||||
const res = await superRequest('/ms-trophy-challenge-completed', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({ id: trophyChallengeId });
|
||||
const res = await superPost('/ms-trophy-challenge-completed').send({
|
||||
id: trophyChallengeId
|
||||
});
|
||||
|
||||
const user =
|
||||
await fastifyTestInstance.prisma.user.findUniqueOrThrow({
|
||||
@@ -1310,12 +1183,8 @@ describe('challengeRoutes', () => {
|
||||
const msUsername = 'ANRandom';
|
||||
await createMSUsernameRecord(msUsername);
|
||||
|
||||
const resOne = await superRequest(
|
||||
'/ms-trophy-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const resOne = await superPost(
|
||||
'/ms-trophy-challenge-completed'
|
||||
).send({ id: trophyChallengeId });
|
||||
|
||||
mockVerifyTrophyWithMicrosoft.mockImplementationOnce(() =>
|
||||
@@ -1324,12 +1193,8 @@ describe('challengeRoutes', () => {
|
||||
msGameStatusApiUrl: solutionUrl
|
||||
})
|
||||
);
|
||||
const resTwo = await superRequest(
|
||||
'/ms-trophy-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const resTwo = await superPost(
|
||||
'/ms-trophy-challenge-completed'
|
||||
).send({ id: trophyChallengeId2 });
|
||||
|
||||
// sending the second trophy challenge again should not change
|
||||
@@ -1340,12 +1205,8 @@ describe('challengeRoutes', () => {
|
||||
msGameStatusApiUrl: solutionUrl
|
||||
})
|
||||
);
|
||||
const resUpdate = await superRequest(
|
||||
'/ms-trophy-challenge-completed',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const resUpdate = await superPost(
|
||||
'/ms-trophy-challenge-completed'
|
||||
).send({ id: trophyChallengeId2 });
|
||||
|
||||
const { completedChallenges, progressTimestamps } =
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { devLogin, setupServer, superRequest } from '../../jest.utils';
|
||||
import {
|
||||
createSuperRequest,
|
||||
devLogin,
|
||||
setupServer,
|
||||
superRequest
|
||||
} from '../../jest.utils';
|
||||
|
||||
const chargeStripeCardReqBody = {
|
||||
paymentMethodId: 'UID',
|
||||
@@ -44,10 +49,11 @@ describe('Donate', () => {
|
||||
setupServer();
|
||||
|
||||
describe('Authenticated User', () => {
|
||||
let setCookies: string[];
|
||||
let superPost: ReturnType<typeof createSuperRequest>;
|
||||
|
||||
beforeEach(async () => {
|
||||
setCookies = await devLogin();
|
||||
const setCookies = await devLogin();
|
||||
superPost = createSuperRequest({ method: 'POST', setCookies });
|
||||
});
|
||||
|
||||
describe('POST /donate/charge-stripe-card', () => {
|
||||
@@ -55,10 +61,9 @@ describe('Donate', () => {
|
||||
mockSubCreate.mockImplementationOnce(
|
||||
generateMockSubCreate('we only care about specific error cases')
|
||||
);
|
||||
const response = await superRequest('/donate/charge-stripe-card', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(chargeStripeCardReqBody);
|
||||
const response = await superPost('/donate/charge-stripe-card').send(
|
||||
chargeStripeCardReqBody
|
||||
);
|
||||
expect(response.body).toEqual({ isDonating: true, type: 'success' });
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
@@ -67,10 +72,9 @@ describe('Donate', () => {
|
||||
mockSubCreate.mockImplementationOnce(
|
||||
generateMockSubCreate('requires_source_action')
|
||||
);
|
||||
const response = await superRequest('/donate/charge-stripe-card', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(chargeStripeCardReqBody);
|
||||
const response = await superPost('/donate/charge-stripe-card').send(
|
||||
chargeStripeCardReqBody
|
||||
);
|
||||
|
||||
expect(response.body).toEqual({
|
||||
type: 'UserActionRequired',
|
||||
@@ -84,10 +88,9 @@ describe('Donate', () => {
|
||||
mockSubCreate.mockImplementationOnce(
|
||||
generateMockSubCreate('requires_source')
|
||||
);
|
||||
const response = await superRequest('/donate/charge-stripe-card', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(chargeStripeCardReqBody);
|
||||
const response = await superPost('/donate/charge-stripe-card').send(
|
||||
chargeStripeCardReqBody
|
||||
);
|
||||
|
||||
expect(response.body).toEqual({
|
||||
type: 'PaymentMethodRequired',
|
||||
@@ -100,28 +103,22 @@ describe('Donate', () => {
|
||||
mockSubCreate.mockImplementationOnce(
|
||||
generateMockSubCreate('still does not matter')
|
||||
);
|
||||
const successResponse = await superRequest(
|
||||
'/donate/charge-stripe-card',
|
||||
{
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}
|
||||
const successResponse = await superPost(
|
||||
'/donate/charge-stripe-card'
|
||||
).send(chargeStripeCardReqBody);
|
||||
|
||||
expect(successResponse.status).toBe(200);
|
||||
const failResponse = await superRequest('/donate/charge-stripe-card', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(chargeStripeCardReqBody);
|
||||
const failResponse = await superPost('/donate/charge-stripe-card').send(
|
||||
chargeStripeCardReqBody
|
||||
);
|
||||
expect(failResponse.status).toBe(400);
|
||||
});
|
||||
|
||||
it('should return 500 if Stripe encountes an error', async () => {
|
||||
mockSubCreate.mockImplementationOnce(defaultError);
|
||||
const response = await superRequest('/donate/charge-stripe-card', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send(chargeStripeCardReqBody);
|
||||
const response = await superPost('/donate/charge-stripe-card').send(
|
||||
chargeStripeCardReqBody
|
||||
);
|
||||
expect(response.status).toBe(500);
|
||||
expect(response.body).toEqual({
|
||||
type: 'danger',
|
||||
@@ -132,10 +129,7 @@ describe('Donate', () => {
|
||||
|
||||
describe('POST /donate/add-donation', () => {
|
||||
it('should return 200 and update the user', async () => {
|
||||
const response = await superRequest('/donate/add-donation', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/donate/add-donation').send({
|
||||
anything: true,
|
||||
itIs: 'ignored'
|
||||
});
|
||||
@@ -147,15 +141,11 @@ describe('Donate', () => {
|
||||
});
|
||||
|
||||
it('should return 400 if the user is already donating', async () => {
|
||||
const successResponse = await superRequest('/donate/add-donation', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({});
|
||||
const successResponse = await superPost('/donate/add-donation').send(
|
||||
{}
|
||||
);
|
||||
expect(successResponse.status).toBe(200);
|
||||
const failResponse = await superRequest('/donate/add-donation', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({});
|
||||
const failResponse = await superPost('/donate/add-donation').send({});
|
||||
expect(failResponse.status).toBe(400);
|
||||
});
|
||||
});
|
||||
|
||||
+87
-175
@@ -1,4 +1,9 @@
|
||||
import { devLogin, setupServer, superRequest } from '../../jest.utils';
|
||||
import {
|
||||
devLogin,
|
||||
setupServer,
|
||||
superRequest,
|
||||
createSuperRequest
|
||||
} from '../../jest.utils';
|
||||
import { createUserInput } from '../utils/create-user';
|
||||
|
||||
import { isPictureWithProtocol } from './settings';
|
||||
@@ -90,11 +95,12 @@ describe('settingRoutes', () => {
|
||||
});
|
||||
|
||||
describe('Authenticated user', () => {
|
||||
let setCookies: string[];
|
||||
let superPut: ReturnType<typeof createSuperRequest>;
|
||||
|
||||
// Authenticate user
|
||||
beforeAll(async () => {
|
||||
setCookies = await devLogin();
|
||||
const setCookies = await devLogin();
|
||||
superPut = createSuperRequest({ method: 'PUT', setCookies });
|
||||
// This is not strictly necessary, since the defaultUser has this
|
||||
// profileUI, but we're interested in how the profileUI is updated. As
|
||||
// such, setting this explicitly isolates these tests.
|
||||
@@ -116,10 +122,7 @@ describe('settingRoutes', () => {
|
||||
|
||||
describe('/update-my-profileui', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-profileui', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-profileui').send({
|
||||
profileUI
|
||||
});
|
||||
|
||||
@@ -136,10 +139,7 @@ describe('settingRoutes', () => {
|
||||
});
|
||||
|
||||
test('PUT ignores invalid keys', async () => {
|
||||
const response = await superRequest('/update-my-profileui', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-profileui').send({
|
||||
profileUI: {
|
||||
...profileUI,
|
||||
invalidKey: 'invalidValue'
|
||||
@@ -155,10 +155,7 @@ describe('settingRoutes', () => {
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code with missing keys', async () => {
|
||||
const response = await superRequest('/update-my-profileui', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-profileui').send({
|
||||
profileUI: {
|
||||
isLocked: true,
|
||||
showName: true,
|
||||
@@ -186,10 +183,9 @@ describe('settingRoutes', () => {
|
||||
});
|
||||
});
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: 'foo@foo.com' });
|
||||
const response = await superPut('/update-my-email').send({
|
||||
email: 'foo@foo.com'
|
||||
});
|
||||
|
||||
expect(response?.body).toEqual({
|
||||
message: 'flash.email-valid',
|
||||
@@ -199,10 +195,9 @@ describe('settingRoutes', () => {
|
||||
});
|
||||
|
||||
test("PUT updates the user's record in preparation for receiving auth email", async () => {
|
||||
const response = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: unusedEmailOne });
|
||||
const response = await superPut('/update-my-email').send({
|
||||
email: unusedEmailOne
|
||||
});
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirstOrThrow({
|
||||
where: { email: developerUserEmail },
|
||||
@@ -230,10 +225,9 @@ describe('settingRoutes', () => {
|
||||
});
|
||||
|
||||
test('PUT rejects invalid email addresses', async () => {
|
||||
const response = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: 'invalid' });
|
||||
const response = await superPut('/update-my-email').send({
|
||||
email: 'invalid'
|
||||
});
|
||||
|
||||
// We cannot use fastify's default validation failure response here
|
||||
// because the client consumes the response and displays it to the user.
|
||||
@@ -249,10 +243,9 @@ describe('settingRoutes', () => {
|
||||
where: { email: developerUserEmail },
|
||||
data: { emailVerified: false }
|
||||
});
|
||||
const response = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: developerUserEmail.toUpperCase() });
|
||||
const response = await superPut('/update-my-email').send({
|
||||
email: developerUserEmail.toUpperCase()
|
||||
});
|
||||
|
||||
expect(response?.statusCode).toEqual(200);
|
||||
expect(response?.body).toEqual({
|
||||
@@ -262,10 +255,9 @@ describe('settingRoutes', () => {
|
||||
});
|
||||
|
||||
test('PUT rejects a request to update to the existing email (ignoring case) address', async () => {
|
||||
const response = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: developerUserEmail.toUpperCase() });
|
||||
const response = await superPut('/update-my-email').send({
|
||||
email: developerUserEmail.toUpperCase()
|
||||
});
|
||||
|
||||
expect(response?.body).toEqual({
|
||||
type: 'info',
|
||||
@@ -276,17 +268,15 @@ You can update a new email address instead.`
|
||||
});
|
||||
|
||||
test('PUT rejects a request to update to the same email (ignoring case) twice', async () => {
|
||||
const successResponse = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: unusedEmailOne });
|
||||
const successResponse = await superPut('/update-my-email').send({
|
||||
email: unusedEmailOne
|
||||
});
|
||||
|
||||
expect(successResponse?.statusCode).toEqual(200);
|
||||
|
||||
const failResponse = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: unusedEmailOne.toUpperCase() });
|
||||
const failResponse = await superPut('/update-my-email').send({
|
||||
email: unusedEmailOne.toUpperCase()
|
||||
});
|
||||
|
||||
expect(failResponse?.body).toEqual({
|
||||
type: 'info',
|
||||
@@ -297,10 +287,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT rejects a request if the new email is already in use', async () => {
|
||||
const response = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: otherDeveloperUserEmail });
|
||||
const response = await superPut('/update-my-email').send({
|
||||
email: otherDeveloperUserEmail
|
||||
});
|
||||
|
||||
expect(response?.body).toEqual({
|
||||
type: 'info',
|
||||
@@ -310,17 +299,15 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT rejects the second request if is immediately after the first', async () => {
|
||||
const successResponse = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: unusedEmailOne });
|
||||
const successResponse = await superPut('/update-my-email').send({
|
||||
email: unusedEmailOne
|
||||
});
|
||||
|
||||
expect(successResponse?.statusCode).toEqual(200);
|
||||
|
||||
const failResponse = await superRequest('/update-my-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ email: unusedEmailTwo });
|
||||
const failResponse = await superPut('/update-my-email').send({
|
||||
email: unusedEmailTwo
|
||||
});
|
||||
|
||||
expect(failResponse?.statusCode).toEqual(429);
|
||||
|
||||
@@ -335,10 +322,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-theme', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-theme', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-theme').send({
|
||||
theme: 'night'
|
||||
});
|
||||
|
||||
@@ -350,10 +334,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code with invalid theme', async () => {
|
||||
const response = await superRequest('/update-my-theme', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-theme').send({
|
||||
theme: 'invalid'
|
||||
});
|
||||
|
||||
@@ -364,10 +345,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-username', () => {
|
||||
test('PUT returns an error when the username uses special characters', async () => {
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username: 'twaha@'
|
||||
});
|
||||
|
||||
@@ -379,10 +357,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns an error when the username is an endpoint', async () => {
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username: 'german'
|
||||
});
|
||||
|
||||
@@ -394,10 +369,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns an error when the username is a bad word', async () => {
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username: 'ass'
|
||||
});
|
||||
|
||||
@@ -409,10 +381,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns an error when the username is a https status code', async () => {
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username: '404'
|
||||
});
|
||||
|
||||
@@ -424,10 +393,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns an error when the username is shorter than 3 characters', async () => {
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username: 'fo'
|
||||
});
|
||||
|
||||
@@ -439,10 +405,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username: 'TwaHa1'
|
||||
});
|
||||
|
||||
@@ -475,17 +438,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
unsubscribeId: 'unsubscribeId'
|
||||
}
|
||||
});
|
||||
await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
username: 'twaha2'
|
||||
});
|
||||
await superPut('/update-my-username').send({ username: 'twaha2' });
|
||||
|
||||
const secondUpdate = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const secondUpdate = await superPut('/update-my-username').send({
|
||||
username: 'twaha2'
|
||||
});
|
||||
|
||||
@@ -497,10 +452,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
// Not allowed because, while the usernameDisplay is different, the
|
||||
// username is not
|
||||
const existingUser = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const existingUser = await superPut('/update-my-username').send({
|
||||
username: 'SemBauke'
|
||||
});
|
||||
|
||||
@@ -512,17 +464,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
username: 'twaha3'
|
||||
});
|
||||
await superPut('/update-my-username').send({ username: 'twaha3' });
|
||||
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username: 'TWaha3'
|
||||
});
|
||||
|
||||
@@ -535,10 +479,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
test('PUT /update-my-username returns 400 status code when username is too long', async () => {
|
||||
const username = 'a'.repeat(1001);
|
||||
const response = await superRequest('/update-my-username', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-username').send({
|
||||
username
|
||||
});
|
||||
|
||||
@@ -552,10 +493,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-keyboard-shortcuts', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-keyboard-shortcuts', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ keyboardShortcuts: true });
|
||||
const response = await superPut('/update-my-keyboard-shortcuts').send({
|
||||
keyboardShortcuts: true
|
||||
});
|
||||
|
||||
expect(response.body).toEqual({
|
||||
message: 'flash.keyboard-shortcut-updated',
|
||||
@@ -565,10 +505,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code with invalid shortcuts setting', async () => {
|
||||
const response = await superRequest('/update-my-keyboard-shortcuts', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ keyboardShortcuts: 'invalid' });
|
||||
const response = await superPut('/update-my-keyboard-shortcuts').send({
|
||||
keyboardShortcuts: 'invalid'
|
||||
});
|
||||
|
||||
expect(response.body).toEqual(updateErrorResponse);
|
||||
expect(response.statusCode).toEqual(400);
|
||||
@@ -577,10 +516,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-socials', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-socials', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-socials').send({
|
||||
website: 'https://www.freecodecamp.org/',
|
||||
twitter: 'https://twitter.com/ossia',
|
||||
linkedin: 'https://www.linkedin.com/in/quincylarson',
|
||||
@@ -595,10 +531,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code with invalid socials setting', async () => {
|
||||
const response = await superRequest('/update-my-socials', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-socials').send({
|
||||
website: 'invalid',
|
||||
twitter: 'invalid',
|
||||
linkedin: 'invalid',
|
||||
@@ -612,10 +545,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-quincy-email', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-quincy-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ sendQuincyEmail: true });
|
||||
const response = await superPut('/update-my-quincy-email').send({
|
||||
sendQuincyEmail: true
|
||||
});
|
||||
|
||||
expect(response.body).toEqual({
|
||||
message: 'flash.subscribe-to-quincy-updated',
|
||||
@@ -625,10 +557,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code with invalid sendQuincyEmail', async () => {
|
||||
const response = await superRequest('/update-my-quincy-email', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ sendQuincyEmail: 'invalid' });
|
||||
const response = await superPut('/update-my-quincy-email').send({
|
||||
sendQuincyEmail: 'invalid'
|
||||
});
|
||||
|
||||
expect(response.body).toEqual(updateErrorResponse);
|
||||
expect(response.statusCode).toEqual(400);
|
||||
@@ -637,10 +568,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-about', () => {
|
||||
test('PUT updates the values in about settings', async () => {
|
||||
const response = await superRequest('/update-my-about', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-about').send({
|
||||
about: 'Teacher at freeCodeCamp',
|
||||
name: 'Quincy Larson',
|
||||
location: 'USA',
|
||||
@@ -667,10 +595,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT updates the values in about settings without image', async () => {
|
||||
const response = await superRequest('/update-my-about', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-about').send({
|
||||
about: 'Teacher at freeCodeCamp',
|
||||
name: 'Quincy Larson',
|
||||
location: 'USA',
|
||||
@@ -688,10 +613,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-honesty', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-honesty', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ isHonest: true });
|
||||
const response = await superPut('/update-my-honesty').send({
|
||||
isHonest: true
|
||||
});
|
||||
|
||||
expect(response.body).toEqual({
|
||||
message: 'buttons.accepted-honesty',
|
||||
@@ -701,10 +625,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code with invalid honesty', async () => {
|
||||
const response = await superRequest('/update-my-honesty', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ isHonest: false });
|
||||
const response = await superPut('/update-my-honesty').send({
|
||||
isHonest: false
|
||||
});
|
||||
|
||||
expect(response.body).toEqual(updateErrorResponse);
|
||||
expect(response.statusCode).toEqual(400);
|
||||
@@ -713,10 +636,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-privacy-terms', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-privacy-terms', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ quincyEmails: true });
|
||||
const response = await superPut('/update-privacy-terms').send({
|
||||
quincyEmails: true
|
||||
});
|
||||
|
||||
expect(response.body).toEqual({
|
||||
message: 'flash.privacy-updated',
|
||||
@@ -726,10 +648,9 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code with non-boolean data', async () => {
|
||||
const response = await superRequest('/update-privacy-terms', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({ quincyEmails: '123' });
|
||||
const response = await superPut('/update-privacy-terms').send({
|
||||
quincyEmails: '123'
|
||||
});
|
||||
|
||||
expect(response.body).toEqual(updateErrorResponse);
|
||||
expect(response.statusCode).toEqual(400);
|
||||
@@ -738,10 +659,7 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
|
||||
describe('/update-my-portfolio', () => {
|
||||
test('PUT returns 200 status code with "success" message', async () => {
|
||||
const response = await superRequest('/update-my-portfolio', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-portfolio').send({
|
||||
portfolio: [{}]
|
||||
});
|
||||
|
||||
@@ -753,20 +671,14 @@ Please wait 5 minutes to resend an authentication link.`
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code when the portfolio property is missing', async () => {
|
||||
const response = await superRequest('/update-my-portfolio', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({});
|
||||
const response = await superPut('/update-my-portfolio').send({});
|
||||
|
||||
expect(response.body).toEqual(updateErrorResponse);
|
||||
expect(response.statusCode).toEqual(400);
|
||||
});
|
||||
|
||||
test('PUT returns 400 status code when any data is the wrong type', async () => {
|
||||
const response = await superRequest('/update-my-portfolio', {
|
||||
method: 'PUT',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPut('/update-my-portfolio').send({
|
||||
portfolio: [
|
||||
{ id: '', title: '', description: '', url: '', image: '' },
|
||||
{ id: '', title: {}, description: '', url: '', image: '' }
|
||||
|
||||
+43
-134
@@ -12,7 +12,8 @@ import {
|
||||
defaultUserEmail,
|
||||
devLogin,
|
||||
setupServer,
|
||||
superRequest
|
||||
superRequest,
|
||||
createSuperRequest
|
||||
} from '../../jest.utils';
|
||||
import { JWT_SECRET } from '../utils/env';
|
||||
import { getMsTranscriptApiUrl } from './user';
|
||||
@@ -273,10 +274,15 @@ describe('userRoutes', () => {
|
||||
setupServer();
|
||||
|
||||
describe('Authenticated user', () => {
|
||||
let setCookies: string[];
|
||||
let superGet: ReturnType<typeof createSuperRequest>;
|
||||
let superPost: ReturnType<typeof createSuperRequest>;
|
||||
let superDelete: ReturnType<typeof createSuperRequest>;
|
||||
|
||||
beforeEach(async () => {
|
||||
setCookies = await devLogin();
|
||||
const setCookies = await devLogin();
|
||||
superGet = createSuperRequest({ method: 'GET', setCookies });
|
||||
superPost = createSuperRequest({ method: 'POST', setCookies });
|
||||
superDelete = createSuperRequest({ method: 'DELETE', setCookies });
|
||||
});
|
||||
|
||||
describe('/account/delete', () => {
|
||||
@@ -291,11 +297,7 @@ describe('userRoutes', () => {
|
||||
|
||||
test('POST returns 200 status code with empty object', async () => {
|
||||
expect(await fastifyTestInstance.prisma.user.count()).toBe(1);
|
||||
const response = await superRequest('/account/delete', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
|
||||
const response = await superPost('/account/delete');
|
||||
const userCount = await fastifyTestInstance.prisma.user.count({
|
||||
where: { email: testUserData.email }
|
||||
});
|
||||
@@ -310,11 +312,7 @@ describe('userRoutes', () => {
|
||||
data: msUsernameData
|
||||
});
|
||||
|
||||
await superRequest('/account/delete', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
|
||||
await superPost('/account/delete');
|
||||
expect(await fastifyTestInstance.prisma.msUsername.count()).toBe(1);
|
||||
});
|
||||
|
||||
@@ -323,10 +321,8 @@ describe('userRoutes', () => {
|
||||
data: tokenData
|
||||
});
|
||||
|
||||
await superRequest('/account/delete', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
await superPost('/account/delete');
|
||||
|
||||
const userTokens =
|
||||
await fastifyTestInstance.prisma.userToken.findMany();
|
||||
expect(userTokens).toHaveLength(1);
|
||||
@@ -349,10 +345,7 @@ describe('userRoutes', () => {
|
||||
data: modifiedProgressData
|
||||
});
|
||||
|
||||
const response = await superRequest('/account/reset-progress', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/account/reset-progress');
|
||||
|
||||
const user = await fastifyTestInstance.prisma.user.findFirst({
|
||||
where: { email: testUserData.email }
|
||||
@@ -370,10 +363,7 @@ describe('userRoutes', () => {
|
||||
data: msUsernameData
|
||||
});
|
||||
|
||||
await superRequest('/account/reset-progress', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
await superPost('/account/reset-progress');
|
||||
|
||||
expect(await fastifyTestInstance.prisma.msUsername.count()).toBe(1);
|
||||
});
|
||||
@@ -383,10 +373,7 @@ describe('userRoutes', () => {
|
||||
data: tokenData
|
||||
});
|
||||
|
||||
await superRequest('/account/reset-progress', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
await superPost('/account/reset-progress');
|
||||
|
||||
const userTokens =
|
||||
await fastifyTestInstance.prisma.userToken.findMany();
|
||||
@@ -417,10 +404,7 @@ describe('userRoutes', () => {
|
||||
|
||||
// TODO(Post-MVP): consider using PUT and updating the logic to upsert
|
||||
test('POST success response includes a JWT encoded string', async () => {
|
||||
const response = await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/user/user-token');
|
||||
|
||||
const userToken = response.body.userToken;
|
||||
const decodedToken = jwt.decode(userToken);
|
||||
@@ -439,10 +423,7 @@ describe('userRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST responds with an encoded UserToken id', async () => {
|
||||
const response = await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/user/user-token');
|
||||
|
||||
const decodedToken = jwt.decode(response.body.userToken);
|
||||
const userTokenId = (decodedToken as JwtPayload).userToken;
|
||||
@@ -457,10 +438,7 @@ describe('userRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST deletes old tokens when creating a new one', async () => {
|
||||
const response = await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/user/user-token');
|
||||
|
||||
const decodedToken = jwt.decode(response.body.userToken);
|
||||
const userTokenId = (decodedToken as JwtPayload).userToken;
|
||||
@@ -470,10 +448,7 @@ describe('userRoutes', () => {
|
||||
where: { id: userTokenId }
|
||||
});
|
||||
|
||||
await superRequest('/user/user-token', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
await superPost('/user/user-token');
|
||||
|
||||
// Verify that the old token has been deleted.
|
||||
expect(
|
||||
@@ -485,10 +460,7 @@ describe('userRoutes', () => {
|
||||
});
|
||||
|
||||
test('DELETE returns 200 status with null userToken', async () => {
|
||||
const response = await superRequest('/user/user-token', {
|
||||
method: 'DELETE',
|
||||
setCookies
|
||||
});
|
||||
const response = await superDelete('/user/user-token');
|
||||
|
||||
expect(response.body).toStrictEqual({ userToken: null });
|
||||
expect(response.status).toBe(200);
|
||||
@@ -496,15 +468,9 @@ describe('userRoutes', () => {
|
||||
});
|
||||
|
||||
test('DELETEing a missing userToken returns 404 status with an error message', async () => {
|
||||
await superRequest('/user/user-token', {
|
||||
method: 'DELETE',
|
||||
setCookies
|
||||
});
|
||||
await superDelete('/user/user-token');
|
||||
|
||||
const response = await superRequest('/user/user-token', {
|
||||
method: 'DELETE',
|
||||
setCookies
|
||||
});
|
||||
const response = await superDelete('/user/user-token');
|
||||
|
||||
expect(response.body).toStrictEqual({
|
||||
type: 'info',
|
||||
@@ -534,20 +500,14 @@ describe('userRoutes', () => {
|
||||
data: { username: '' }
|
||||
});
|
||||
|
||||
const response = await superRequest('/user/get-session-user', {
|
||||
method: 'GET',
|
||||
setCookies
|
||||
});
|
||||
const response = await superGet('/user/get-session-user');
|
||||
|
||||
expect(response.body).toStrictEqual({ user: {}, result: '' });
|
||||
expect(response.statusCode).toBe(500);
|
||||
});
|
||||
|
||||
test('GET returns username as the result property', async () => {
|
||||
const response = await superRequest('/user/get-session-user', {
|
||||
method: 'GET',
|
||||
setCookies
|
||||
});
|
||||
const response = await superGet('/user/get-session-user');
|
||||
|
||||
expect(response.body).toMatchObject({
|
||||
result: testUserData.username
|
||||
@@ -567,10 +527,7 @@ describe('userRoutes', () => {
|
||||
joinDate: new ObjectId(testUser?.id).getTimestamp().toISOString()
|
||||
};
|
||||
|
||||
const response = await superRequest('/user/get-session-user', {
|
||||
method: 'GET',
|
||||
setCookies
|
||||
});
|
||||
const response = await superGet('/user/get-session-user');
|
||||
const {
|
||||
user: { foobar }
|
||||
} = response.body as unknown as {
|
||||
@@ -597,10 +554,7 @@ describe('userRoutes', () => {
|
||||
const tokens = await fastifyTestInstance.prisma.userToken.count();
|
||||
expect(tokens).toBe(1);
|
||||
|
||||
const response = await superRequest('/user/get-session-user', {
|
||||
method: 'GET',
|
||||
setCookies
|
||||
});
|
||||
const response = await superGet('/user/get-session-user');
|
||||
|
||||
const { userToken } = jwt.decode(
|
||||
response.body.user.foobar.userToken
|
||||
@@ -625,7 +579,7 @@ describe('userRoutes', () => {
|
||||
|
||||
// devLogin must not be used here since it overrides the user
|
||||
const res = await superRequest('/auth/dev-callback', { method: 'GET' });
|
||||
setCookies = res.get('Set-Cookie');
|
||||
const setCookies = res.get('Set-Cookie');
|
||||
|
||||
const publicUser = {
|
||||
..._.omit(minimalUserData, ['externalId', 'unsubscribeId']),
|
||||
@@ -671,10 +625,7 @@ describe('userRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST returns 400 for empty username', async () => {
|
||||
const response = await superRequest('/user/report-user', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/user/report-user').send({
|
||||
username: '',
|
||||
reportDescription: 'Test Report'
|
||||
});
|
||||
@@ -687,10 +638,7 @@ describe('userRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST returns 400 for empty report', async () => {
|
||||
const response = await superRequest('/user/report-user', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/user/report-user').send({
|
||||
username: 'darth-vader',
|
||||
reportDescription: ''
|
||||
});
|
||||
@@ -703,10 +651,7 @@ describe('userRoutes', () => {
|
||||
});
|
||||
|
||||
test('POST sanitises report description', async () => {
|
||||
await superRequest('/user/report-user', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
await superPost('/user/report-user').send({
|
||||
username: 'darth-vader',
|
||||
reportDescription:
|
||||
'<script>const breath = "loud"</script>Luke, I am your father'
|
||||
@@ -728,10 +673,7 @@ describe('userRoutes', () => {
|
||||
where: { email: testUserData.email }
|
||||
}
|
||||
);
|
||||
const response = await superRequest('/user/report-user', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/user/report-user').send({
|
||||
username: 'darth-vader',
|
||||
reportDescription: 'Luke, I am your father'
|
||||
});
|
||||
@@ -786,10 +728,7 @@ Thanks and regards,
|
||||
]
|
||||
});
|
||||
|
||||
const response = await superRequest('/user/ms-username', {
|
||||
method: 'DELETE',
|
||||
setCookies
|
||||
});
|
||||
const response = await superDelete('/user/ms-username');
|
||||
|
||||
const msUsernames =
|
||||
await fastifyTestInstance.prisma.msUsername.count();
|
||||
@@ -807,10 +746,7 @@ Thanks and regards,
|
||||
]
|
||||
});
|
||||
|
||||
await superRequest('/user/ms-username', {
|
||||
method: 'DELETE',
|
||||
setCookies
|
||||
});
|
||||
await superDelete('/user/ms-username');
|
||||
|
||||
const msUsernames =
|
||||
await fastifyTestInstance.prisma.msUsername.count();
|
||||
@@ -835,10 +771,7 @@ Thanks and regards,
|
||||
});
|
||||
|
||||
it('handles missing transcript urls', async () => {
|
||||
const response = await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
});
|
||||
const response = await superPost('/user/ms-username');
|
||||
|
||||
expect(response.body).toStrictEqual({
|
||||
type: 'error',
|
||||
@@ -854,10 +787,7 @@ Thanks and regards,
|
||||
})
|
||||
);
|
||||
|
||||
const response = await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl: 'https://www.example.com'
|
||||
});
|
||||
|
||||
@@ -876,10 +806,7 @@ Thanks and regards,
|
||||
})
|
||||
);
|
||||
|
||||
const response = await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl: 'https://www.example.com'
|
||||
});
|
||||
|
||||
@@ -909,10 +836,7 @@ Thanks and regards,
|
||||
}
|
||||
});
|
||||
|
||||
const response = await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl: 'https://www.example.com'
|
||||
});
|
||||
|
||||
@@ -935,10 +859,7 @@ Thanks and regards,
|
||||
})
|
||||
})
|
||||
);
|
||||
const response = await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
const response = await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl: 'https://www.example.com'
|
||||
});
|
||||
|
||||
@@ -960,10 +881,7 @@ Thanks and regards,
|
||||
})
|
||||
);
|
||||
|
||||
await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl: 'https://www.example.com'
|
||||
});
|
||||
|
||||
@@ -1011,16 +929,10 @@ Thanks and regards,
|
||||
}
|
||||
});
|
||||
|
||||
await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl: 'https://www.example.com'
|
||||
});
|
||||
await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl: 'https://www.example.com'
|
||||
});
|
||||
|
||||
@@ -1038,10 +950,7 @@ Thanks and regards,
|
||||
const msTranscriptApiUrl =
|
||||
'https://learn.microsoft.com/api/profiles/transcript/share/8u6awert43q1plo';
|
||||
|
||||
await superRequest('/user/ms-username', {
|
||||
method: 'POST',
|
||||
setCookies
|
||||
}).send({
|
||||
await superPost('/user/ms-username').send({
|
||||
msTranscriptUrl
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user