Skip to content

Commit b3d1b20

Browse files
committed
fix: broken tests, update configs
1 parent 1b174bd commit b3d1b20

15 files changed

+364
-220
lines changed

.mocharc.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
spec:
22
- test/end-to-end/**/*.test.js
33
slow: 20000
4-
timeout: 30000
4+
timeout: 40000
55
exit: true
6-
reporter: mochawesome
7-
reporter-option:
8-
- "reportDir=test_report/mochawesome"
96
require:
107
- "@babel/register"
118
- test/test.mocha.env
9+
reporter: mocha-multi-reporters
10+
reporter-option:
11+
- configFile=mocha-multi-reporters.json

mocha-multi-reporters.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"reporterEnabled": "mochawesome, mocha-junit-reporter",
3+
"mochaJunitReporterReporterOptions": {
4+
"mochaFile": "test_report/test-results.xml"
5+
},
6+
"mochawesomeReporterOptions": {
7+
"reportDir": "test_report/mochawesome"
8+
}
9+
}

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"mocha": "^10.2.0",
6262
"mocha-junit-reporter": "^2.2.1",
6363
"mocha-multi": "^1.1.7",
64+
"mocha-multi-reporters": "^1.5.1",
6465
"mocha-split-tests": "github:rishabhpoddar/mocha-split-tests",
6566
"mochawesome": "^7.1.3",
6667
"npm-run-all": "^4.1.5",

