prescottprue / cypress-firebase

Cypress plugin and custom commands for testing Firebase projects
MIT License
273 stars 50 forks source link

bug: Firestore get ignores any where conditions beyond the first two #1313

Closed dominics closed 3 months ago

dominics commented 3 months ago

Bug Description

If you make a get callFirestore with more than two where conditions, any additional where conditions are silently dropped. For example: this call will return projects where bar does not equal def:

cy.callFirestore("get", "projects", {
    where: [
        ["active", "==", true],
        ["foo", "==", "abc"],
        ["bar", "==", "def"],
    ],
})

As another example showing that the where order matters, this call will return projects that aren't active:

cy.callFirestore("get", "projects", {
    where: [
        ["name", ">=", "abc"],
        ["name", "<=", "abc\xff"], 
        ["active", "==", true],
    ],
})

Originally reported here: https://github.com/prescottprue/cypress-firebase/issues/501#issuecomment-1729915139

Why It Happens

This happens because the where option handling only destructures two where conditions out of the array: https://github.com/prescottprue/cypress-firebase/blob/885abba7068fe4a392c47dcac828d8f93e53c17a/src/firebase-utils.ts#L276-L283

Solution

Opened this just to track the issue for the fix in PR: #1314

prescottprue commented 3 months ago

Great catch - thanks for making the issue and the PR to fix 👏

github-actions[bot] commented 3 months ago

:tada: This issue has been resolved in version 4.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: