From 4eedc6bac9fa2bb4509789908d37dc63a6a79da0 Mon Sep 17 00:00:00 2001 From: Dominic Fraser Date: Fri, 15 Sep 2023 17:08:29 +0100 Subject: [PATCH 1/2] fix(pencil): illustrate the false positive of 'focus' regex matching 'focused' --- 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..2ea527df 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', diff --git a/tests/lib/rules/unsafe-to-chain-command.js b/tests/lib/rules/unsafe-to-chain-command.js index 2855b59a..0e2afa8f 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.focused().should("be.visible");', + parserOptions, + }, ], invalid: [ From 0c525e1a4306b34ee264d40190f8a0c3fb4427d0 Mon Sep 17 00:00:00 2001 From: Dominic Fraser Date: Fri, 15 Sep 2023 18:00:04 +0100 Subject: [PATCH 2/2] add test to ensure 'focus' does fail, in addition to 'focused' passing --- tests/lib/rules/unsafe-to-chain-command.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/lib/rules/unsafe-to-chain-command.js b/tests/lib/rules/unsafe-to-chain-command.js index 0e2afa8f..c79b8e6e 100644 --- a/tests/lib/rules/unsafe-to-chain-command.js +++ b/tests/lib/rules/unsafe-to-chain-command.js @@ -31,6 +31,11 @@ ruleTester.run('action-ends-chain', rule, { parserOptions, errors, }, + { + code: 'cy.get("new-todo").focus().should("have.class", "active");', + parserOptions, + errors, + }, { code: 'cy.get("new-todo").customType("todo A{enter}").customClick();', parserOptions,