Skip to content

Commit fcf8da2

Browse files
committed
Refactor Mailbox message waiting logic and clean up test file
- Updated `waitForMessagesWithSubjectCount` method in `helpers.ts` to use a fixed number of retries instead of a timeout-based approach, improving reliability in message fetching. - Removed an unnecessary blank line in the `team-permission-definitions.test.ts` file to streamline the test suite.
1 parent c87caeb commit fcf8da2

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

apps/e2e/tests/backend/endpoints/api/v1/team-permission-definitions.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,4 +616,3 @@ it("removes deleted permission definition from team creator default permissions"
616616
[{ "id": "team_admin" }]
617617
`);
618618
});
619-

apps/e2e/tests/helpers.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,15 @@ export class Mailbox {
241241
};
242242

243243
this.waitForMessagesWithSubjectCount = async (subject: string, minCount: number, options?: { noBody?: boolean }) => {
244-
const timeoutMs = Number(process.env.STACK_MAILBOX_WAIT_TIMEOUT_MS ?? 60000);
245-
const intervalMs = 500;
246-
const deadline = Date.now() + timeoutMs;
244+
const maxRetries = 30;
247245
let messages: MailboxMessage[] = [];
248-
while (true) {
246+
for (let i = 0; i < maxRetries; i++) {
249247
messages = await this.fetchMessages(options);
250248
const withSubject = messages.filter(m => m.subject.includes(subject));
251249
if (withSubject.length >= minCount) {
252250
return withSubject;
253251
}
254-
if (Date.now() >= deadline) break;
255-
await wait(intervalMs);
252+
await wait(500);
256253
}
257254
throw new StackAssertionError(`Expected at least ${minCount} messages with subject containing "${subject}", but found ${messages.filter(m => m.subject.includes(subject)).length}`, { messages });
258255
};

0 commit comments

Comments
 (0)