From dcd2aa824869d9e041d9f8c8c520b764fbbcf854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Teixeira?= Date: Fri, 5 Apr 2024 14:11:17 +0100 Subject: [PATCH 1/8] fix: --spec now allows () in filename (https://github.com/cypress-io/cypress/issues/28509) --- cli/CHANGELOG.md | 3 +++ packages/server/lib/util/args.js | 3 +++ packages/server/test/unit/util/args_spec.js | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 64344c1f3210..a17fb5038860 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,6 +7,9 @@ _Released 4/16/2024 (PENDING)_ - Updated the Chrome flags to not show the "Enhanced Ad Privacy" dialog. Addresses [#29199](https://github.com/cypress-io/cypress/issues/29199). +**Bugfixes** + - Specs with () in the filename will no longer fail to load and now behave as any other spec. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509) + ## 13.7.2 _Released 4/2/2024_ diff --git a/packages/server/lib/util/args.js b/packages/server/lib/util/args.js index f948f709c82e..64042402e839 100644 --- a/packages/server/lib/util/args.js +++ b/packages/server/lib/util/args.js @@ -234,6 +234,9 @@ const parseSpecArgv = (pattern) => { ] } + // Escape parentheses. + pattern = pattern.replace(/[()]/g, '\\$&') + /** * Sanitizes a path's leftover commas. * diff --git a/packages/server/test/unit/util/args_spec.js b/packages/server/test/unit/util/args_spec.js index ff7e1ba4af00..c930ad590bae 100644 --- a/packages/server/test/unit/util/args_spec.js +++ b/packages/server/test/unit/util/args_spec.js @@ -216,6 +216,13 @@ describe('lib/util/args', () => { expect(options.spec[2]).to.eq(`${getCwd()}/cypress/integration/foo2/bar/baz/test.ts`) expect(options.spec[3]).to.eq(`${getCwd()}/cypress/integration/foo3/bar/baz/foo4.ts`) }) + + // https://github.com/cypress-io/cypress/issues/28509 + it('correctly escapes parentheses in filename', function () { + const options = this.setup('--spec', 'cypress/integration/foo/bar/test().ts') + + expect(options.spec[0]).to.eq(`${getCwd()}/cypress/integration/foo/bar/test\\(\\).ts`) + }) }) context('--tag', () => { From 8ab97816059bfa5950991623b570a2749203e805 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 9 Apr 2024 13:40:52 -0400 Subject: [PATCH 2/8] Update cli/CHANGELOG.md --- cli/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index a17fb5038860..9b14cefdb1ff 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -8,6 +8,7 @@ _Released 4/16/2024 (PENDING)_ - Updated the Chrome flags to not show the "Enhanced Ad Privacy" dialog. Addresses [#29199](https://github.com/cypress-io/cypress/issues/29199). **Bugfixes** + - Specs with () in the filename will no longer fail to load and now behave as any other spec. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509) ## 13.7.2 From cf27d2c5ed36b7cc10830b63799d4d2d8b74f929 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 11 Apr 2024 12:58:20 -0400 Subject: [PATCH 3/8] Update cli/CHANGELOG.md --- cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 9b14cefdb1ff..4501d92b2b6a 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,7 +7,7 @@ _Released 4/16/2024 (PENDING)_ - Updated the Chrome flags to not show the "Enhanced Ad Privacy" dialog. Addresses [#29199](https://github.com/cypress-io/cypress/issues/29199). -**Bugfixes** +**Bugfixes:** - Specs with () in the filename will no longer fail to load and now behave as any other spec. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509) From 3d803c1c86bf996e461e3ae5afc6ec8b96f1be22 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Fri, 12 Apr 2024 17:07:33 -0400 Subject: [PATCH 4/8] Update cli/CHANGELOG.md Co-authored-by: Bill Glesias --- cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 85a8f94f64ac..1ee18043dd1d 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -16,7 +16,7 @@ _Released 4/11/2024_ **Bugfixes:** - - Specs with () in the filename will no longer fail to load and now behave as any other spec. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509) + - Specs with () in the filename will no longer fail to load and now behave as any other spec when run with the `--spec` argument via `cypress run`. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509) ## 13.7.2 From 131a9647ed4d046b9e63c23aca691336c268935b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Teixeira?= Date: Wed, 19 Jun 2024 15:47:27 +0100 Subject: [PATCH 5/8] fix: passes system-test it was previously failing --- packages/server/lib/util/args.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/server/lib/util/args.js b/packages/server/lib/util/args.js index 64042402e839..eeac4412ab05 100644 --- a/packages/server/lib/util/args.js +++ b/packages/server/lib/util/args.js @@ -234,8 +234,16 @@ const parseSpecArgv = (pattern) => { ] } - // Escape parentheses. - pattern = pattern.replace(/[()]/g, '\\$&') + // Split the path into directory and file name + const lastSlashIndex = pattern.lastIndexOf('/'); + const directoryPath = pattern.substring(0, lastSlashIndex + 1); + const fileName = pattern.substring(lastSlashIndex + 1); + + // Escape the parentheses in the file name + const escapedFileName = fileName.replace(/[()]/g, '\\$&'); + + // Recombine the directory path and escaped file name + pattern = directoryPath + escapedFileName; /** * Sanitizes a path's leftover commas. From 237297f0a82fb9b99247467cf1055abac87d39c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Teixeira?= Date: Thu, 20 Jun 2024 20:33:26 +0100 Subject: [PATCH 6/8] fix: passes system-test it was previously failing --- packages/server/lib/util/args.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/server/lib/util/args.js b/packages/server/lib/util/args.js index 64042402e839..eeac4412ab05 100644 --- a/packages/server/lib/util/args.js +++ b/packages/server/lib/util/args.js @@ -234,8 +234,16 @@ const parseSpecArgv = (pattern) => { ] } - // Escape parentheses. - pattern = pattern.replace(/[()]/g, '\\$&') + // Split the path into directory and file name + const lastSlashIndex = pattern.lastIndexOf('/'); + const directoryPath = pattern.substring(0, lastSlashIndex + 1); + const fileName = pattern.substring(lastSlashIndex + 1); + + // Escape the parentheses in the file name + const escapedFileName = fileName.replace(/[()]/g, '\\$&'); + + // Recombine the directory path and escaped file name + pattern = directoryPath + escapedFileName; /** * Sanitizes a path's leftover commas. From 94412998f30ed8cfb80edf69e1e6412700282edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Teixeira?= Date: Thu, 20 Jun 2024 20:37:32 +0100 Subject: [PATCH 7/8] fix: corrected lint errors --- packages/server/lib/util/args.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/server/lib/util/args.js b/packages/server/lib/util/args.js index eeac4412ab05..4729b24e335f 100644 --- a/packages/server/lib/util/args.js +++ b/packages/server/lib/util/args.js @@ -235,15 +235,15 @@ const parseSpecArgv = (pattern) => { } // Split the path into directory and file name - const lastSlashIndex = pattern.lastIndexOf('/'); - const directoryPath = pattern.substring(0, lastSlashIndex + 1); - const fileName = pattern.substring(lastSlashIndex + 1); + const lastSlashIndex = pattern.lastIndexOf('/') + const directoryPath = pattern.substring(0, lastSlashIndex + 1) + const fileName = pattern.substring(lastSlashIndex + 1) // Escape the parentheses in the file name - const escapedFileName = fileName.replace(/[()]/g, '\\$&'); + const escapedFileName = fileName.replace(/[()]/g, '\\$&') // Recombine the directory path and escaped file name - pattern = directoryPath + escapedFileName; + pattern = directoryPath + escapedFileName /** * Sanitizes a path's leftover commas. From 6e18b7431d71fb7f6d3a479f310739ba5ae0f365 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Fri, 21 Jun 2024 11:57:15 -0400 Subject: [PATCH 8/8] Update changelog --- cli/CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 12d65b305ce2..3a0a5a3a5455 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -6,6 +6,7 @@ _Released 7/2/2024 (PENDING)_ **Bugfixes:** - Fixed an issue where Firefox 129 (Firefox Nightly) would not launch with Cypress. Fixes [#29713](https://github.com/cypress-io/cypress/issues/29713). Fixed in [#29720](https://github.com/cypress-io/cypress/pull/29720). +- Specs with () in the filename will no longer fail to load and now behave as any other spec when run with the `--spec` argument via `cypress run`. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509). **Dependency Updates:** @@ -117,10 +118,6 @@ _Released 4/23/2024_ - Fixed a regression introduced in [`13.6.0`](https://docs.cypress.io/guides/references/changelog#13-6-0) where Cypress would occasionally exit with status code 1, even when a test run was successful, due to an unhandled WebSocket exception (`Error: WebSocket connection closed`). Addresses [#28523](https://github.com/cypress-io/cypress/issues/28523). - Fixed an issue where Cypress would hang on some commands when an invalid `timeout` option was provided. Fixes [#29323](https://github.com/cypress-io/cypress/issues/29323). - -**Bugfixes:** - - - Specs with () in the filename will no longer fail to load and now behave as any other spec when run with the `--spec` argument via `cypress run`. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509). **Misc:**