Skip to content

Commit 2dcfa7d

Browse files
Merge pull request #3234 from SalesforceCommerceCloud/develop
update `feature/manual-bonus-products-v3` with `develop`
2 parents 04c37a2 + 7df11fe commit 2dcfa7d

File tree

67 files changed

+1221
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1221
-291
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/actions/e2e_validate_generated_app/action.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,21 @@ runs:
1414
steps:
1515
- name: Validate generated project
1616
run: |
17-
set -e
18-
COMMAND="node e2e/scripts/validate-generated-project.js ${{ inputs.PROJECT_KEY }}"
17+
set -euo pipefail
18+
19+
COMMAND=(node e2e/scripts/validate-generated-project.js "${{ inputs.PROJECT_KEY }}")
20+
1921
if [[ -n "${{ inputs.TEMPLATE_VERSION }}" ]]; then
20-
COMMAND="$COMMAND --templateVersion ${{ inputs.TEMPLATE_VERSION }}"
22+
COMMAND+=(--templateVersion "${{ inputs.TEMPLATE_VERSION }}")
2123
fi
22-
$COMMAND
24+
25+
echo "Executing command: ${COMMAND[*]}"
26+
27+
if ! "${COMMAND[@]}"; then
28+
echo "❌ Node.js validation script failed with exit code $?"
29+
echo "::error::Validation of generated project failed"
30+
exit 1
31+
fi
32+
33+
echo "✅ Project validation completed successfully"
2334
shell: bash

.github/workflows/e2e-pr.yml

Lines changed: 182 additions & 182 deletions
Large diffs are not rendered by default.

.github/workflows/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ jobs:
266266

267267
- name: Run a11y test for Node 22 with npm 11
268268
if: env.IS_MRT_NODE == 'true'
269-
run: npm run test:e2e:a11y
269+
run: npm run test:e2e:a11y:slas-public-client
270270

271271
notify-slack-pwa-ext:
272272
needs: [run-generator-retail-app-ext]

.github/workflows/test.yml

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ jobs:
8787
- name: Run unit tests
8888
uses: "./.github/actions/unit_tests"
8989

90-
91-
9290
- name: Smoke test scripts
9391
if: env.IS_DEFAULT_NPM == 'true'
9492
uses: "./.github/actions/smoke_tests"
@@ -119,8 +117,20 @@ jobs:
119117
if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true'
120118
uses: "./.github/actions/check_clean"
121119

120+
- name: Check if monorepo version is a dev version
121+
run: |-
122+
version=`jq -r ".version" package.json`
123+
echo "The monorepo version is $version"
124+
if echo "$version" | grep -Eiq "[0-9]-dev(\.|$)"; then
125+
echo "Dev version detected."
126+
echo "IS_DEV_VERSION=true" >> "$GITHUB_ENV"
127+
else
128+
echo "Monorepo is not on a dev version."
129+
echo "IS_DEV_VERSION=false" >> "$GITHUB_ENV"
130+
fi
131+
122132
- name: Publish to NPM
123-
if: env.IS_NOT_FORK == 'true' && env.IS_MRT_NODE == 'true' && env.RELEASE == 'true'
133+
if: env.IS_NOT_FORK == 'true' && env.IS_MRT_NODE == 'true' && env.RELEASE == 'true' && env.IS_DEV_VERSION == 'false'
124134
uses: "./.github/actions/publish_to_npm"
125135
with:
126136
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
@@ -188,7 +198,6 @@ jobs:
188198
runs-on: ubuntu-latest
189199
env:
190200
IS_TEMPLATE_FROM_RETAIL_REACT_APP: ${{ matrix.template == 'retail-react-app-test-project' || matrix.template == 'retail-react-app-demo' }}
191-
PROJECT_DIR: generated-${{ matrix.template }}
192201
steps:
193202
- name: Checkout
194203
uses: actions/checkout@v4
@@ -201,31 +210,39 @@ jobs:
201210
- name: Setup Ubuntu Machine
202211
uses: "./.github/actions/setup_ubuntu"
203212

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+
204221
- name: Generate ${{ matrix.template }} project
205222
run: |-
206-
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 }}"
207224
env:
208225
GENERATOR_PRESET: ${{ matrix.template }}
209226
timeout-minutes: 8
210227

211-
212-
213228
- name: Run unit tests
214229
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
215230
uses: "./.github/actions/unit_tests"
216231
with:
217-
cwd: ${{ env.PROJECT_DIR }}
232+
cwd: ${{ env.PATH_TO_PROJECT_DIR }}
218233

219234
- name: Run smoke tests
220235
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
221236
uses: "./.github/actions/smoke_tests"
222237
with:
223-
dir: ${{ env.PROJECT_DIR }}
238+
dir: ${{ env.PATH_TO_PROJECT_DIR }}
224239

225240
- name: Count Generated Project Dependencies
226241
id: count_deps
227242
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
228243
uses: "./.github/actions/count_deps"
244+
with:
245+
project_dir: ${{ env.PATH_TO_PROJECT_DIR }}
229246

230247
- name: Store Verdaccio logfile artifact
231248
uses: actions/upload-artifact@v4
@@ -260,7 +277,7 @@ jobs:
260277
if: env.IS_NOT_FORK == 'true' && env.DEVELOP == 'true' && matrix.template == 'retail-react-app-test-project'
261278
uses: "./.github/actions/push_to_mrt"
262279
with:
263-
CWD: ${{ env.PROJECT_DIR }}
280+
CWD: ${{ env.PATH_TO_PROJECT_DIR }}
264281
TARGET: generated-pwa
265282

