Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
};
await sql`
UPDATE "Project"
SET "onboardingState" = ${JSON.stringify(onboardingState)}::jsonb
SET "onboardingState" = ${sql.json(onboardingState)}::jsonb
Comment thread
mantrakp04 marked this conversation as resolved.
WHERE "id" = ${ctx.projectId}
`;

Expand All @@ -39,7 +39,7 @@
WHERE "id" = ${ctx.projectId}
`;
expect(updatedRows).toHaveLength(1);
expect(JSON.parse(updatedRows[0].onboardingState)).toMatchInlineSnapshot(`

Check failure on line 42 in apps/backend/prisma/migrations/20260420000000_add_project_onboarding_state/tests/default-and-updates.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

src/auto-migrations/migration-tests.test.ts > database migration tests > 20260420000000_add_project_onboarding_state > default-and-updates

Error: Snapshot `database migration tests > 20260420000000_add_project_onboarding_state > default-and-updates 1` mismatched - Expected + Received - { - "selected_apps": [ - "authentication", - "emails", - ], - "selected_config_choice": "create-new", - "selected_email_theme_id": null, - "selected_payments_country": "US", - "selected_sign_in_methods": [ - "credential", - "magicLink", - ], - } + "{"selected_config_choice":"create-new","selected_apps":["authentication","emails"],"selected_sign_in_methods":["credential","magicLink"],"selected_email_theme_id":null,"selected_payments_country":"US"}" ❯ Module.postMigration prisma/migrations/20260420000000_add_project_onboarding_state/tests/default-and-updates.ts:42:54 ❯ src/auto-migrations/migration-tests.test.ts:148:13

Check failure on line 42 in apps/backend/prisma/migrations/20260420000000_add_project_onboarding_state/tests/default-and-updates.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

src/auto-migrations/migration-tests.test.ts > database migration tests > 20260420000000_add_project_onboarding_state > default-and-updates

Error: Snapshot `database migration tests > 20260420000000_add_project_onboarding_state > default-and-updates 1` mismatched - Expected + Received - { - "selected_apps": [ - "authentication", - "emails", - ], - "selected_config_choice": "create-new", - "selected_email_theme_id": null, - "selected_payments_country": "US", - "selected_sign_in_methods": [ - "credential", - "magicLink", - ], - } + "{"selected_config_choice":"create-new","selected_apps":["authentication","emails"],"selected_sign_in_methods":["credential","magicLink"],"selected_email_theme_id":null,"selected_payments_country":"US"}" ❯ Module.postMigration prisma/migrations/20260420000000_add_project_onboarding_state/tests/default-and-updates.ts:42:54 ❯ src/auto-migrations/migration-tests.test.ts:148:13

Check failure on line 42 in apps/backend/prisma/migrations/20260420000000_add_project_onboarding_state/tests/default-and-updates.ts

View workflow job for this annotation

GitHub Actions / Forward-compat — Current branch code with dev branch migrations

src/auto-migrations/migration-tests.test.ts > database migration tests > 20260420000000_add_project_onboarding_state > default-and-updates

