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
2 changes: 1 addition & 1 deletion unit-test-security-rules-v9/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function getDatabaseCoverageMeta(databaseName: string, firebaseJsonPath:

export async function expectFirestorePermissionDenied(promise: Promise<any>) {
const errorResult = await assertFails(promise);
expect(errorResult.code).toBe('permission-denied' || 'PERMISSION_DENIED');
expect(errorResult.code).toBe('permission-denied');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The original code 'permission-denied' || 'PERMISSION_DENIED' was a logical error in JavaScript/TypeScript that always evaluated to the first string. While removing the dead code is an improvement, if the intention was to support both possible error codes (e.g., to handle variations across different SDK versions or environments), you should use an array check with toContain instead of a single string comparison.

Suggested change
expect(errorResult.code).toBe('permission-denied');
expect(['permission-denied', 'PERMISSION_DENIED']).toContain(errorResult.code);

}

export async function expectDatabasePermissionDenied(promise: Promise<any>) {
Expand Down
2 changes: 1 addition & 1 deletion unit-test-security-rules/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function getDatabaseCoverageMeta(databaseName: string, firebaseJsonPath:

export async function expectFirestorePermissionDenied(promise: Promise<any>) {
const errorResult = await assertFails(promise);
expect(errorResult.code).toBe('permission-denied' || 'PERMISSION_DENIED');
expect(errorResult.code).toBe('permission-denied');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The original code 'permission-denied' || 'PERMISSION_DENIED' was a logical error in JavaScript/TypeScript that always evaluated to the first string. While removing the dead code is an improvement, if the intention was to support both possible error codes (e.g., to handle variations across different SDK versions or environments), you should use an array check with toContain instead of a single string comparison.

Suggested change
expect(errorResult.code).toBe('permission-denied');
expect(['permission-denied', 'PERMISSION_DENIED']).toContain(errorResult.code);

}

export async function expectDatabasePermissionDenied(promise: Promise<any>) {
Expand Down