From e34adddbed0591dbb9dbac3ab6ebc1ff849c65fb Mon Sep 17 00:00:00 2001 From: Mike Plummer Date: Thu, 15 Dec 2022 15:29:42 -0600 Subject: [PATCH] fix: Add missing `filter` parameter to `nextUntil` command (#25167) --- cli/types/cypress.d.ts | 12 ++++++------ cli/types/tests/cypress-tests.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 91d80c3423..5291f64883 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -1589,19 +1589,19 @@ declare namespace Cypress { * * @see https://on.cypress.io/nextuntil */ - nextUntil(selector: K, options?: Partial): Chainable> + nextUntil(selector: K, filter?: string, options?: Partial): Chainable> /** * Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * * @see https://on.cypress.io/nextuntil */ - nextUntil(options?: Partial): Chainable> + nextUntil(selector: string, filter?: string, options?: Partial): Chainable> /** * Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * * @see https://on.cypress.io/nextuntil */ - nextUntil(selector: string, options?: Partial): Chainable> + nextUntil(element: E | JQuery, filter?: string, options?: Partial): Chainable> /** * Filter DOM element(s) from a set of DOM elements. Opposite of `.filter()` @@ -1774,21 +1774,21 @@ declare namespace Cypress { * Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery. * - * @see https://on.cypress.io/prevall + * @see https://on.cypress.io/prevuntil */ prevUntil(selector: K, filter?: string, options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery. * - * @see https://on.cypress.io/prevall + * @see https://on.cypress.io/prevuntil */ prevUntil(selector: string, filter?: string, options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery. * - * @see https://on.cypress.io/prevall + * @see https://on.cypress.io/prevuntil */ prevUntil(element: E | JQuery, filter?: string, options?: Partial): Chainable> diff --git a/cli/types/tests/cypress-tests.ts b/cli/types/tests/cypress-tests.ts index 3b9f5f9f4d..d31223d596 100644 --- a/cli/types/tests/cypress-tests.ts +++ b/cli/types/tests/cypress-tests.ts @@ -1136,3 +1136,29 @@ namespace CypressLocalStorageTests { cy.clearAllSessionStorage({ log: false }) cy.clearAllSessionStorage({ log: 'true' }) // $ExpectError } + +namespace CypressTraversalTests { + cy.wrap({}).prevUntil('a') // $ExpectType Chainable> + cy.wrap({}).prevUntil('#myItem') // $ExpectType Chainable> + cy.wrap({}).prevUntil('span', 'a') // $ExpectType Chainable> + cy.wrap({}).prevUntil('#myItem', 'a') // $ExpectType Chainable> + cy.wrap({}).prevUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable> + cy.wrap({}).prevUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable> + cy.wrap({}).prevUntil('#myItem', 'a', { log: 'true' }) // $ExpectError + + cy.wrap({}).nextUntil('a') // $ExpectType Chainable> + cy.wrap({}).nextUntil('#myItem') // $ExpectType Chainable> + cy.wrap({}).nextUntil('span', 'a') // $ExpectType Chainable> + cy.wrap({}).nextUntil('#myItem', 'a') // $ExpectType Chainable> + cy.wrap({}).nextUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable> + cy.wrap({}).nextUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable> + cy.wrap({}).nextUntil('#myItem', 'a', { log: 'true' }) // $ExpectError + + cy.wrap({}).parentsUntil('a') // $ExpectType Chainable> + cy.wrap({}).parentsUntil('#myItem') // $ExpectType Chainable> + cy.wrap({}).parentsUntil('span', 'a') // $ExpectType Chainable> + cy.wrap({}).parentsUntil('#myItem', 'a') // $ExpectType Chainable> + cy.wrap({}).parentsUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable> + cy.wrap({}).parentsUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable> + cy.wrap({}).parentsUntil('#myItem', 'a', { log: 'true' }) // $ExpectError +}