Error: Snapshot `database migration tests > 20260420000000_add_project_onboarding_state > default-and-updates 1` mismatched - Expected + Received - { - "selected_apps": [ - "authentication", - "emails", - ], - "selected_config_choice": "create-new", - "selected_email_theme_id": null, - "selected_payments_country": "US", - "selected_sign_in_methods": [ - "credential", - "magicLink", - ], - } + "{"selected_config_choice":"create-new","selected_apps":["authentication","emails"],"selected_sign_in_methods":["credential","magicLink"],"selected_email_theme_id":null,"selected_payments_country":"US"}" ❯ Module.postMigration prisma/migrations/20260420000000_add_project_onboarding_state/tests/default-and-updates.ts:42:54 ❯ src/auto-migrations/migration-tests.test.ts:148:13
{
"selected_apps": [
"authentication",
Expand Down
12 changes: 7 additions & 5 deletions apps/backend/src/lib/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,13 @@ export async function createOrUpdateProjectWithLegacyConfig(
configOverrideOverride['apps.installed.authentication.enabled'] ??= true;
configOverrideOverride['apps.installed.emails.enabled'] ??= true;
}
await overrideEnvironmentConfigOverride({
projectId: projectId,
branchId: branchId,
environmentConfigOverrideOverride: configOverrideOverride,
});
if (options.type === "create" || Object.keys(configOverrideOverride).length > 0) {
await overrideEnvironmentConfigOverride({
projectId: projectId,
branchId: branchId,
environmentConfigOverrideOverride: configOverrideOverride,
});
}
const result = await getProject(projectId);
if (!result) {
throw new StackAssertionError("Project not found after creation/update", { projectId });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2435,15 +2435,15 @@ NiceResponse {
"display_name": null,
"id": "<stripped UUID>",
"last_active_at_millis": <stripped field 'last_active_at_millis'>,
"primary_email": "mailbox-1--<stripped UUID>@stack-generated.example.com",
"primary_email": "mailbox-2--<stripped UUID>@stack-generated.example.com",
"profile_image_url": null,
"signed_up_at_millis": <stripped field 'signed_up_at_millis'>,
},
{
"display_name": null,
"id": "<stripped UUID>",
"last_active_at_millis": <stripped field 'last_active_at_millis'>,
"primary_email": "mailbox-2--<stripped UUID>@stack-generated.example.com",
"primary_email": "mailbox-1--<stripped UUID>@stack-generated.example.com",
"profile_image_url": null,
"signed_up_at_millis": <stripped field 'signed_up_at_millis'>,
},
Expand Down
12 changes: 6 additions & 6 deletions apps/e2e/tests/backend/endpoints/api/v1/auth/cli/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
expect(response.body).toHaveProperty("login_code");
expect(response.body).toHaveProperty("expires_at");

// Verify that the expiration time is about 2 hours from now
// Verify that the expiration time is about 2 minutes from now (default polling-code TTL)
const expiresAt = new Date(response.body.expires_at);
const now = new Date();
const twoHoursInMs = 2 * 60 * 60 * 1000;
expect(expiresAt.getTime() - now.getTime()).toBeGreaterThan(twoHoursInMs - 10000); // Allow for a small margin of error
expect(expiresAt.getTime() - now.getTime()).toBeLessThan(twoHoursInMs + 10000); // Allow for a small margin of error
const twoMinutesInMs = 2 * 60 * 1000;
expect(expiresAt.getTime() - now.getTime()).toBeGreaterThan(twoMinutesInMs - 10000); // Allow for a small margin of error

Check failure on line 20 in apps/e2e/tests/backend/endpoints/api/v1/auth/cli/route.test.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

tests/backend/endpoints/api/v1/auth/cli/route.test.ts > should create a new CLI auth attempt

AssertionError: expected 119963 to be greater than 7190000 ❯ tests/backend/endpoints/api/v1/auth/cli/route.test.ts:20:47

Check failure on line 20 in apps/e2e/tests/backend/endpoints/api/v1/auth/cli/route.test.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

tests/backend/endpoints/api/v1/auth/cli/route.test.ts > should create a new CLI auth attempt

AssertionError: expected 119905 to be greater than 7190000 ❯ tests/backend/endpoints/api/v1/auth/cli/route.test.ts:20:47
expect(expiresAt.getTime() - now.getTime()).toBeLessThan(twoMinutesInMs + 10000); // Allow for a small margin of error
});

it("should create a new CLI auth attempt with custom expiration time", async ({ expect }) => {
const customExpirationMs = 30 * 60 * 1000; // 30 minutes
const customExpirationMs = 10 * 60 * 1000; // 10 minutes (max is 15)

const response = await niceBackendFetch("/api/latest/auth/cli", {
method: "POST",
Expand All @@ -32,12 +32,12 @@
},
});

expect(response.status).toBe(200);

Check failure on line 35 in apps/e2e/tests/backend/endpoints/api/v1/auth/cli/route.test.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

tests/backend/endpoints/api/v1/auth/cli/route.test.ts > should create a new CLI auth attempt with custom expiration time

AssertionError: expected 400 to be 200 // Object.is equality - Expected + Received - 200 + 400 ❯ tests/backend/endpoints/api/v1/auth/cli/route.test.ts:35:27

Check failure on line 35 in apps/e2e/tests/backend/endpoints/api/v1/auth/cli/route.test.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

tests/backend/endpoints/api/v1/auth/cli/route.test.ts > should create a new CLI auth attempt with custom expiration time

AssertionError: expected 400 to be 200 // Object.is equality - Expected + Received - 200 + 400 ❯ tests/backend/endpoints/api/v1/auth/cli/route.test.ts:35:27
expect(response.body).toHaveProperty("polling_code");
expect(response.body).toHaveProperty("login_code");
expect(response.body).toHaveProperty("expires_at");

// Verify that the expiration time is about 30 minutes from now
// Verify that the expiration time is about the requested 10 minutes from now
const expiresAt = new Date(response.body.expires_at);
const now = new Date();
expect(expiresAt.getTime() - now.getTime()).toBeGreaterThan(customExpirationMs - 10000); // Allow for a small margin of error
Expand Down
14 changes: 7 additions & 7 deletions apps/e2e/tests/backend/endpoints/api/v1/internal-metrics.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomUUID } from "node:crypto";
import { deepPlainEquals } from "@stackframe/stack-shared/dist/utils/objects";
import { wait } from "@stackframe/stack-shared/dist/utils/promises";
import { randomUUID } from "node:crypto";
import { expect } from "vitest";
import { NiceResponse, it } from "../../../../helpers";
import { Auth, InternalApiKey, Project, Team, backendContext, createMailbox, niceBackendFetch } from "../../../backend-helpers";
Expand Down Expand Up @@ -173,12 +173,10 @@
backendContext.set({ mailbox: mailboxes[2], ipData: { country: "CH", ipAddress: "127.0.0.1", city: "Zurich", region: "ZH", latitude: 47.3769, longitude: 8.5417, tzIdentifier: "Europe/Zurich" } });
await Auth.Otp.signIn();

await wait(3000); // the event log is async, so let's give it some time to be written to the DB

const response = await niceBackendFetch("/api/v1/internal/metrics", { accessType: 'admin' });
const response = await waitForMetricsToIncludeUsersByCountry({ countryCode: "CH", expectedCount: 1 });
expect(response).toMatchSnapshot(`metrics_result_with_users`);

await ensureAnonymousUsersAreStillExcluded(response);

Check failure on line 179 in apps/e2e/tests/backend/endpoints/api/v1/internal-metrics.test.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

tests/backend/endpoints/api/v1/internal-metrics.test.ts > should return metrics data with users

Error: Snapshot `should return metrics data with users > metrics_result_with_users 1` mismatched - Expected + Received @@ -5,19 +5,19 @@ "AQ": [ { "display_name": null, "id": "<stripped UUID>", "last_active_at_millis": <stripped field 'last_active_at_millis'>, - "primary_email": "mailbox-1--<stripped UUID>@stack-generated.example.com", + "primary_email": "mailbox-2--<stripped UUID>@stack-generated.example.com", "profile_image_url": null, "signed_up_at_millis": <stripped field 'signed_up_at_millis'>, }, { "display_name": null, "id": "<stripped UUID>", "last_active_at_millis": <stripped field 'last_active_at_millis'>, - "primary_email": "mailbox-2--<stripped UUID>@stack-generated.example.com", + "primary_email": "mailbox-1--<stripped UUID>@stack-generated.example.com", "profile_image_url": null, "signed_up_at_millis": <stripped field 'signed_up_at_millis'>, }, ], "CH": [ ❯ it.timeout tests/backend/endpoints/api/v1/internal-metrics.test.ts:179:20

Check failure on line 179 in apps/e2e/tests/backend/endpoints/api/v1/internal-metrics.test.ts

View workflow job for this annotation

GitHub Actions / Back-compat — Current branch migrations with dev branch code

tests/backend/endpoints/api/v1/internal-metrics.test.ts > should return metrics data with users

Error: Snapshot `should return metrics data with users > metrics_result_with_users 1` mismatched - Expected + Received @@ -5,19 +5,19 @@ "AQ": [ { "display_name": null, "id": "<stripped UUID>", "last_active_at_millis": <stripped field 'last_active_at_millis'>, - "primary_email": "mailbox-1--<stripped UUID>@stack-generated.example.com", + "primary_email": "mailbox-2--<stripped UUID>@stack-generated.example.com", "profile_image_url": null, "signed_up_at_millis": <stripped field 'signed_up_at_millis'>, }, { "display_name": null, "id": "<stripped UUID>", "last_active_at_millis": <stripped field 'last_active_at_millis'>, - "primary_email": "mailbox-2--<stripped UUID>@stack-generated.example.com", + "primary_email": "mailbox-1--<stripped UUID>@stack-generated.example.com", "profile_image_url": null, "signed_up_at_millis": <stripped field 'signed_up_at_millis'>, }, ], "CH": [ ❯ it.timeout tests/backend/endpoints/api/v1/internal-metrics.test.ts:179:20
}, {
timeout: 240_000,
});
Expand Down Expand Up @@ -299,9 +297,11 @@
await Auth.Anonymous.signUp();
}

