From e721eae7e2797540d1fb16b3aaddbb2c244a9aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Lengyel?= Date: Fri, 4 Oct 2024 18:53:06 +0200 Subject: [PATCH] feat: expand the missing ui error message to provide more info on common errors (#860) * feat: expand the missing ui error message to provide more info on common errors * test: fix react 16 tests * feat: expand the error message a bit more --- CHANGELOG.md | 1 + lib/build/index2.js | 4 +++- .../authRecipe/components/feature/authPage/authPage.tsx | 4 +++- test/end-to-end/signin-rrdv5.test.js | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b9b2029b..53300a251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added the `OAuth2Provider` recipe - Changed the input types and default implementation of `AuthPageHeader` to show the client information in OAuth2 flows +- Expanded an error message in `AuthPage` to help with common errors ### Breaking changes diff --git a/lib/build/index2.js b/lib/build/index2.js index bc16a1368..5acf21394 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -1524,7 +1524,9 @@ function buildAndSetChildProps( "Couldn't cover all first factors: " .concat(firstFactors.join(", "), " (from ") .concat(source, "), available components: ") - .concat(Array.from(availableFactors).join(", ")) + .concat(Array.from(availableFactors).join(", "), ".\n") + + "You may have missed adding a recipe into the list of prebuiltUIs passed to list of prebuiltUIs passed to getSuperTokensRoutesForReactRouterDom, canHandleRoute, handleRoute functions or the AuthPage component.\n" + + "Another common error is adding a non-existent factor id into the list, e.g.: passwordless instead of otp-email/phone" ); } setComponentListInfo({ diff --git a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx index 5b4e2fbb4..9027d10b8 100644 --- a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx +++ b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx @@ -569,7 +569,9 @@ async function buildAndSetChildProps( throw new Error( `Couldn't cover all first factors: ${firstFactors.join( ", " - )} (from ${source}), available components: ${Array.from(availableFactors).join(", ")}` + )} (from ${source}), available components: ${Array.from(availableFactors).join(", ")}.\n` + + "You may have missed adding a recipe into the list of prebuiltUIs passed to list of prebuiltUIs passed to getSuperTokensRoutesForReactRouterDom, canHandleRoute, handleRoute functions or the AuthPage component.\n" + + "Another common error is adding a non-existent factor id into the list, e.g.: passwordless instead of otp-email/phone" ); } diff --git a/test/end-to-end/signin-rrdv5.test.js b/test/end-to-end/signin-rrdv5.test.js index c8fefef68..97fc6c666 100644 --- a/test/end-to-end/signin-rrdv5.test.js +++ b/test/end-to-end/signin-rrdv5.test.js @@ -191,7 +191,7 @@ describe("SuperTokens SignIn with react router dom v5", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john@gmail.com"},{"id":"password","value":"********"}]}' + '{"formFields":[{"id":"email","value":"john@gmail.com"},{"id":"password","value":"********"}],"shouldTryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "WRONG_CREDENTIALS_ERROR"); @@ -272,7 +272,7 @@ describe("SuperTokens SignIn with react router dom v5", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}]}' + '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}],"shouldTryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "OK");