266283
- name: Send GitHub Action data to Slack workflow (Generated)
@@ -283,7 +300,6 @@ jobs:
283300
runs-on: windows-latest
284301
env:
285302
IS_TEMPLATE_FROM_RETAIL_REACT_APP: ${{ matrix.template == 'retail-react-app-test-project' || matrix.template == 'retail-react-app-demo' }}
286-
PROJECT_DIR: generated-${{ matrix.template }}
287303
steps:
288304
- name: Checkout
289305
uses: actions/checkout@v4
@@ -296,30 +312,40 @@ jobs:
296312
- name: Setup Windows Machine
297313
uses: "./.github/actions/setup_windows"
298314

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+
299325
- name: Generate ${{ matrix.template }} project
300326
run: |-
301-
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 }}"
302328
env:
303329
GENERATOR_PRESET: ${{ matrix.template }}
304330
timeout-minutes: 7
305331

306-
307-
308332
- name: Run unit tests
309333
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
310334
uses: "./.github/actions/unit_tests"
311335
with:
312-
cwd: ${{ env.PROJECT_DIR }}
336+
cwd: ${{ env.PATH_TO_PROJECT_DIR }}
313337

314338
- name: Run smoke tests
315339
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
316340
uses: "./.github/actions/smoke_tests"
317341
with:
318-
dir: ${{ env.PROJECT_DIR }}
342+
dir: ${{ env.PATH_TO_PROJECT_DIR }}
319343

320344
- name: Count Generated Project Dependencies
321345
if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true'
322346
uses: "./.github/actions/count_deps"
347+
with:
348+
project_dir: ${{ env.PATH_TO_PROJECT_DIR }}
323349

324350
- name: Store Verdaccio logfile artifact
325351
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/pageHelpers.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -594,32 +594,23 @@ export const registeredUserHappyPath = async ({page, registeredUserCredentials,
594594
// Confirm the shipping details form toggles to show edit button on clicking "Checkout as guest"
595595
const step1Card = page.locator("div[data-testid='sf-toggle-card-step-1']")
596596

597-
await expect(step1Card.getByRole('button', {name: /Edit/i})).toBeVisible()
597+
await expect(step1Card.getByRole('button', {name: /Edit Shipping Address/i})).toBeVisible()
598598

599599
await expect(page.getByRole('heading', {name: /Shipping & Gift Options/i})).toBeVisible()
600600
await page.waitForLoadState()
601601
if (checkA11y) {
602602
await runAccessibilityTest(page, [snapShotName, 'checkout-a11y-violations-step-2.json'])
603603
}
604604

605-
const continueToPayment = page.getByRole('button', {
606-
name: /Continue to Payment/i
607-
})
605+
const continueToPayment = page.getByRole('button', {name: /Continue to Payment/i})
608606

609-
let hasShippingStep = false
610-
try {
611-
await expect(continueToPayment).toBeVisible({timeout: 2000})
607+
// If the Continue to Payment button is not visible, the payment details form is already being shown, so we can skip this step.
608+
if ((await continueToPayment.count()) > 0 && (await continueToPayment.isEnabled())) {
612609
await continueToPayment.click()
613-
hasShippingStep = true
614-
} catch {
615-
// Shipping step was skipped, proceed directly to payment
616610
}
617611

618-
// Verify step-2 edit button only if shipping step was present
619-
if (hasShippingStep) {
620-
const step2Card = page.locator("div[data-testid='sf-toggle-card-step-2']")
621-
await expect(step2Card.getByRole('button', {name: /Edit/i})).toBeVisible()
622-
}
612+
const step2Card = page.locator("div[data-testid='sf-toggle-card-step-2']")
613+
await expect(step2Card.getByRole('button', {name: /Edit Shipping Options/i})).toBeVisible()
623614

624615
await expect(page.getByRole('heading', {name: /Payment/i})).toBeVisible()
625616

@@ -635,10 +626,9 @@ export const registeredUserHappyPath = async ({page, registeredUserCredentials,
635626

636627
await page.getByRole('button', {name: /Review Order/i}).click()
637628

638-
// Confirm the shipping options form toggles to show edit button on clicking "Checkout as guest"
639629
const step3Card = page.locator("div[data-testid='sf-toggle-card-step-3']")
640630

641-
await expect(step3Card.getByRole('button', {name: /Edit/i})).toBeVisible()
631+
await expect(step3Card.getByRole('button', {name: /Edit Payment Info/i})).toBeVisible()
642632
page.getByRole('button', {name: /Place Order/i})
643633
.first()
644634
.click()

e2e/scripts/validate-generated-project.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const validateGeneratedArtifacts = async (project) => {
2222

2323
return new Promise((resolve, reject) => {
2424
const missingArtifacts = diffArrays(
25-
config.EXPECTED_GENERATED_ARTIFACTS[project],
25+
config.EXPECTED_GENERATED_ARTIFACTS[project] || [],
2626
generatedArtifacts
2727
)
2828
if (missingArtifacts && missingArtifacts.length > 0) {
@@ -72,12 +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+
throw err
8182
}
8283
}
8384

e2e/tests/a11y/desktop/__snapshots__/guest/cart-a11y-violations.json renamed to e2e/tests/a11y/desktop/slas-private-client/__snapshots__/guest/cart-a11y-violations.json

File renamed without changes.

e2e/tests/a11y/desktop/__snapshots__/guest/checkout-a11y-violations-step-0.json renamed to e2e/tests/a11y/desktop/slas-private-client/__snapshots__/guest/checkout-a11y-violations-step-0.json

File renamed without changes.

0 commit comments

Comments
 (0)