Skip to content
Merged
Changes from 2 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
2 changes: 1 addition & 1 deletion apps/meteor/tests/data/permissions.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const updatePermission = (permission: string, roles: string[]): Promise<v
.send({ permissions: [{ _id: permission, roles }] })
.expect('Content-Type', 'application/json')
.expect(200)
.end((err?: Error) => setTimeout(() => (!err && resolve()) || reject(err), 100));
.end((err?: Error) => (!err && resolve()) || reject(err));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Reintroduce propagation wait to prevent permission-test race conditions

On Line 16, resolving immediately after the HTTP response can race with backend permission propagation (notifyOnPermissionChangedById is fire-and-forget in the API handler), so assertions that run right after this helper can become flaky.

Suggested fix
-			.end((err?: Error) => (!err && resolve()) || reject(err));
+			.end((err?: Error) =>
+				setTimeout(() => {
+					if (err) {
+						reject(err);
+						return;
+					}
+					resolve();
+				}, 100),
+			);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.end((err?: Error) => (!err && resolve()) || reject(err));
.end((err?: Error) =>
setTimeout(() => {
if (err) {
reject(err);
return;
}
resolve();
}, 100),
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/data/permissions.helper.ts` at line 16, The helper
currently resolves immediately in the .end callback (the line with .end((err?:
Error) => (!err && resolve()) || reject(err))); which can race with backend
permission propagation (notifyOnPermissionChangedById is fire-and-forget).
Change the success branch so it does not call resolve() immediately: wait for
permission propagation (either poll the API/event that reflects permission
changes, await a helper like notifyOnPermissionChangedById confirmation, or add
a short retry/poll loop with timeout) and only call resolve() after propagation
is observed; keep reject(err) behavior unchanged.

});

export const updateEEPermission = (permission: string, roles: string[]): Promise<void | Error> =>
Expand Down
Loading