@@ -17,6 +17,7 @@ import {
1717 backendHook ,
1818 setupCoreApp ,
1919 setupST ,
20+ loginWithAuth0 ,
2021} from "../helpers" ;
2122
2223import { TEST_CLIENT_BASE_URL , SIGN_IN_UP_API } from "../constants" ;
@@ -301,20 +302,11 @@ describe("getRedirectionURL Tests", function () {
301302 await page ?. close ( ) ;
302303 } ) ;
303304
304- it ( "should not do any redirection after successful sign up" , async function ( ) {
305- await Promise . all ( [
306- page . goto ( `${ TEST_CLIENT_BASE_URL } /auth?authRecipe=emailpassword` ) ,
307- page . waitForNavigation ( { waitUntil : "networkidle0" } ) ,
308- ] ) ;
309-
305+ it ( "Test that isNewUser is true when signing up" , async function ( ) {
310306 await toggleSignInSignUp ( page ) ;
311- const urlBeforeSignUp = await page . url ( ) ;
312307 await defaultSignUp ( page ) ;
313- const urlAfterSignUp = await page . url ( ) ;
314-
315308 const newUserCheck = await page . evaluate ( ( ) => localStorage . getItem ( "isNewUserCheck" ) ) ;
316309 assert . equal ( newUserCheck , "emailpassword-true" ) ;
317- assert . equal ( urlBeforeSignUp , urlAfterSignUp ) ;
318310 } ) ;
319311 } ) ;
320312
@@ -358,7 +350,7 @@ describe("getRedirectionURL Tests", function () {
358350 await page ?. close ( ) ;
359351 } ) ;
360352
361- it ( "should not do any redirection after successful sign up " , async function ( ) {
353+ it ( "Test that isNewUser is passed correctly " , async function ( ) {
362354 await Promise . all ( [
363355 page . goto ( `${ TEST_CLIENT_BASE_URL } /auth` ) ,
364356 page . waitForNavigation ( { waitUntil : "networkidle0" } ) ,
@@ -367,130 +359,16 @@ describe("getRedirectionURL Tests", function () {
367359 await submitForm ( page ) ;
368360 await waitForSTElement ( page , "[data-supertokens~=input][name=userInputCode]" ) ;
369361
370- const urlBeforeSignUp = await page . url ( ) ;
371-
372362 const loginAttemptInfo = JSON . parse (
373363 await page . evaluate ( ( ) => localStorage . getItem ( "supertokens-passwordless-loginAttemptInfo" ) )
374364 ) ;
375365 const device = await getPasswordlessDevice ( loginAttemptInfo ) ;
376366 await setInputValues ( page , [ { name : "userInputCode" , value : device . codes [ 0 ] . userInputCode } ] ) ;
377367 await submitForm ( page ) ;
378- // wait until network idle to ensure that the page has not been redirected
379- await page . waitForNetworkIdle ( ) ;
368+ await page . waitForSelector ( ".sessionInfo-user-id" ) ;
380369
381- const urlAfterSignUp = await page . url ( ) ;
382370 const newUserCheck = await page . evaluate ( ( ) => localStorage . getItem ( "isNewUserCheck" ) ) ;
383371 assert . equal ( newUserCheck , "passwordless-true" ) ;
384- assert . equal ( urlBeforeSignUp , urlAfterSignUp ) ;
385- } ) ;
386- } ) ;
387-
388- describe ( "ThirdPartyPasswordless recipe: Magic Link" , function ( ) {
389- const exampleEmail = "[email protected] " ; 390-
391- before ( async function ( ) {
392- let _isThirdPartyPasswordlessSupported = await isThirdPartyPasswordlessSupported ( ) ;
393- if ( ! _isThirdPartyPasswordlessSupported ) {
394- this . skip ( ) ;
395- }
396-
397- const coreUrl = await setupCoreApp ( {
398- coreConfig : {
399- passwordless_code_lifetime : 4000 ,
400- passwordless_max_code_input_attempts : 3 ,
401- } ,
402- } ) ;
403- await setupST ( {
404- coreUrl,
405- passwordlessFlowType : "MAGIC_LINK" ,
406- passwordlessContactMethod : "EMAIL" ,
407- } ) ;
408-
409- page = await browser . newPage ( ) ;
410- await clearBrowserCookiesWithoutAffectingConsole ( page , [ ] ) ;
411- // We need to set the localStorage value before the page loads to ensure ST initialises with the correct value
412- await page . evaluateOnNewDocument ( ( ) => {
413- localStorage . setItem ( "disableRedirectionAfterSuccessfulSignInUp" , "true" ) ;
414- localStorage . removeItem ( "isNewUserCheck" ) ;
415- } ) ;
416-
417- await Promise . all ( [
418- page . goto (
419- `${ TEST_CLIENT_BASE_URL } /auth?authRecipe=thirdpartypasswordless&passwordlessContactMethodType=EMAIL`
420- ) ,
421- page . waitForNavigation ( { waitUntil : "networkidle0" } ) ,
422- ] ) ;
423- } ) ;
424-
425- after ( async function ( ) {
426- await page ?. close ( ) ;
427- } ) ;
428-
429- it ( "should not do any redirection after successful sign up" , async function ( ) {
430- await Promise . all ( [
431- page . goto ( `${ TEST_CLIENT_BASE_URL } /auth` ) ,
432- page . waitForNavigation ( { waitUntil : "networkidle0" } ) ,
433- ] ) ;
434- await setInputValues ( page , [ { name : "email" , value : exampleEmail } ] ) ;
435- await submitForm ( page ) ;
436- await waitForSTElement ( page , "[data-supertokens~=sendCodeIcon]" ) ;
437-
438- const loginAttemptInfo = JSON . parse (
439- await page . evaluate ( ( ) => localStorage . getItem ( "supertokens-passwordless-loginAttemptInfo" ) )
440- ) ;
441- const device = await getPasswordlessDevice ( loginAttemptInfo ) ;
442-
443- const magicLink = device . codes [ 0 ] . urlWithLinkCode ;
444-
445- await page . goto ( magicLink ) ;
446- await page . waitForNetworkIdle ( ) ;
447-
448- const urlAfterSignUp = await page . url ( ) ;
449- const newUserCheck = await page . evaluate ( ( ) => localStorage . getItem ( "isNewUserCheck" ) ) ;
450- assert . equal ( newUserCheck , "thirdpartypasswordless-true" ) ;
451- assert . equal ( magicLink , urlAfterSignUp ) ;
452- } ) ;
453- } ) ;
454-
455- describe ( "ThirdParty Recipe" , function ( ) {
456- before ( async function ( ) {
457- const coreUrl = await setupCoreApp ( ) ;
458- await setupST ( { coreUrl } ) ;
459-
460- page = await browser . newPage ( ) ;
461- // We need to set the localStorage value before the page loads to ensure ST initialises with the correct value
462- await page . evaluateOnNewDocument ( ( ) => {
463- localStorage . setItem ( "disableRedirectionAfterSuccessfulSignInUp" , "true" ) ;
464- localStorage . removeItem ( "isNewUserCheck" ) ;
465- } ) ;
466-
467- await clearBrowserCookiesWithoutAffectingConsole ( page , [ ] ) ;
468- } ) ;
469-
470- after ( async function ( ) {
471- await page ?. close ( ) ;
472- } ) ;
473-
474- it ( "should not do any redirection after successful sign up" , async function ( ) {
475- await Promise . all ( [
476- page . goto ( `${ TEST_CLIENT_BASE_URL } /auth?authRecipe=thirdparty` ) ,
477- page . waitForNavigation ( { waitUntil : "networkidle0" } ) ,
478- ] ) ;
479-
480- await assertProviders ( page ) ;
481- await clickOnProviderButton ( page , "Mock Provider" ) ;
482-
483- await Promise . all ( [
484- loginWithMockProvider ( page ) ,
485- page . waitForResponse (
486- ( response ) => response . url ( ) === SIGN_IN_UP_API && response . status ( ) === 200
487- ) ,
488- ] ) ;
489-
490- const urlAfterSignUp = await page . url ( ) ;
491- const newUserCheck = await page . evaluate ( ( ) => localStorage . getItem ( "isNewUserCheck" ) ) ;
492- assert . equal ( newUserCheck , "thirdparty-true" ) ;
493- assert ( urlAfterSignUp . includes ( "/auth/callback/mock-provider" ) ) ;
494372 } ) ;
495373 } ) ;
496374 } ) ;
0 commit comments