From 896d99433f87caf30b82fdcafe0274e5d4cfb85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Thu, 26 Oct 2023 17:31:45 -0300 Subject: [PATCH 01/22] docs: Fix custom folder for integration tests --- .../docs/faststore-config-options/custom-cypress-test.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx index 912c6fc291..1905c9eb22 100644 --- a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx +++ b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx @@ -35,7 +35,6 @@ Learn how to add custom integration tests in the following steps. 2. Navigate to the `@faststore/core` and `@faststore/cli` dependencies and and update their versions to be at least `2.1.56`. 3. Run `yarn install` to apply these changes. - --- ## Step 1: Enabling `enableCypressExtension` @@ -56,7 +55,7 @@ Learn how to add custom integration tests in the following steps. ## Step 2: Integrating custom Cypress tests into your FastStore project 1. In the root directory of your storefront project, create a new folder named `cypress`. -2. Add your custom integration tests within the `cypress` folder. +2. Add your custom integration tests within the `cypress/integration` folder. 3. Open a pull request with the changes you have made. 4. Within the pull request, navigate to **Checks > Integration Tests** and check the **Details** section. From 5f9a05d6e130cce2acfc1644256e42250b6fd1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Thu, 26 Oct 2023 17:31:55 -0300 Subject: [PATCH 02/22] fix: Test command --- packages/cli/src/commands/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index 10df987d41..d55dd10b55 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -29,7 +29,7 @@ const defaultIgnored = [ const testAbortController = new AbortController() async function storeTest() { - const testProcess = spawn('yarn test', { + const testProcess = spawn('yarn test:e2e', { shell: true, cwd: tmpDir, signal: testAbortController.signal, From 4a41642269c779f25b51d537eedbdc32d8fd7330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Thu, 26 Oct 2023 19:29:10 -0300 Subject: [PATCH 03/22] chore: Change custom tests folder (cypress/e2e) --- packages/cli/src/utils/generate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 3fc0e3d7ca..266bf91b0b 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -90,7 +90,7 @@ async function copyCypressFiles() { const userStoreConfig = await import(userStoreConfigFileDir) if (userStoreConfig?.experimental?.enableCypressExtension) { - copySync(`${userDir}/cypress`, `${tmpDir}/cypress/integration`, { + copySync(`${userDir}/cypress`, `${tmpDir}/cypress/e2e`, { overwrite: true, }) console.log(`${chalk.green('success')} - Cypress test files copied`) From df15e9f146f16a797bee5cb4725437e02850ecf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Thu, 26 Oct 2023 19:43:20 -0300 Subject: [PATCH 04/22] chore: Change custom tests folder (cypress/) --- packages/cli/src/utils/generate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 266bf91b0b..1fb27486bc 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -90,7 +90,7 @@ async function copyCypressFiles() { const userStoreConfig = await import(userStoreConfigFileDir) if (userStoreConfig?.experimental?.enableCypressExtension) { - copySync(`${userDir}/cypress`, `${tmpDir}/cypress/e2e`, { + copySync(`${userDir}/cypress`, `${tmpDir}/cypress`, { overwrite: true, }) console.log(`${chalk.green('success')} - Cypress test files copied`) From cc377397ef2426083c438138849444d17c737206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 11:19:14 -0300 Subject: [PATCH 05/22] Revert "chore: Change custom tests folder (cypress/)" This reverts commit ebe9d0938342cc4c124344dc6ee3b398b8f0f672. --- packages/cli/src/utils/generate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 1fb27486bc..266bf91b0b 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -90,7 +90,7 @@ async function copyCypressFiles() { const userStoreConfig = await import(userStoreConfigFileDir) if (userStoreConfig?.experimental?.enableCypressExtension) { - copySync(`${userDir}/cypress`, `${tmpDir}/cypress`, { + copySync(`${userDir}/cypress`, `${tmpDir}/cypress/e2e`, { overwrite: true, }) console.log(`${chalk.green('success')} - Cypress test files copied`) From 09483e533577dfcac1f3f968698f16f56dea11b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 11:57:30 -0300 Subject: [PATCH 06/22] chore: Set default support file for Cypress 12.x or superior --- packages/cli/src/utils/generate.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 266bf91b0b..962d881bc9 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -9,6 +9,7 @@ import { symlinkSync, writeFileSync, writeJsonSync, + moveSync, } from 'fs-extra' import path from 'path' @@ -93,6 +94,14 @@ async function copyCypressFiles() { copySync(`${userDir}/cypress`, `${tmpDir}/cypress/e2e`, { overwrite: true, }) + + // Set default Cypress 12.x (or superior) support file + if (userStoreConfig?.experimental?.cypressVersion > 9) { + if (existsSync(`${tmpDir}/cypress/support/index.js`)) { + moveSync(`${tmpDir}/cypress/support/index.js`, `${tmpDir}/cypress/support/e2e.ts`) + } + } + console.log(`${chalk.green('success')} - Cypress test files copied`) } } catch (e) { From 05b57007b085d1beee07ff5dc5312f40009fe8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 13:15:56 -0300 Subject: [PATCH 07/22] fix: Cypress paths --- packages/cli/src/utils/generate.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 962d881bc9..905343b004 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -9,7 +9,6 @@ import { symlinkSync, writeFileSync, writeJsonSync, - moveSync, } from 'fs-extra' import path from 'path' @@ -91,15 +90,15 @@ async function copyCypressFiles() { const userStoreConfig = await import(userStoreConfigFileDir) if (userStoreConfig?.experimental?.enableCypressExtension) { - copySync(`${userDir}/cypress`, `${tmpDir}/cypress/e2e`, { + copySync(`${userDir}/cypress`, `${tmpDir}/cypress`, { overwrite: true, }) // Set default Cypress 12.x (or superior) support file if (userStoreConfig?.experimental?.cypressVersion > 9) { - if (existsSync(`${tmpDir}/cypress/support/index.js`)) { - moveSync(`${tmpDir}/cypress/support/index.js`, `${tmpDir}/cypress/support/e2e.ts`) - } + copySync(`${tmpDir}/cypress/support/index.js`, `${tmpDir}/cypress/support/e2e.ts`, { + overwrite: false, + }) } console.log(`${chalk.green('success')} - Cypress test files copied`) From 288591fef4a7e36ff84c8d529832293561cc9aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 14:43:30 -0300 Subject: [PATCH 08/22] docs: Steps improvements --- .../faststore-config-options/custom-cypress-test.mdx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx index 1905c9eb22..777ea6af39 100644 --- a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx +++ b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx @@ -30,10 +30,11 @@ Learn how to add custom integration tests in the following steps. - Refer to [Cypress documentation](https://docs.cypress.io/guides/overview/why-cypress) for more information on this testing tool. -- Ensure that you are using `@faststore/core` and `@faststore/cli` version 2.1.56 or above. If you are using a previous version, take the following steps: +- Ensure that you are using `@faststore/core` version 2.1.56 or above and `@faststore/cli` version 2.2.6 or above. If you have a version that is lower than this requirement, change the following: 1. In your storefront project, open the `package.json` file. - 2. Navigate to the `@faststore/core` and `@faststore/cli` dependencies and and update their versions to be at least `2.1.56`. - 3. Run `yarn install` to apply these changes. + 2. Navigate to the `@faststore/core` and and update them to be at least `2.1.56`. + 3. Navigate to the `@faststore/cli` and and update them to be at least `2.2.6`. + 4. Run `yarn dev` to update your changes. --- @@ -56,8 +57,9 @@ Learn how to add custom integration tests in the following steps. 1. In the root directory of your storefront project, create a new folder named `cypress`. 2. Add your custom integration tests within the `cypress/integration` folder. -3. Open a pull request with the changes you have made. -4. Within the pull request, navigate to **Checks > Integration Tests** and check the **Details** section. +3. With the local server running, run `yarn test` to open the Cypress app and to check your tests execution. +4. Open a pull request with the changes you have made. +5. Within the pull request, navigate to **Checks > Integration Tests** and check the **Details** section. ![checks-integration-tests](https://vtexhelp.vtexassets.com/assets/docs/src/custom-test-checks___583ac9b78e43ebdafde93a735a47d61b.png) From 6d01e99613781031a34d34affb067cda08a9b63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 15:29:14 -0300 Subject: [PATCH 09/22] fix: Prevent running test command without `.faststore` --- packages/cli/src/commands/test.ts | 11 ++++++++--- packages/cli/src/utils/generate.ts | 7 +------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index d55dd10b55..c12cf88feb 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -1,9 +1,10 @@ import { Command } from '@oclif/core' import { spawn } from 'child_process' import chokidar from 'chokidar' +import { existsSync } from 'fs-extra' import { getRoot, tmpDir } from '../utils/directory' -import { generate } from '../utils/generate' +import { generate} from '../utils/generate' /** * Taken from toolbelt @@ -43,6 +44,12 @@ async function storeTest() { export default class Test extends Command { async run() { + if (!existsSync(tmpDir)) { + throw Error( + 'The ".faststore" directory could not be found. If you are trying to test your store, run "yarn dev" in another window first.' + ) + } + const watcher = chokidar.watch([...defaultPatterns], { atomic: stabilityThreshold, awaitWriteFinish: { @@ -59,8 +66,6 @@ export default class Test extends Command { watcher.close() }) - await generate({ test: true }) - storeTest() return await new Promise((resolve, reject) => { diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 905343b004..ee8b27396c 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -36,7 +36,6 @@ import chalk from 'chalk' interface GenerateOptions { setup?: boolean - test?: boolean } const ignorePaths = ['node_modules', 'cypress.config.ts'] @@ -244,14 +243,10 @@ function createNodeModulesSymbolicLink() { } export async function generate(options?: GenerateOptions) { - const { setup = false, test = false } = options ?? {} + const { setup = false } = options ?? {} let setupPromise: Promise | null = null - if (test) { - return copyCypressFiles() - } - if (setup) { setupPromise = Promise.all([ createTmpFolder(), From ae371de61f37521e0d5ae9b9e3fac3ab0b01c789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 15:41:01 -0300 Subject: [PATCH 10/22] fix: Remove unnecessary import --- packages/cli/src/commands/test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index c12cf88feb..fa47095777 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -4,7 +4,6 @@ import chokidar from 'chokidar' import { existsSync } from 'fs-extra' import { getRoot, tmpDir } from '../utils/directory' -import { generate} from '../utils/generate' /** * Taken from toolbelt From 7d5282feb6c528ad9d7a5e27173e909e1d8365de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 15:47:45 -0300 Subject: [PATCH 11/22] fix: Error message typo --- packages/cli/src/commands/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index fa47095777..717dd97139 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -45,7 +45,7 @@ export default class Test extends Command { async run() { if (!existsSync(tmpDir)) { throw Error( - 'The ".faststore" directory could not be found. If you are trying to test your store, run "yarn dev" in another window first.' + 'The ".faststore" directory could not be found. If you are trying to test your store, run "faststore dev" in another window first.' ) } From 775a85e0f9a98bcfdb7247e90dbbe12a89acbd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Fri, 27 Oct 2023 15:59:34 -0300 Subject: [PATCH 12/22] fix: Default Cypress support file as `.js` file --- packages/cli/src/utils/generate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index ee8b27396c..15945de02e 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -95,7 +95,7 @@ async function copyCypressFiles() { // Set default Cypress 12.x (or superior) support file if (userStoreConfig?.experimental?.cypressVersion > 9) { - copySync(`${tmpDir}/cypress/support/index.js`, `${tmpDir}/cypress/support/e2e.ts`, { + copySync(`${tmpDir}/cypress/support/index.js`, `${tmpDir}/cypress/support/e2e.js`, { overwrite: false, }) } From 581fb5b7c250b5c3e35101a97f2f4e56980385bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 11:24:52 -0300 Subject: [PATCH 13/22] feat: Creates a detached local server when running test command --- packages/cli/src/commands/test.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index 717dd97139..b70b288936 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -29,6 +29,13 @@ const defaultIgnored = [ const testAbortController = new AbortController() async function storeTest() { + const detachedDevProcess = spawn('yarn dev', { + shell: true, + cwd: tmpDir, + stdio: 'ignore', + detached: true, + }) + const testProcess = spawn('yarn test:e2e', { shell: true, cwd: tmpDir, @@ -37,18 +44,18 @@ async function storeTest() { }) testProcess.on('close', () => { + detachedDevProcess.kill() + testAbortController.abort() + }) + + testProcess.on('exit', () => { + detachedDevProcess.kill() testAbortController.abort() }) } export default class Test extends Command { async run() { - if (!existsSync(tmpDir)) { - throw Error( - 'The ".faststore" directory could not be found. If you are trying to test your store, run "faststore dev" in another window first.' - ) - } - const watcher = chokidar.watch([...defaultPatterns], { atomic: stabilityThreshold, awaitWriteFinish: { From 930a4d8abc41fdd305879cd669d5ce36c3503c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 11:26:32 -0300 Subject: [PATCH 14/22] fix: Ensures default Cypress 12.x support file creation --- packages/cli/src/utils/generate.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 15945de02e..155ae646de 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -87,21 +87,24 @@ async function copyCypressFiles() { copySync(`${userDir}/cypress.config.ts`, `${tmpDir}/cypress.config.ts`) } + // Copy custom Cypress folder and files const userStoreConfig = await import(userStoreConfigFileDir) if (userStoreConfig?.experimental?.enableCypressExtension) { copySync(`${userDir}/cypress`, `${tmpDir}/cypress`, { overwrite: true, }) - // Set default Cypress 12.x (or superior) support file - if (userStoreConfig?.experimental?.cypressVersion > 9) { - copySync(`${tmpDir}/cypress/support/index.js`, `${tmpDir}/cypress/support/e2e.js`, { - overwrite: false, - }) - } - console.log(`${chalk.green('success')} - Cypress test files copied`) } + + // Create default Cypress 12.x (or superior) support file + if (userStoreConfig?.experimental?.cypressVersion > 9) { + copySync( + `${tmpDir}/cypress/support/index.js`, + `${tmpDir}/cypress/support/e2e.js`, + { overwrite: false } + ) + } } catch (e) { console.error(e) } From 816fa9dcb749eee409c12a3273762429afb90094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 11:31:10 -0300 Subject: [PATCH 15/22] fix: `@faststore/cli` build --- packages/cli/src/commands/test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index b70b288936..542d21eea7 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -1,7 +1,6 @@ import { Command } from '@oclif/core' import { spawn } from 'child_process' import chokidar from 'chokidar' -import { existsSync } from 'fs-extra' import { getRoot, tmpDir } from '../utils/directory' From d3feead0e394c3100031b7d35481d6180ae85fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 11:54:10 -0300 Subject: [PATCH 16/22] fix: Remove dev detached process and copy Cypress files before running test command --- packages/cli/src/commands/test.ts | 14 ++------------ packages/cli/src/utils/generate.ts | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index 542d21eea7..a555b6b1a0 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -2,6 +2,7 @@ import { Command } from '@oclif/core' import { spawn } from 'child_process' import chokidar from 'chokidar' +import { copyCypressFiles } from '../utils/generate' import { getRoot, tmpDir } from '../utils/directory' /** @@ -28,12 +29,7 @@ const defaultIgnored = [ const testAbortController = new AbortController() async function storeTest() { - const detachedDevProcess = spawn('yarn dev', { - shell: true, - cwd: tmpDir, - stdio: 'ignore', - detached: true, - }) + await copyCypressFiles() const testProcess = spawn('yarn test:e2e', { shell: true, @@ -43,12 +39,6 @@ async function storeTest() { }) testProcess.on('close', () => { - detachedDevProcess.kill() - testAbortController.abort() - }) - - testProcess.on('exit', () => { - detachedDevProcess.kill() testAbortController.abort() }) } diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 155ae646de..ce77008145 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -75,7 +75,7 @@ function copyCoreFiles() { } } -async function copyCypressFiles() { +export async function copyCypressFiles() { try { // Cypress 9.x config file if (existsSync(`${userDir}/cypress.json`)) { From 591b8817c2e4b6d8306a74081b874fb5f9f8f2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 12:03:38 -0300 Subject: [PATCH 17/22] fix: Generate and setup `.faststore` --- packages/cli/src/commands/test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index a555b6b1a0..defe3607b5 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -2,7 +2,7 @@ import { Command } from '@oclif/core' import { spawn } from 'child_process' import chokidar from 'chokidar' -import { copyCypressFiles } from '../utils/generate' +import { generate } from '../utils/generate' import { getRoot, tmpDir } from '../utils/directory' /** @@ -29,8 +29,6 @@ const defaultIgnored = [ const testAbortController = new AbortController() async function storeTest() { - await copyCypressFiles() - const testProcess = spawn('yarn test:e2e', { shell: true, cwd: tmpDir, @@ -61,6 +59,8 @@ export default class Test extends Command { watcher.close() }) + await generate({ setup: true }) + storeTest() return await new Promise((resolve, reject) => { From 3a40c207e09fd28b057bbe157c69a1e517b646b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 15:14:16 -0300 Subject: [PATCH 18/22] fix: Check custom Cypress folder before copying --- packages/cli/src/utils/generate.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index ce77008145..2824f76ac5 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -87,9 +87,13 @@ export async function copyCypressFiles() { copySync(`${userDir}/cypress.config.ts`, `${tmpDir}/cypress.config.ts`) } - // Copy custom Cypress folder and files const userStoreConfig = await import(userStoreConfigFileDir) - if (userStoreConfig?.experimental?.enableCypressExtension) { + + // Copy custom Cypress folder and files + if ( + existsSync(`${userDir}/cypress`) && + userStoreConfig?.experimental?.enableCypressExtension + ) { copySync(`${userDir}/cypress`, `${tmpDir}/cypress`, { overwrite: true, }) From 1638545227f1c575800dc9c80747ffffd2752354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 16:22:07 -0300 Subject: [PATCH 19/22] docs: Improve Cypress extension docs --- .../faststore-config-options/custom-cypress-test.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx index 777ea6af39..3bab513494 100644 --- a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx +++ b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx @@ -30,10 +30,10 @@ Learn how to add custom integration tests in the following steps. - Refer to [Cypress documentation](https://docs.cypress.io/guides/overview/why-cypress) for more information on this testing tool. -- Ensure that you are using `@faststore/core` version 2.1.56 or above and `@faststore/cli` version 2.2.6 or above. If you have a version that is lower than this requirement, change the following: +- Ensure that you are using `@faststore/core` version `2.1.56` or above and `@faststore/cli` version `2.2.6` or above. If you have a version that is lower than this requirement, change the following: 1. In your storefront project, open the `package.json` file. - 2. Navigate to the `@faststore/core` and and update them to be at least `2.1.56`. - 3. Navigate to the `@faststore/cli` and and update them to be at least `2.2.6`. + 2. Navigate to the `@faststore/core` and update it to be at least `2.1.56`. + 3. Navigate to the `@faststore/cli` and update it to be at least `2.2.6`. 4. Run `yarn dev` to update your changes. --- @@ -51,10 +51,10 @@ Learn how to add custom integration tests in the following steps. } ``` ---- - ## Step 2: Integrating custom Cypress tests into your FastStore project +Just like any other project using Cypress, all standard Cypress folders and configuration files are supported. (see official Cypress configuration guide [here](https://docs.cypress.io/guides/references/configuration)) + 1. In the root directory of your storefront project, create a new folder named `cypress`. 2. Add your custom integration tests within the `cypress/integration` folder. 3. With the local server running, run `yarn test` to open the Cypress app and to check your tests execution. From 69038135abccc0fae74c5d3a6fc994b2d88611af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 16:36:44 -0300 Subject: [PATCH 20/22] fix: Remove export of `copyCypressFiles` function --- packages/cli/src/utils/generate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 2824f76ac5..786bfb6830 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -75,7 +75,7 @@ function copyCoreFiles() { } } -export async function copyCypressFiles() { +async function copyCypressFiles() { try { // Cypress 9.x config file if (existsSync(`${userDir}/cypress.json`)) { From 7b8441ddf415fce131ce72728f9c8bb0ade30b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 17:27:15 -0300 Subject: [PATCH 21/22] fix: Apply suggestions from code review Co-authored-by: Mariana Caetano Pereira <67270558+Mariana-Caetano@users.noreply.github.com> --- .../faststore-config-options/custom-cypress-test.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx index 3bab513494..e4375c495a 100644 --- a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx +++ b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx @@ -30,11 +30,11 @@ Learn how to add custom integration tests in the following steps. - Refer to [Cypress documentation](https://docs.cypress.io/guides/overview/why-cypress) for more information on this testing tool. -- Ensure that you are using `@faststore/core` version `2.1.56` or above and `@faststore/cli` version `2.2.6` or above. If you have a version that is lower than this requirement, change the following: +- Ensure you are using `@faststore/core` `2.1.56` version or above and `@faststore/cli` version `2.2.6` or above. If you have versions lower than these requirements, update them as follows: 1. In your storefront project, open the `package.json` file. - 2. Navigate to the `@faststore/core` and update it to be at least `2.1.56`. - 3. Navigate to the `@faststore/cli` and update it to be at least `2.2.6`. - 4. Run `yarn dev` to update your changes. + 2. Navigate to the `@faststore/core` and update it to at least `2.1.56`. + 3. Navigate to the `@faststore/cli` and update it to at least `2.2.6`. + 4. Run `yarn dev` to apply these changes. --- @@ -53,7 +53,7 @@ Learn how to add custom integration tests in the following steps. ## Step 2: Integrating custom Cypress tests into your FastStore project -Just like any other project using Cypress, all standard Cypress folders and configuration files are supported. (see official Cypress configuration guide [here](https://docs.cypress.io/guides/references/configuration)) +Like any other project using Cypress, you'll follow standard practices, including setting up standard Cypress folders and configuration files. This allows you to seamlessly add and execute your custom integration tests within your project. For further details on Cypress configuration, refer to the official [Cypress configuration](https://docs.cypress.io/guides/references/configuration) guide. 1. In the root directory of your storefront project, create a new folder named `cypress`. 2. Add your custom integration tests within the `cypress/integration` folder. From 721022f727902a79642f15182b55074b12b4f5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Feij=C3=B3?= Date: Tue, 31 Oct 2023 17:27:53 -0300 Subject: [PATCH 22/22] fix: Step number 6 --- .../pages/docs/faststore-config-options/custom-cypress-test.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx index e4375c495a..1c6b038ef1 100644 --- a/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx +++ b/apps/site/pages/docs/faststore-config-options/custom-cypress-test.mdx @@ -63,4 +63,4 @@ Like any other project using Cypress, you'll follow standard practices, includin ![checks-integration-tests](https://vtexhelp.vtexassets.com/assets/docs/src/custom-test-checks___583ac9b78e43ebdafde93a735a47d61b.png) -5. Review the results to check the execution status of your custom integration tests. +6. Review the results to check the execution status of your custom integration tests.