-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update version and include e2e tests
- Loading branch information
Showing
10 changed files
with
190 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,7 +200,6 @@ describe("getRedirectionURL Tests", function () { | |
if (!_isPasswordlessSupported) { | ||
didSkip = true; | ||
this.skip(); | ||
return; | ||
} | ||
|
||
await backendBeforeEach(); | ||
|
@@ -287,7 +286,6 @@ describe("getRedirectionURL Tests", function () { | |
if (!_isThirdPartyPasswordlessSupported) { | ||
didSkip = true; | ||
this.skip(); | ||
return; | ||
} | ||
|
||
await backendBeforeEach(); | ||
|
@@ -377,5 +375,152 @@ describe("getRedirectionURL Tests", function () { | |
assert.equal(newUserCheck, "thirdpartypasswordless-true"); | ||
}); | ||
}); | ||
|
||
describe("No Redirection", function () { | ||
describe("Email Password Recipe", function () { | ||
let browser; | ||
let page; | ||
|
||
before(async function () { | ||
await backendBeforeEach(); | ||
|
||
await fetch(`${TEST_SERVER_BASE_URL}/startst`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
|
||
browser = await puppeteer.launch({ | ||
args: ["--no-sandbox", "--disable-setuid-sandbox"], | ||
headless: true, | ||
}); | ||
|
||
page = await browser.newPage(); | ||
// We need to set the localStorage value before the page loads to ensure ST initialises with the correct value | ||
await page.evaluateOnNewDocument(() => { | ||
localStorage.setItem("disableRedirectionAfterSuccessfulSignInUp", "true"); | ||
localStorage.removeItem("isNewUserCheck"); | ||
}); | ||
|
||
await clearBrowserCookiesWithoutAffectingConsole(page, []); | ||
}); | ||
|
||
after(async function () { | ||
await browser.close(); | ||
await fetch(`${TEST_SERVER_BASE_URL}/after`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
|
||
await screenshotOnFailure(this, browser); | ||
}); | ||
|
||
it("should not do any redirection after successful sign up", async function () { | ||
await Promise.all([ | ||
page.goto(`${TEST_CLIENT_BASE_URL}/auth?authRecipe=emailpassword`), | ||
page.waitForNavigation({ waitUntil: "networkidle0" }), | ||
]); | ||
|
||
await toggleSignInSignUp(page); | ||
const urlBeforeSignUp = await page.url(); | ||
await defaultSignUp(page); | ||
const urlAfterSignUp = await page.url(); | ||
|
||
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck")); | ||
assert.equal(newUserCheck, "emailpassword-true"); | ||
assert.equal(urlBeforeSignUp, urlAfterSignUp); | ||
}); | ||
}); | ||
|
||
describe("Passwordless recipe", function () { | ||
let browser; | ||
let page; | ||
const exampleEmail = "[email protected]"; | ||
// Mocha calls cleanup functions even if the test block is skipped, this helps skipping the after block | ||
let didSkip = false; | ||
|
||
before(async function () { | ||
let _isPasswordlessSupported = await isPasswordlessSupported(); | ||
if (!_isPasswordlessSupported) { | ||
didSkip = true; | ||
this.skip(); | ||
} | ||
|
||
await backendBeforeEach(); | ||
|
||
await fetch(`${TEST_SERVER_BASE_URL}/startst`, { | ||
method: "POST", | ||
headers: [["content-type", "application/json"]], | ||
body: JSON.stringify({ | ||
coreConfig: { | ||
passwordless_code_lifetime: 4000, | ||
passwordless_max_code_input_attempts: 3, | ||
}, | ||
}), | ||
}).catch(console.error); | ||
|
||
browser = await puppeteer.launch({ | ||
args: ["--no-sandbox", "--disable-setuid-sandbox"], | ||
headless: true, | ||
}); | ||
page = await browser.newPage(); | ||
// We need to set the localStorage value before the page loads to ensure ST initialises with the correct value | ||
await page.evaluateOnNewDocument(() => { | ||
localStorage.setItem("disableRedirectionAfterSuccessfulSignInUp", "true"); | ||
localStorage.removeItem("isNewUserCheck"); | ||
}); | ||
await clearBrowserCookiesWithoutAffectingConsole(page, []); | ||
await Promise.all([ | ||
page.goto( | ||
`${TEST_CLIENT_BASE_URL}/auth?authRecipe=passwordless&passwordlessContactMethodType=EMAIL` | ||
), | ||
page.waitForNavigation({ waitUntil: "networkidle0" }), | ||
]); | ||
await setPasswordlessFlowType("EMAIL", "USER_INPUT_CODE"); | ||
}); | ||
|
||
after(async function () { | ||
// Dont cleanup if tests were skipped | ||
if (didSkip) { | ||
return; | ||
} | ||
await browser.close(); | ||
await fetch(`${TEST_SERVER_BASE_URL}/after`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
|
||
return screenshotOnFailure(this, browser); | ||
}); | ||
|
||
it("should not do any redirection after successful sign up", async function () { | ||
await Promise.all([ | ||
page.goto(`${TEST_CLIENT_BASE_URL}/auth`), | ||
page.waitForNavigation({ waitUntil: "networkidle0" }), | ||
]); | ||
await setInputValues(page, [{ name: "email", value: exampleEmail }]); | ||
await submitForm(page); | ||
await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]"); | ||
|
||
const urlBeforeSignUp = await page.url(); | ||
|
||
const loginAttemptInfo = JSON.parse( | ||
await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo")) | ||
); | ||
const device = await getPasswordlessDevice(loginAttemptInfo); | ||
await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]); | ||
await submitForm(page); | ||
// wait until network idle to ensure that the page has not been redirected | ||
await page.waitForNetworkIdle(); | ||
|
||
const urlAfterSignUp = await page.url(); | ||
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck")); | ||
assert.equal(newUserCheck, "passwordless-true"); | ||
assert.equal(urlBeforeSignUp, urlAfterSignUp); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters