Skip to content

Commit 7df11fe

Browse files
authored
Merge pull request #3204 from SalesforceCommerceCloud/bugfix/pin-testing-library-version
@W-19443536 - [Bugfix] Fix unit test failures in generated projects
2 parents ac63b3a + bcd1f65 commit 7df11fe

File tree

14 files changed

+72
-35
lines changed

14 files changed

+72
-35
lines changed

.github/actions/count_deps/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
name: count_deps
2+
inputs:
3+
project_dir:
4+
description: 'Path to the project directory'
5+
required: true
26
runs:
37
using: composite
48
steps:
59
- name: Count Generated Project Dependencies
610
# TODO: Can TOTAL_PACKAGES be exported in a cleaner way?
711
run: |-
812
MAX_PACKAGES="2260"
9-
total=$(./scripts/count-dependencies.js generated-${{ matrix.template }})
13+
total=$(./scripts/count-dependencies.js "${{ inputs.project_dir }}")
1014
echo "TOTAL_PACKAGES=${total}" >> $GITHUB_ENV
1115
1216
if [ "$total" -gt "$MAX_PACKAGES" ]; then

.github/workflows/test.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ jobs:
198198
runs-on: ubuntu-latest
199199
env:
200200
IS_TEMPLATE_FROM_RETAIL_REACT_APP: ${{ matrix.template == 'retail-react-app-test-project' || matrix.template == 'retail-react-app-demo' }}
201-
PROJECT_DIR: generated-${{ matrix.template }}
202201
steps:
203202
- name: Checkout
204203
uses: actions/checkout@v4
@@ -211,9 +210,17 @@ jobs:
211210
- name: Setup Ubuntu Machine
212211
uses: "./.github/actions/setup_ubuntu"
213212

213+
- name: Set project directory with generated projects path
214+
run: |
215+
GENERATED_PROJECTS_DIR=$(node -e "console.log(require('./e2e/config.js').GENERATED_PROJECTS_DIR)")
216+
echo "PATH_TO_PROJECT_DIR=$GENERATED_PROJECTS_DIR/generated-${{ matrix.template }}" >> $GITHUB_ENV
217+
218+
- name: Create generated-projects directory
219+
run: mkdir -p "$(dirname "${{ env.PATH_TO_PROJECT_DIR }}")"
220+
214221
- name: Generate ${{ matrix.template }} project
215222
run: |-
216-
node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }}
223+
node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir "${{ env.PATH_TO_PROJECT_DIR }}"
217224
env:
218225
GENERATOR_PRESET: ${{ matrix.template }}
219226
timeout-minutes: 8
@@ -222,18 +229,20 @@ jobs:
222229
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
223230
uses: "./.github/actions/unit_tests"
224231
with:
225-
cwd: ${{ env.PROJECT_DIR }}
232+
cwd: ${{ env.PATH_TO_PROJECT_DIR }}
226233

227234
- name: Run smoke tests
228235
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
229236
uses: "./.github/actions/smoke_tests"
230237
with:
231-
dir: ${{ env.PROJECT_DIR }}
238+
dir: ${{ env.PATH_TO_PROJECT_DIR }}
232239

233240
- name: Count Generated Project Dependencies
234241
id: count_deps
235242
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
236243
uses: "./.github/actions/count_deps"
244+
with:
245+
project_dir: ${{ env.PATH_TO_PROJECT_DIR }}
237246

238247
- name: Store Verdaccio logfile artifact
239248
uses: actions/upload-artifact@v4
@@ -268,7 +277,7 @@ jobs:
268277
if: env.IS_NOT_FORK == 'true' && env.DEVELOP == 'true' && matrix.template == 'retail-react-app-test-project'
269278
uses: "./.github/actions/push_to_mrt"
270279
with:
271-
CWD: ${{ env.PROJECT_DIR }}
280+
CWD: ${{ env.PATH_TO_PROJECT_DIR }}
272281
TARGET: generated-pwa
273282

274283
- name: Send GitHub Action data to Slack workflow (Generated)
@@ -291,7 +300,6 @@ jobs:
291300
runs-on: windows-latest
292301
env:
293302
IS_TEMPLATE_FROM_RETAIL_REACT_APP: ${{ matrix.template == 'retail-react-app-test-project' || matrix.template == 'retail-react-app-demo' }}
294-
PROJECT_DIR: generated-${{ matrix.template }}
295303
steps:
296304
- name: Checkout
297305
uses: actions/checkout@v4
@@ -304,9 +312,19 @@ jobs:
304312
- name: Setup Windows Machine
305313
uses: "./.github/actions/setup_windows"
306314

