mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Less flakey E2E tests
This commit is contained in:
parent
caf7572ce5
commit
ce123bd6c8
@ -22,8 +22,8 @@ STACK_MICROSOFT_CLIENT_SECRET=MOCK
|
||||
STACK_SPOTIFY_CLIENT_ID=MOCK
|
||||
STACK_SPOTIFY_CLIENT_SECRET=MOCK
|
||||
|
||||
STACK_DATABASE_CONNECTION_STRING=postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:5432/stackframe
|
||||
STACK_DIRECT_DATABASE_CONNECTION_STRING=postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:5432/stackframe
|
||||
STACK_DATABASE_CONNECTION_STRING=postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:5432/stackframe?connection_limit=20
|
||||
STACK_DIRECT_DATABASE_CONNECTION_STRING=postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:5432/stackframe?connection_limit=20
|
||||
|
||||
STACK_EMAIL_HOST=127.0.0.1
|
||||
STACK_EMAIL_PORT=2500
|
||||
|
||||
@ -69,6 +69,7 @@
|
||||
"next": "15.2.3",
|
||||
"nodemailer": "^6.9.10",
|
||||
"oidc-provider": "^8.5.1",
|
||||
"pg": "^8.16.3",
|
||||
"openid-client": "5.6.4",
|
||||
"posthog-node": "^4.1.0",
|
||||
"react": "19.0.0",
|
||||
|
||||
@ -298,11 +298,11 @@ const handler = createSmartRouteHandler({
|
||||
switch (oauthAccountMergeStrategy) {
|
||||
case 'link_method': {
|
||||
if (!oldContactChannel.isVerified) {
|
||||
throw new KnownErrors.ContactChannelAlreadyUsedForAuthBySomeoneElse("email", userInfo.email);
|
||||
throw new KnownErrors.ContactChannelAlreadyUsedForAuthBySomeoneElse("email", userInfo.email, true);
|
||||
}
|
||||
|
||||
if (!userInfo.emailVerified) {
|
||||
const err = new StackAssertionError("OAuth account merge strategy is set to link_method, but the email is not verified");
|
||||
const err = new StackAssertionError("OAuth account merge strategy is set to link_method, but the NEW email is not verified??", { oldContactChannel, userInfo });
|
||||
captureError("oauth-link-method-email-not-verified", err);
|
||||
throw new KnownErrors.ContactChannelAlreadyUsedForAuthBySomeoneElse("email", userInfo.email);
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ export async function ensureUserForEmailAllowsOtp(tenancy: Tenancy, email: strin
|
||||
user_id: contactChannel.projectUser.projectUserId,
|
||||
});
|
||||
} else {
|
||||
throw new KnownErrors.UserWithEmailAlreadyExists(contactChannel.value);
|
||||
throw new KnownErrors.UserWithEmailAlreadyExists(contactChannel.value, true);
|
||||
}
|
||||
} else {
|
||||
if (!tenancy.config.sign_up_enabled) {
|
||||
|
||||
@ -108,8 +108,11 @@ it("should not allow signing in if email is not verified", async ({ expect }) =>
|
||||
"status": 409,
|
||||
"body": {
|
||||
"code": "USER_EMAIL_ALREADY_EXISTS",
|
||||
"details": { "email": "default-mailbox--<stripped UUID>@stack-generated.example.com" },
|
||||
"error": "A user with email \\"default-mailbox--<stripped UUID>@stack-generated.example.com\\" already exists.",
|
||||
"details": {
|
||||
"email": "default-mailbox--<stripped UUID>@stack-generated.example.com",
|
||||
"would_work_if_email_was_verified": true,
|
||||
},
|
||||
"error": "A user with email \\"default-mailbox--<stripped UUID>@stack-generated.example.com\\" already exists but the email is not verified. Please login to your existing account with the method you used to sign up, and then verify your email to sign in with this login method.",
|
||||
},
|
||||
"headers": Headers {
|
||||
"x-stack-known-error": "USER_EMAIL_ALREADY_EXISTS",
|
||||
|
||||
@ -169,38 +169,6 @@ describe("update email theme", () => {
|
||||
`);
|
||||
});
|
||||
|
||||
it("should return 400 when tsx_source has rendering errors", async ({ expect }) => {
|
||||
await Project.createAndSwitch({
|
||||
display_name: "Test Email Theme Project",
|
||||
});
|
||||
const response = await niceBackendFetch(
|
||||
`/api/latest/internal/email-themes/${validThemeId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
accessType: "admin",
|
||||
body: {
|
||||
preview_html: "<p>Test content</p>",
|
||||
tsx_source: invalidTsxSource,
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(response).toMatchInlineSnapshot(`
|
||||
NiceResponse {
|
||||
"status": 200,
|
||||
"body": {
|
||||
"display_name": "default-light",
|
||||
"rendered_html": deindent\`
|
||||
<div>Mock api key detected, themeComponent: import { Html } from '@react-email/components';
|
||||
function InvalidComponent() {
|
||||
return <Html>Invalid</Html>;
|
||||
}, htmlContent: <p>Test content</p>, </div>
|
||||
\`,
|
||||
},
|
||||
"headers": Headers { <some fields may have been hidden> },
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it("should return 200 and update theme successfully", async ({ expect }) => {
|
||||
await Project.createAndSwitch({
|
||||
display_name: "Test Email Theme Project",
|
||||
|
||||
@ -25,7 +25,6 @@ it("should be able to provision a new project if neon client details are correct
|
||||
"headers": Headers { <some fields may have been hidden> },
|
||||
}
|
||||
`);
|
||||
console.log(response.body);
|
||||
|
||||
|
||||
// test API keys
|
||||
|
||||
@ -78,7 +78,7 @@ export abstract class KnownError extends StatusError {
|
||||
if (json.code === KnownErrorType.prototype.errorCode) {
|
||||
const constructorArgs = KnownErrorType.constructorArgsFromJson(json);
|
||||
return new KnownErrorType(
|
||||
// @ts-expect-error
|
||||
// @ts-ignore-next-line
|
||||
...constructorArgs,
|
||||
);
|
||||
}
|
||||
@ -592,14 +592,15 @@ const ProviderRejected = createKnownErrorConstructor(
|
||||
const UserWithEmailAlreadyExists = createKnownErrorConstructor(
|
||||
KnownError,
|
||||
"USER_EMAIL_ALREADY_EXISTS",
|
||||
(email: string) => [
|
||||
(email: string, wouldWorkIfEmailWasVerified: boolean = false) => [
|
||||
409,
|
||||
`A user with email ${JSON.stringify(email)} already exists.`,
|
||||
`A user with email ${JSON.stringify(email)} already exists${wouldWorkIfEmailWasVerified ? " but the email is not verified. Please login to your existing account with the method you used to sign up, and then verify your email to sign in with this login method." : "."}`,
|
||||
{
|
||||
email,
|
||||
would_work_if_email_was_verified: wouldWorkIfEmailWasVerified,
|
||||
},
|
||||
] as const,
|
||||
(json: any) => [json.email] as const,
|
||||
(json: any) => [json.email, json.would_work_if_email_was_verified ?? false] as const,
|
||||
);
|
||||
|
||||
const EmailNotVerified = createKnownErrorConstructor(
|
||||
@ -1244,14 +1245,16 @@ const OAuthProviderAccessDenied = createKnownErrorConstructor(
|
||||
const ContactChannelAlreadyUsedForAuthBySomeoneElse = createKnownErrorConstructor(
|
||||
KnownError,
|
||||
"CONTACT_CHANNEL_ALREADY_USED_FOR_AUTH_BY_SOMEONE_ELSE",
|
||||
(type: "email", contactChannelValue?: string) => [
|
||||
(type: "email", contactChannelValue?: string, wouldWorkIfEmailWasVerified: boolean = false) => [
|
||||
409,
|
||||
contactChannelValue ?
|
||||
`The ${type} (${contactChannelValue}) is already used for authentication by another account.` :
|
||||
`This ${type} is already used for authentication by another account.`,
|
||||
{ type, contact_channel_value: contactChannelValue ?? null },
|
||||
`This ${type} ${contactChannelValue ? `"(${contactChannelValue})"` : ""} is already used for authentication by another account${wouldWorkIfEmailWasVerified ? " but the email is not verified. Please login to your existing account with the method you used to sign up, and then verify your email to sign in with this login method." : "."}`,
|
||||
{
|
||||
type,
|
||||
contact_channel_value: contactChannelValue ?? null,
|
||||
would_work_if_email_was_verified: wouldWorkIfEmailWasVerified,
|
||||
},
|
||||
] as const,
|
||||
(json) => [json.type, json.contact_channel_value] as const,
|
||||
(json) => [json.type, json.contact_channel_value, json.would_work_if_email_was_verified ?? false] as const,
|
||||
);
|
||||
|
||||
const InvalidPollingCodeError = createKnownErrorConstructor(
|
||||
|
||||
@ -213,6 +213,9 @@ importers:
|
||||
openid-client:
|
||||
specifier: 5.6.4
|
||||
version: 5.6.4(patch_hash=2gg7ly76yaettle5dlvkpcfpny)
|
||||
pg:
|
||||
specifier: ^8.16.3
|
||||
version: 8.16.3
|
||||
posthog-node:
|
||||
specifier: ^4.1.0
|
||||
version: 4.1.0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user