test/end-to-end/mfa.factorscreen.totp.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
112112
let email, phoneNumber;
113113
before(async () => {
114114
await setupST({
115+
...appConfig,
115116
mfaInfo: {
116117
allowedToSetup: ["totp"],
117118
}
@@ -140,6 +141,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
140141

141142
it("should respect redirectToPath", async () => {
142143
await setupST({
144+
...appConfig,
143145
mfaInfo: {
144146
requirements: [],
145147
alreadySetup: [factorId],
@@ -165,6 +167,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
165167

166168
it("should show access denied if the app navigates to the setup page but the user it is not allowed to set up the factor", async () => {
167169
await setupST({
170+
...appConfig,
168171
mfaInfo: {
169172
requirements: [],
170173
alreadySetup: [factorId],
@@ -184,6 +187,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
184187

185188
it("should show access denied if setup is not allowed but the factor is not set up", async () => {
186189
await setupST({
190+
...appConfig,
187191
mfaInfo: {
188192
requirements: [factorId],
189193
alreadySetup: [],
@@ -202,6 +206,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
202206

203207
it("should show loading screen", async () => {
204208
await setupST({
209+
...appConfig,
205210
mfaInfo: {
206211
requirements: [factorId],
207212
alreadySetup: [factorId],
@@ -235,6 +240,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
235240

236241
it("should show blocked screen after too many retries", async () => {
237242
await setupST({
243+
...appConfig,
238244
mfaInfo: {
239245
requirements: [factorId],
240246
alreadySetup: [factorId],
@@ -251,6 +257,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
251257

252258
it("should handle mfa info api failures gracefully", async () => {
253259
await setupST({
260+
...appConfig,
254261
mfaInfo: {
255262
requirements: [factorId],
256263
alreadySetup: [factorId],
@@ -292,6 +299,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
292299

293300
it("should handle createDevice failures gracefully", async () => {
294301
await setupST({
302+
...appConfig,
295303
mfaInfo: {
296304
requirements: [factorId],
297305
alreadySetup: [],
@@ -328,6 +336,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
328336

329337
it("should redirect back if visited after sign in without stepUp param", async () => {
330338
await setupST({
339+
...appConfig,
331340
mfaInfo: {
332341
requirements: [],
333342
alreadySetup: [factorId],
@@ -346,6 +355,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
346355

347356
it("should show a link redirecting back if visited after sign in - force setup", async () => {
348357
await setupST({
358+
...appConfig,
349359
mfaInfo: {
350360
requirements: [],
351361
alreadySetup: [factorId],
@@ -366,6 +376,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
366376

367377
it("should show a link redirecting back if visited after sign in - setup in stepUp", async () => {
368378
await setupST({
379+
...appConfig,
369380
mfaInfo: {
370381
requirements: [],
371382
alreadySetup: [],
@@ -386,6 +397,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
386397

387398
it("should show a link redirecting back if visited after sign in - verification in stepUp", async () => {
388399
await setupST({
400+
...appConfig,
389401
mfaInfo: {
390402
requirements: [],
391403
alreadySetup: [factorId],
@@ -406,6 +418,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
406418

407419
it("should show a back button redirecting to the chooser screen if other options are available during sign in - setup", async () => {
408420
await setupST({
421+
...appConfig,
409422
mfaInfo: {
410423
requirements: [{ oneOf: [factorId, "otp-email"] }],
411424
alreadySetup: ["otp-email"],
@@ -427,6 +440,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
427440

428441
it("should show a back button redirecting to the chooser screen if other options are available during sign in - verification", async () => {
429442
await setupST({
443+
...appConfig,
430444
mfaInfo: {
431445
requirements: [{ oneOf: [factorId, "otp-email"] }],
432446
alreadySetup: [factorId, "otp-email"],
@@ -447,6 +461,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
447461

448462
it("should show a logout link - setup", async () => {
449463
await setupST({
464+
...appConfig,
450465
mfaInfo: {
451466
requirements: [factorId],
452467
alreadySetup: [],
@@ -468,6 +483,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
468483

469484
it("should show a logout link - verify", async () => {
470485
await setupST({
486+
...appConfig,
471487
mfaInfo: {
472488
requirements: [factorId],
473489
alreadySetup: [factorId],

test/end-to-end/mfa.helpers.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ export async function setupUserWithAllFactors(page) {
4747
const totpSecret = await setupTOTP(page);
4848
return { email, phoneNumber, totpSecret };
4949
}
50-
export async function setMFAInfo(mfaInfo) {
51-
let resp = await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/setMFAInfo`, {
52-
method: "POST",
53-
headers: new Headers([["content-type", "application/json"]]),
54-
body: JSON.stringify(mfaInfo),
55-
});
56-
assert.strictEqual(resp.status, 200);
57-
}
5850

5951
export async function addToRequiredSecondaryFactorsForUser(page, factorId) {
6052
await page.evaluate(

test/end-to-end/mfa.requirement_handling.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
import { TEST_CLIENT_BASE_URL } from "../constants";
3333
import { getTestPhoneNumber } from "../exampleTestHelpers";
3434
import {
35-
setMFAInfo,
3635
tryEmailPasswordSignUp,
3736
waitForDashboard,
3837
completeOTP,

test/end-to-end/mfa.signin.test.js

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ describe("SuperTokens SignIn w/ MFA", function () {
113113
it("sign in with email-otp (auto-setup)", async function () {
114114
const email = await getTestEmail();
115115

116-
appConfig.mfaInfo = {
117-
requirements: ["otp-email"],
118-
};
119-
setupST(appConfig);
116+
setupST({
117+
...appConfig,
118+
mfaInfo: {
119+
requirements: ["otp-email"],
120+
}
121+
});
120122

121123
await tryEmailPasswordSignUp(page, email);
122124

@@ -137,10 +139,12 @@ describe("SuperTokens SignIn w/ MFA", function () {
137139
const email = await getTestEmail();
138140
const phoneNumber = getTestPhoneNumber();
139141

140-
appConfig.mfaInfo = {
141-
requirements: [{ oneOf: ["otp-email", "otp-phone"] }],
142-
};
143-
setupST(appConfig);
142+
setupST({
143+
...appConfig,
144+
mfaInfo: {
145+
requirements: [{ oneOf: ["otp-email", "otp-phone"] }],
146+
},
147+
});
144148

145149
await tryEmailPasswordSignUp(page, email);
146150
await chooseFactor(page, "otp-phone");
@@ -159,10 +163,12 @@ describe("SuperTokens SignIn w/ MFA", function () {
159163
});
160164

161165
it("set up otp-email and sign-in", async function () {
162-
appConfig.mfaInfo = {
163-
requirements: [],
164-
};
165-
setupST(appConfig);
166+
setupST({
167+
...appConfig,
168+
mfaInfo: {
169+
requirements: [],
170+
},
171+
});
166172
const email = await getTestEmail();
167173
const phoneNumber = getTestPhoneNumber();
168174

@@ -173,10 +179,12 @@ describe("SuperTokens SignIn w/ MFA", function () {
173179

174180
await logout(page);
175181

176-
appConfig.mfaInfo = {
177-
requirements: [{ oneOf: ["otp-email"] }],
178-
};
179-
setupST(appConfig);
182+
setupST({
183+
...appConfig,
184+
mfaInfo: {
185+
requirements: [{ oneOf: ["otp-email"] }],
186+
},
187+
});
180188

181189
await tryPasswordlessSignInUp(page, phoneNumber, undefined, true);
182190

@@ -195,16 +203,20 @@ describe("SuperTokens SignIn w/ MFA", function () {
195203
});
196204

197205
it("set up totp and sign-in", async function () {
198-
appConfig.mfaInfo = {
199-
requirements: [],
200-
};
201-
setupST(appConfig);
206+
setupST({
207+
...appConfig,
208+
mfaInfo: {
209+
requirements: [],
210+
},
211+
});
202212
const email = await getTestEmail();
203213

204-
appConfig.mfaInfo = {
205-
requirements: [{ oneOf: ["otp-email", "totp"] }],
206-
};
207-
setupST(appConfig);
214+
setupST({
215+
...appConfig,
216+
mfaInfo: {
217+
requirements: [{ oneOf: ["otp-email", "totp"] }],
218+
},
219+
});
208220

209221
await tryEmailPasswordSignUp(page, email);
210222
await chooseFactor(page, "otp-email");
@@ -233,21 +245,25 @@ describe("SuperTokens SignIn w/ MFA", function () {
233245

234246
it("should show access denied if the only next option is an unknown factor id", async () => {
235247
const email = await getTestEmail();
236-
appConfig.mfaInfo = {
237-
requirements: ["unknown"],
238-
alreadySetup: ["unknown"],
239-
};
240-
setupST(appConfig);
248+
setupST({
249+
...appConfig,
250+
mfaInfo: {
251+
requirements: ["unknown"],
252+
alreadySetup: ["unknown"],
253+
},
254+
});
241255

242256
await tryEmailPasswordSignUp(page, email);
243257
await waitForAccessDenied(page);
244258
});
245259

246260
it("should throw error if there are no valid next options", async () => {
247-
appConfig.mfaInfo = {
248-
requirements: ["unknown"],
249-
};
250-
setupST(appConfig);
261+
setupST({
262+
...appConfig,
263+
mfaInfo: {
264+
requirements: ["unknown"],
265+
},
266+
});
251267

252268
const email = await getTestEmail();
253269
await expectErrorThrown(page, () => tryEmailPasswordSignUp(page, email));

0 commit comments

Comments
 (0)