Skip to content

Commit 35fd07b

Browse files
committed
fix(tests): align tests with new CLI polling-code TTLs and refresh snapshots
- Update OpenAPI defaults snapshot for `expires_in_millis` to match the new 2-minute default introduced in #1419. - CLI route test: default is now 2min and max 15min, so update expectations. - failed-emails-digest: refresh inline snapshot to match new digest output. - internal-metrics anonymous-with-activity test: poll for ClickHouse ingestion instead of a fixed wait, mirroring the sibling test.
1 parent 50430fb commit 35fd07b

6 files changed

Lines changed: 17 additions & 20 deletions

File tree

apps/e2e/tests/backend/endpoints/api/v1/auth/cli/route.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ it("should create a new CLI auth attempt", async ({ expect }) => {
1313
expect(response.body).toHaveProperty("login_code");
1414
expect(response.body).toHaveProperty("expires_at");
1515

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

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

2727
const response = await niceBackendFetch("/api/latest/auth/cli", {
2828
method: "POST",
@@ -37,7 +37,7 @@ it("should create a new CLI auth attempt with custom expiration time", async ({
3737
expect(response.body).toHaveProperty("login_code");
3838
expect(response.body).toHaveProperty("expires_at");
3939

40-
// Verify that the expiration time is about 30 minutes from now
40+
// Verify that the expiration time is about the requested 10 minutes from now
4141
const expiresAt = new Date(response.body.expires_at);
4242
const now = new Date();
4343
expect(expiresAt.getTime() - now.getTime()).toBeGreaterThan(customExpirationMs - 10000); // Allow for a small margin of error

apps/e2e/tests/backend/endpoints/api/v1/internal-metrics.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,13 @@ it("should handle anonymous users with activity correctly", async ({ expect }) =
298298
await Auth.Anonymous.signUp();
299299
}
300300

301-
await wait(3000); // the event log is async, so let's give it some time to be written to the DB
302-
303-
const response = await niceBackendFetch("/api/v1/internal/metrics", { accessType: 'admin' });
301+
// ClickHouse ingestion is async; poll until the regular user's activity is counted in DAU.
302+
const response = await waitForMetricsMatch(false, (r) => {
303+
const dau = (r.body.daily_active_users as Array<{ activity: number }>);
304+
return r.body.users_by_country?.["CA"] === 1
305+
&& dau.length > 0
306+
&& dau[dau.length - 1].activity === 1;
307+
});
304308

305309
// Should only count 1 regular user
306310
expect(response.body.total_users).toBe(1);

apps/e2e/tests/backend/endpoints/api/v1/internal/failed-emails-digest.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,14 @@ describe("with valid credentials", () => {
128128
[
129129
{
130130
"emails": [
131-
{
132-
"subject": "",
133-
"to": ["User ID: <stripped UUID>"],
134-
},
135131
{
136132
"subject": "Verify your email at Test Failed Emails Project",
137133
"to": ["default-mailbox--<stripped UUID>@stack-generated.example.com"],
138134
},
139135
],
140136
"project_id": "<stripped UUID>",
141137
"tenancy_id": "<stripped UUID>",
142-
"tenant_owner_emails": [
143-
"default-mailbox--<stripped UUID>@stack-generated.example.com",
144-
"default-mailbox--<stripped UUID>@stack-generated.example.com",
145-
],
138+
"tenant_owner_emails": ["default-mailbox--<stripped UUID>@stack-generated.example.com"],
146139
},
147140
]
148141
`);

docs-mintlify/openapi/admin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@
11231123
"properties": {
11241124
"expires_in_millis": {
11251125
"type": "number",
1126-
"default": 7200000
1126+
"default": 120000
11271127
},
11281128
"anon_refresh_token": {
11291129
"type": "string"

docs-mintlify/openapi/client.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@
893893
"properties": {
894894
"expires_in_millis": {
895895
"type": "number",
896-
"default": 7200000
896+
"default": 120000
897897
},
898898
"anon_refresh_token": {
899899
"type": "string"

docs-mintlify/openapi/server.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@
10711071
"properties": {
10721072
"expires_in_millis": {
10731073
"type": "number",
1074-
"default": 7200000
1074+
"default": 120000
10751075
},
10761076
"anon_refresh_token": {
10771077
"type": "string"

0 commit comments

Comments
 (0)