await wait(3000); // the event log is async, so let's give it some time to be written to the DB

const response = await niceBackendFetch("/api/v1/internal/metrics", { accessType: 'admin' });
const response = await waitForMetricsMatch(false, (r) => {
if (r.body?.total_users !== 1) return false;
const dau = r.body?.daily_active_users?.[r.body.daily_active_users.length - 1];
return dau?.activity === 1 && r.body?.users_by_country?.["CA"] === 1;
});

// Should only count 1 regular user
expect(response.body.total_users).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ describe("with valid credentials", () => {
dry_run: `${isDryRun}`,
},
});
expect(response.status).toBe(200);
expect(response.status).toBe(200);

const failedEmailsByTenancy = response.body.failed_emails_by_tenancy;
const mockProjectFailedEmails = failedEmailsByTenancy.filter(
(batch: any) => batch.tenant_owner_emails.includes(backendContext.value.mailbox.emailAddress)
).map((batch: any) => ({
...batch,
emails: [...batch.emails].sort((a, b) => stringCompare(a.subject, b.subject)),
}));
const failedEmailsByTenancy = response.body.failed_emails_by_tenancy;
const mockProjectFailedEmails = failedEmailsByTenancy.filter(
(batch: any) => batch.tenant_owner_emails.includes(backendContext.value.mailbox.emailAddress)
).map((batch: any) => ({
...batch,
emails: [...batch.emails].sort((a, b) => stringCompare(a.subject, b.subject)),
}));

