From 93824e49b34db920a4ea83abbdcc60341550c175 Mon Sep 17 00:00:00 2001 From: George Korakas Date: Wed, 30 Aug 2023 13:40:32 +0300 Subject: [PATCH 1/3] fix: issue with unsafe to chain command that is not an action --- lib/rules/unsafe-to-chain-command.js | 2 +- tests/lib/rules/unsafe-to-chain-command.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rules/unsafe-to-chain-command.js b/lib/rules/unsafe-to-chain-command.js index ac2e13d3..82f1a8f1 100644 --- a/lib/rules/unsafe-to-chain-command.js +++ b/lib/rules/unsafe-to-chain-command.js @@ -129,7 +129,7 @@ const isRootCypress = (node) => { */ const isActionUnsafeToChain = (node, additionalMethods = []) => { const unsafeActionsRegex = new RegExp([ - ...unsafeToChainActions, + ...unsafeToChainActions.map((action) => `^${action}$`), ...additionalMethods.map((method) => method instanceof RegExp ? method.source : method), ].join('|')) diff --git a/tests/lib/rules/unsafe-to-chain-command.js b/tests/lib/rules/unsafe-to-chain-command.js index 2855b59a..4c1a4bc1 100644 --- a/tests/lib/rules/unsafe-to-chain-command.js +++ b/tests/lib/rules/unsafe-to-chain-command.js @@ -14,6 +14,10 @@ ruleTester.run('action-ends-chain', rule, { code: 'cy.get("new-todo").type("todo A{enter}"); cy.get("new-todo").type("todo B{enter}"); cy.get("new-todo").should("have.class", "active");', parserOptions, }, + { + code: 'cy.submitBtn().click();', + parserOptions, + }, ], invalid: [ From b400d558ede4b57be929b402976ef655ab19dfc7 Mon Sep 17 00:00:00 2001 From: George Korakas Date: Wed, 20 Sep 2023 08:29:11 +0300 Subject: [PATCH 2/3] chore: merge master and apply the fix --- lib/rules/unsafe-to-chain-command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/unsafe-to-chain-command.js b/lib/rules/unsafe-to-chain-command.js index 39c7705b..82f1a8f1 100644 --- a/lib/rules/unsafe-to-chain-command.js +++ b/lib/rules/unsafe-to-chain-command.js @@ -19,7 +19,7 @@ const unsafeToChainActions = [ 'check', 'dblclick', 'each', - 'focus$', + 'focus', 'rightclick', 'screenshot', 'scrollIntoView', From edc37e489c8f56b1702d5031a2185838aa1e6bd9 Mon Sep 17 00:00:00 2001 From: George Korakas Date: Thu, 2 May 2024 11:19:07 +0300 Subject: [PATCH 3/3] chore: add test case that shows the issue back to the code. --- tests/lib/rules/unsafe-to-chain-command.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/lib/rules/unsafe-to-chain-command.js b/tests/lib/rules/unsafe-to-chain-command.js index c79b8e6e..470bebd5 100644 --- a/tests/lib/rules/unsafe-to-chain-command.js +++ b/tests/lib/rules/unsafe-to-chain-command.js @@ -18,6 +18,10 @@ ruleTester.run('action-ends-chain', rule, { code: 'cy.focused().should("be.visible");', parserOptions, }, + { + code: 'cy.submitBtn().click();', + parserOptions, + }, ], invalid: [