firebase / firebase/quickstart-testing

example code passes incorrectly

Aperta
#334 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
368
Fork
125
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

The function, expectPermissionGetSucceeds, can pass when it shouldn't.

https://github.com/firebase/quickstart-testing/blob/6ac0acf396e87e2588223151e8f0b4cf307a5e84/unit-test-security-rules-v9/test/utils.ts#L61

If your READ permissions return a PERMISSION_DENIED, then the getDoc promise will return the error code. however since this only expects that promise.not.toBeUndefined, then the error code meets that criteria.

I fixed locally by just adding the second check to make sure that the error code != PERMISSION_DENIED

```
export async function expectPermissionGetSucceeds(promise: Promise) {
const successResult = await assertSucceeds(promise);
expect(successResult).not.toBeUndefined();
expect(successResult.code).not.toBe('permission-denied' || 'PERMISSION_DENIED');
}
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.