if (process.env.STACK_TEST_SOURCE_OF_TRUTH === "true") {
if (process.env.STACK_TEST_SOURCE_OF_TRUTH === "true") {
expect(mockProjectFailedEmails).toMatchInlineSnapshot(`[]`);
} else {
} else {
expect(mockProjectFailedEmails).toMatchInlineSnapshot(`
[
{
Expand All @@ -147,11 +147,11 @@ describe("with valid credentials", () => {
]
`);
expect(mockProjectFailedEmails[0].project_id).toBe(projectId);
}
}

return {
projectOwnerMailbox,
};
return {
projectOwnerMailbox,
};
}

it("should return 200 and process dry run request", async ({ expect }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,6 @@ describe("local emulator project endpoint", () => {
}
});

it.runIf(isLocalEmulator)("rejects non-existent config files", async ({ expect }) => {
const nonExistentPath = `/tmp/${randomUUID()}/stack.config.ts`;

const response = await niceBackendFetch(LOCAL_EMULATOR_PROJECT_ENDPOINT, {
accessType: "admin",
method: "POST",
body: {
absolute_file_path: nonExistentPath,
},
});

expect(response.status).toBe(400);
expect(response.body).toContain("Config file not found");
});

it.runIf(isLocalEmulator)("writes default config for empty files", async ({ expect }) => {
const filePath = `/tmp/${randomUUID()}/stack.config.ts`;
await fs.mkdir(path.dirname(filePath), { recursive: true });
Expand Down
2 changes: 1 addition & 1 deletion docs-mintlify/openapi/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@
"properties": {
"expires_in_millis": {
"type": "number",
"default": 7200000
"default": 120000
},
"anon_refresh_token": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion docs-mintlify/openapi/client.json
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@
"properties": {
"expires_in_millis": {
"type": "number",
"default": 7200000
"default": 120000
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"anon_refresh_token": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion docs-mintlify/openapi/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@
"properties": {
"expires_in_millis": {
"type": "number",
"default": 7200000
"default": 120000
},
"anon_refresh_token": {
"type": "string"
Expand Down
Loading