315+
- name: Set project directory with generated projects path
316+
run: |
317+
GENERATED_PROJECTS_DIR=$(node -e "console.log(require('./e2e/config.js').GENERATED_PROJECTS_DIR)")
318+
echo "PATH_TO_PROJECT_DIR=$GENERATED_PROJECTS_DIR/generated-${{ matrix.template }}" >> $GITHUB_ENV
319+
shell: bash
320+
321+
- name: Create generated-projects directory
322+
run: mkdir -p "$(dirname "${{ env.PATH_TO_PROJECT_DIR }}")"
323+
shell: bash
324+
307325
- name: Generate ${{ matrix.template }} project
308326
run: |-
309-
node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }}
327+
node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir "${{ env.PATH_TO_PROJECT_DIR }}"
310328
env:
311329
GENERATOR_PRESET: ${{ matrix.template }}
312330
timeout-minutes: 7
@@ -315,17 +333,19 @@ jobs:
315333
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
316334
uses: "./.github/actions/unit_tests"
317335
with:
318-
cwd: ${{ env.PROJECT_DIR }}
336+
cwd: ${{ env.PATH_TO_PROJECT_DIR }}
319337

320338
- name: Run smoke tests
321339
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
322340
uses: "./.github/actions/smoke_tests"
323341
with:
324-
dir: ${{ env.PROJECT_DIR }}
342+
dir: ${{ env.PATH_TO_PROJECT_DIR }}
325343

326344
- name: Count Generated Project Dependencies
327345
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
328346
uses: "./.github/actions/count_deps"
347+
with:
348+
project_dir: ${{ env.PATH_TO_PROJECT_DIR }}
329349

330350
- name: Store Verdaccio logfile artifact
331351
uses: actions/upload-artifact@v4

e2e/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = {
3434
},
3535
{
3636
expectedPrompt: /Do you wish to use template extensibility?/i,
37-
response: '2\n'
37+
response: '1\n'
3838
},
3939
{
4040
expectedPrompt: /What is the name of your Project?/i,
@@ -72,7 +72,7 @@ module.exports = {
7272
},
7373
{
7474
expectedPrompt: /Do you wish to use template extensibility?/i,
75-
response: '1\n'
75+
response: '2\n'
7676
},
7777
{
7878
expectedPrompt: /What is the name of your Project?/i,

e2e/scripts/validate-generated-project.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ const main = async (opts) => {
7272
}
7373

7474
try {
75-
console.log(await validateGeneratedArtifacts(project))
76-
if (project === 'retail-app-ext' || project === 'retail-app-ext') {
77-
console.log(await validateExtensibilityConfig(project, templateVersion))
75+
await validateGeneratedArtifacts(project)
76+
if (project === 'retail-app-ext') {
77+
await validateExtensibilityConfig(project, templateVersion)
7878
}
7979
} catch (err) {
8080
console.error(err)
81-
process.exit(1)
81+
throw err
8282
}
8383
}
8484

packages/commerce-sdk-react/package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/commerce-sdk-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@tanstack/react-query": "^4.28.0",
5050
"@testing-library/jest-dom": "^5.16.5",
5151
"@testing-library/react": "^14.0.0",
52-
"@testing-library/user-event": "^14.4.3",
52+
"@testing-library/user-event": "14.4.3",
5353
"@types/js-cookie": "~3.0.3",
5454
"@types/jsdom": "^16.2.15",
5555
"@types/jsonwebtoken": "~9.0.0",

packages/pwa-kit-create-app/program.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
"description": "",
364364
"templateId": "retail-react-app",
365365
"answers": {
366-
"project.extend": true,
366+
"project.extend": false,
367367
"project.hybrid": false,
368368
"project.name": "retail-react-app",
369369
"project.commerce.instanceUrl": "https://zzrf-001.dx.commercecloud.salesforce.com",

packages/pwa-kit-react-sdk/package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/pwa-kit-react-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@salesforce/pwa-kit-dev": "3.12.0-dev.1",
6060
"@testing-library/jest-dom": "^5.16.5",
6161
"@testing-library/react": "^14.0.0",
62-
"@testing-library/user-event": "^14.4.3",
62+
"@testing-library/user-event": "14.4.3",
6363
"internal-lib-build": "3.12.0-dev.1",
6464
"node-html-parser": "^3.3.6",
6565
"nodemon": "^2.0.22",

packages/template-retail-react-app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [Bugfix] Pin `@chakra-ui/react` version to 2.7.0 to avoid breaking changes from 2.10.9 [#2658](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2658)
99
- Introduce optional prop `hybridAuthEnabled` to control Hybrid Auth specific behaviors in commerce-sdk-react [#3151](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3151)
1010
- Inject sfdc_user_agent request header into all SCAPI requests for debugging and metrics prupose [#3183](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3183)
11+
- [Bugfix] Fix unit test failures in generated projects [3204](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3204)
1112

1213
## v7.0.0 (July 22, 2025)
1314

0 commit comments

Comments
 (0)