mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 15:03:52 +00:00
tests
This commit is contained in:
@@ -4,7 +4,10 @@ describe("register", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||||
data: {
|
data: {
|
||||||
result: [{ id: "123" }],
|
details: {
|
||||||
|
totalResult: 1,
|
||||||
|
},
|
||||||
|
result: [{ id: "256088834543534543" }],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
stub("zitadel.user.v2.UserService", "AddHumanUser", {
|
stub("zitadel.user.v2.UserService", "AddHumanUser", {
|
||||||
|
|||||||
@@ -1,42 +1,62 @@
|
|||||||
import { stub } from "../support/mock";
|
import { stub } from "../support/mock";
|
||||||
|
|
||||||
describe("/verify", () => {
|
beforeEach(() => {
|
||||||
it("shows authenticators after successful invite verification", () => {
|
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||||
stub("zitadel.user.v2.UserService", "VerifyInviteCode");
|
data: {
|
||||||
cy.visit("/verify?userId=123&code=abc&submit=true&invite=true");
|
details: {
|
||||||
cy.location("pathname", { timeout: 10000 }).should(
|
totalResult: 1,
|
||||||
"eq",
|
},
|
||||||
"/authenticator/set",
|
result: [{ id: "256088834543534543" }],
|
||||||
);
|
},
|
||||||
});
|
|
||||||
it("shows an error if invite code validation failed", () => {
|
|
||||||
stub("zitadel.user.v2.UserService", "VerifyInviteCode", {
|
|
||||||
code: 3,
|
|
||||||
error: "error validating code",
|
|
||||||
});
|
|
||||||
// TODO: Avoid uncaught exception in application
|
|
||||||
cy.once("uncaught:exception", () => false);
|
|
||||||
cy.visit("/verify?userId=123&code=abc&submit=true&invite=true");
|
|
||||||
cy.contains("Could not verify invite", { timeout: 10000 });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows password and passkey method after successful invite verification", () => {
|
stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
||||||
stub("zitadel.user.v2.UserService", "VerifyEmail");
|
data: {
|
||||||
cy.visit("/verify?userId=123&code=abc&submit=true");
|
authMethodTypes: [],
|
||||||
cy.location("pathname", { timeout: 10000 }).should(
|
},
|
||||||
"eq",
|
|
||||||
"/authenticator/set",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows an error if invite code validation failed", () => {
|
describe("verify invite", () => {
|
||||||
stub("zitadel.user.v2.UserService", "VerifyEmail", {
|
it.only("shows authenticators after successful invite verification", () => {
|
||||||
code: 3,
|
stub("zitadel.user.v2.UserService", "VerifyInviteCode");
|
||||||
error: "error validating code",
|
cy.visit("/verify?userId=123&code=abc&invite=true");
|
||||||
|
cy.location("pathname", { timeout: 10_000 }).should(
|
||||||
|
"eq",
|
||||||
|
"/authenticator/set",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows an error if invite code validation failed", () => {
|
||||||
|
stub("zitadel.user.v2.UserService", "VerifyInviteCode", {
|
||||||
|
code: 3,
|
||||||
|
error: "error validating code",
|
||||||
|
});
|
||||||
|
// TODO: Avoid uncaught exception in application
|
||||||
|
cy.once("uncaught:exception", () => false);
|
||||||
|
cy.visit("/verify?userId=123&code=abc&invite=true");
|
||||||
|
cy.contains("Could not verify invite", { timeout: 10_000 });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("verify email", () => {
|
||||||
|
it("shows password and passkey method after successful invite verification", () => {
|
||||||
|
stub("zitadel.user.v2.UserService", "VerifyEmail");
|
||||||
|
cy.visit("/verify?userId=123&code=abc");
|
||||||
|
cy.location("pathname", { timeout: 10_000 }).should(
|
||||||
|
"eq",
|
||||||
|
"/authenticator/set",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows an error if invite code validation failed", () => {
|
||||||
|
stub("zitadel.user.v2.UserService", "VerifyEmail", {
|
||||||
|
code: 3,
|
||||||
|
error: "error validating code",
|
||||||
|
});
|
||||||
|
// TODO: Avoid uncaught exception in application
|
||||||
|
cy.once("uncaught:exception", () => false);
|
||||||
|
cy.visit("/verify?userId=123&code=abc&submit=true");
|
||||||
|
cy.contains("Could not verify email", { timeout: 10_000 });
|
||||||
});
|
});
|
||||||
// TODO: Avoid uncaught exception in application
|
|
||||||
cy.once("uncaught:exception", () => false);
|
|
||||||
cy.visit("/verify?userId=123&code=abc&submit=true");
|
|
||||||
cy.contains("Could not verify email", { timeout: 10000 });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getLegalAndSupportSettings,
|
getLegalAndSupportSettings,
|
||||||
getPasswordComplexitySettings,
|
getPasswordComplexitySettings,
|
||||||
} from "@/lib/zitadel";
|
} from "@/lib/zitadel";
|
||||||
|
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
|
||||||
import { getLocale, getTranslations } from "next-intl/server";
|
import { getLocale, getTranslations } from "next-intl/server";
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
@@ -21,11 +22,16 @@ export default async function Page({
|
|||||||
searchParams;
|
searchParams;
|
||||||
|
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
const org = await getDefaultOrg();
|
const org: Organization | void = await getDefaultOrg().catch((error) => {
|
||||||
|
console.log("err");
|
||||||
|
});
|
||||||
if (!org) {
|
if (!org) {
|
||||||
|
console.log("no default organization");
|
||||||
throw new Error("No default organization found");
|
throw new Error("No default organization found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("org", org);
|
||||||
|
|
||||||
organization = org.id;
|
organization = org.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,10 @@ export function RegisterFormWithoutPassword({
|
|||||||
variant={ButtonVariants.Primary}
|
variant={ButtonVariants.Primary}
|
||||||
disabled={loading || !formState.isValid || !tosAndPolicyAccepted}
|
disabled={loading || !formState.isValid || !tosAndPolicyAccepted}
|
||||||
onClick={handleSubmit((values) =>
|
onClick={handleSubmit((values) =>
|
||||||
submitAndContinue(values, selected === methods[0] ? false : true),
|
submitAndContinue(
|
||||||
|
values,
|
||||||
|
selected.name === methods[0].name ? false : true,
|
||||||
|
),
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{loading && <Spinner className="h-5 w-5 mr-2" />}
|
{loading && <Spinner className="h-5 w-5 mr-2" />}
|
||||||
|
|||||||
Reference in New Issue
Block a user