Merge branch 'trunk' into add/sync_of_deleted_orders

This commit is contained in:
Nestor Soriano 2023-03-24 17:00:29 +01:00
commit 33ce695cd2
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
552 changed files with 16074 additions and 7846 deletions

View File

@ -0,0 +1,38 @@
name: Run API tests
description: Runs the WooCommerce Core API tests and generates Allure report.
permissions: {}
inputs:
report-name:
description: Name of Allure report to be generated.
required: true
tests:
description: Specific tests to run, separated by single whitespace. See https://playwright.dev/docs/test-cli
runs:
using: composite
steps:
- name: Run API tests.
id: run-api-tests
working-directory: plugins/woocommerce
shell: bash
run: |
pnpm exec playwright test \
--config=tests/api-core-tests/playwright.config.js \
${{ inputs.tests }}
- name: Generate Test report.
if: success() || ( failure() && steps.run-api-tests.conclusion == 'failure' )
working-directory: plugins/woocommerce
shell: bash
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
- name: Archive test report
if: success() || ( failure() && steps.run-api-tests.conclusion == 'failure' )
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.report-name }}
path: |
${{ env.ALLURE_RESULTS_DIR }}
${{ env.ALLURE_REPORT_DIR }}
retention-days: 20

View File

@ -0,0 +1,49 @@
name: Run E2E tests
description: Runs the WooCommerce Core E2E tests and generates Allure report.
permissions: {}
inputs:
report-name:
description: Name of Allure report to be generated.
required: true
tests:
description: Specific tests to run, separated by single whitespace. See https://playwright.dev/docs/test-cli
playwright-config:
description: The Playwright configuration file to use.
default: playwright.config.js
runs:
using: composite
steps:
- name: Download and install Chromium browser.
working-directory: plugins/woocommerce
shell: bash
run: pnpm exec playwright install chromium
- name: Run E2E tests.
id: run-e2e-tests
env:
FORCE_COLOR: 1
USE_WP_ENV: 1
working-directory: plugins/woocommerce
shell: bash
run: |
pnpm exec playwright test \
--config=tests/e2e-pw/${{ inputs.playwright-config }} \
${{ inputs.tests }}
- name: Generate Test report.
if: success() || ( failure() && steps.run-e2e-tests.conclusion == 'failure' )
working-directory: plugins/woocommerce
shell: bash
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
- name: Archive test report
if: success() || ( failure() && steps.run-e2e-tests.conclusion == 'failure' )
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.report-name }}
path: |
${{ env.ALLURE_RESULTS_DIR }}
${{ env.ALLURE_REPORT_DIR }}
retention-days: 20

View File

@ -0,0 +1,17 @@
name: Run k6 performance tests
description: Runs the WooCommerce Core k6 performance tests.
permissions: {}
runs:
using: composite
steps:
- name: Install k6
shell: bash
run: |
curl https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1
- name: Run k6 performance tests
id: run-k6-tests
shell: bash
run: |
./k6 run plugins/woocommerce/tests/performance/tests/gh-action-pr-requests.js

View File

@ -0,0 +1,29 @@
name: Setup local test environment
description: Set up a wp-env testing environment
permissions: {}
inputs:
test-type:
required: true
type: choice
options:
- e2e
- api
- k6
runs:
using: composite
steps:
- name: Load docker images and start containers for E2E or API tests
if: ( inputs.test-type == 'e2e' ) || ( inputs.test-type == 'api' )
working-directory: plugins/woocommerce
shell: bash
run: pnpm run env:test
- name: Load docker images and start containers for k6 performance tests
if: inputs.test-type == 'k6'
working-directory: plugins/woocommerce
shell: bash
run: |
pnpm env:dev --filter=woocommerce
pnpm env:performance-init --filter=woocommerce

View File

@ -0,0 +1,41 @@
name: Send Slack alert on PR merge test failure
description: Send a Slack alert when automated tests failed on trunk after PR merge.
permissions: {}
inputs:
slack-bot-token:
required: true
channel-id:
required: true
test-type:
required: true
type: choice
options:
- E2E
- API
- k6
runs:
using: composite
steps:
- name: Compose Slack message
id: compose-slack-message
uses: actions/github-script@v6
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
SHA: ${{ github.event.pull_request.merge_commit_sha }}
TEST_TYPE: ${{ inputs.test-type }}
with:
script: |
const script = require('./.github/actions/tests/slack-alert-on-pr-merge/scripts/compose-slack-message.js')
const slackMessage = script()
core.setOutput('slack-message', slackMessage)
- name: Send Slack alert
uses: slackapi/slack-github-action@v1.23.0
env:
SLACK_BOT_TOKEN: ${{ inputs.slack-bot-token }}
with:
channel-id: ${{ inputs.channel-id }}
payload: ${{ steps.compose-slack-message.outputs.slack-message }}

View File

@ -0,0 +1,114 @@
module.exports = () => {
const {
GITHUB_BASE_REF,
GITHUB_RUN_ID,
PR_NUMBER,
PR_TITLE,
SHA,
TEST_TYPE,
} = process.env;
// Slack message blocks
const blocks = [];
const dividerBlock = {
type: 'divider',
};
const introBlock = {
type: 'section',
text: {
type: 'mrkdwn',
text: `${ TEST_TYPE } tests failed on \`${ GITHUB_BASE_REF }\` after merging PR <https://github.com/woocommerce/woocommerce/pull/${ PR_NUMBER }|#${ PR_NUMBER }>`,
},
};
const prTitleBlock = {
type: 'header',
text: {
type: 'plain_text',
text: PR_TITLE,
emoji: true,
},
};
const prButtonBlock = {
type: 'actions',
elements: [
{
type: 'button',
text: {
type: 'plain_text',
text: 'View pull request :pr-merged:',
emoji: true,
},
value: 'view_pr',
url: `https://github.com/woocommerce/woocommerce/pull/${ PR_NUMBER }`,
action_id: 'view-pr',
},
],
};
const mergeCommitBlock = {
type: 'actions',
elements: [
{
type: 'button',
text: {
type: 'plain_text',
text: `View merge commit ${ SHA.substring(
0,
7
) } :alphabet-yellow-hash:`,
emoji: true,
},
value: 'view_commit',
url: `https://github.com/woocommerce/woocommerce/commit/${ SHA }`,
action_id: 'view-commit',
},
],
};
const githubBlock = {
type: 'actions',
elements: [
{
type: 'button',
text: {
type: 'plain_text',
text: 'View GitHub run log :github:',
emoji: true,
},
value: 'view_github',
url: `https://github.com/woocommerce/woocommerce/actions/runs/${ GITHUB_RUN_ID }`,
action_id: 'view-github',
},
],
};
const reportBlock = {
type: 'actions',
elements: [
{
type: 'button',
text: {
type: 'plain_text',
text: 'View test report :colorful-bar-chart:',
emoji: true,
},
value: 'view_report',
url: `https://woocommerce.github.io/woocommerce-test-reports/pr-merge/${ PR_NUMBER }/${ TEST_TYPE.toLowerCase() }`,
action_id: 'view-report',
},
],
};
// Assemble blocks
blocks.push( dividerBlock );
blocks.push( introBlock );
blocks.push( prTitleBlock );
blocks.push( prButtonBlock );
blocks.push( mergeCommitBlock );
blocks.push( githubBlock );
if ( [ 'e2e', 'api' ].includes( TEST_TYPE.toLowerCase() ) ) {
blocks.push( reportBlock );
}
blocks.push( dividerBlock );
return { blocks };
};

View File

@ -0,0 +1,37 @@
name: Upload Allure files to bucket
description: Upload Allure files to bucket.
permissions: {}
inputs:
artifact-name:
description: Name of the artifact that contains the allure-report and/or allure-results folders.
required: true
aws-region:
required: true
aws-access-key-id:
required: true
aws-secret-access-key:
required: true
s3-bucket:
required: true
include-allure-results:
dafault: false
runs:
using: composite
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-region: ${{ inputs.aws-region }}
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
- name: Upload Allure artifact
env:
ARTIFACT_NAME: ${{ inputs.artifact-name }}
S3_BUCKET: ${{ inputs.s3-bucket }}
INCLUDE_ALLURE_RESULTS: ${{ inputs.include-allure-results }}
shell: bash
working-directory: .github/actions/tests/upload-allure-files-to-bucket/scripts
run: bash upload-allure-artifact.sh

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
s3_upload () {
aws s3 cp "$1" "$2" \
--recursive
}
upload_allure_results () {
if [[ $INCLUDE_ALLURE_RESULTS != "true" ]]; then
return
fi
SOURCE="$ALLURE_RESULTS_DIR"
DESTINATION="$S3_BUCKET/artifacts/$GITHUB_RUN_ID/$ARTIFACT_NAME/allure-results"
s3_upload "$SOURCE" "$DESTINATION"
}
upload_allure_report () {
SOURCE="$ALLURE_REPORT_DIR"
DESTINATION="$S3_BUCKET/artifacts/$GITHUB_RUN_ID/$ARTIFACT_NAME/allure-report"
s3_upload "$SOURCE" "$DESTINATION"
}
upload_allure_results
upload_allure_report
EXIT_CODE=$(echo $?)
exit $EXIT_CODE

View File

@ -65,3 +65,12 @@
- plugins/woocommerce/src/Admin/**/* - plugins/woocommerce/src/Admin/**/*
- plugins/woocommerce/src/Internal/Admin/**/* - plugins/woocommerce/src/Internal/Admin/**/*
- plugins/woocommerce-admin/**/* - plugins/woocommerce-admin/**/*
'focus: performance tests [team:Solaris]':
- plugins/woocommerce/tests/performance/**/*
'focus: api tests [team:Solaris]':
- plugins/woocommerce/tests/api-core-tests/**/*
'focus: e2e tests [team:Solaris]':
- plugins/woocommerce/tests/e2e-pw/**/*

View File

@ -173,7 +173,7 @@ jobs:
return await script( { core } ) return await script( { core } )
- name: Find PR comment by github-actions[bot] - name: Find PR comment by github-actions[bot]
uses: peter-evans/find-comment@v2 uses: peter-evans/find-comment@034abe94d3191f9c89d870519735beae326f2bdb
id: find-comment id: find-comment
with: with:
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}
@ -181,7 +181,7 @@ jobs:
body-includes: Test Results Summary body-includes: Test Results Summary
- name: Create or update PR comment - name: Create or update PR comment
uses: peter-evans/create-or-update-comment@v2 uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d
with: with:
comment-id: ${{ steps.find-comment.outputs.comment-id }} comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}

View File

@ -219,7 +219,7 @@ jobs:
return await script( { core } ) return await script( { core } )
- name: Find PR comment by github-actions[bot] - name: Find PR comment by github-actions[bot]
uses: peter-evans/find-comment@v2 uses: peter-evans/find-comment@034abe94d3191f9c89d870519735beae326f2bdb
id: find-comment id: find-comment
with: with:
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}
@ -227,7 +227,7 @@ jobs:
body-includes: Test Results Summary body-includes: Test Results Summary
- name: Create or update PR comment - name: Create or update PR comment
uses: peter-evans/create-or-update-comment@v2 uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d
with: with:
comment-id: ${{ steps.find-comment.outputs.comment-id }} comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}

View File

@ -15,12 +15,14 @@ permissions: {}
jobs: jobs:
test: test:
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.user.login != 'github-actions[bot]' }} if: ${{ github.event_name != 'pull_request' || github.event.pull_request.user.login != 'github-actions[bot]' }}
name: PHP ${{ matrix.php }} WP ${{ matrix.wp }} name: PHP ${{ matrix.php }} WP ${{ matrix.wp }} ${{ matrix.hpos && 'HPOS' || '' }}
timeout-minutes: 30 timeout-minutes: 30
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
permissions: permissions:
contents: read contents: read
continue-on-error: ${{ matrix.wp == 'nightly' }} continue-on-error: ${{ matrix.wp == 'nightly' }}
env:
HPOS: ${{ matrix.hpos }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -33,6 +35,9 @@ jobs:
php: 7.4 php: 7.4
- wp: '5.9' - wp: '5.9'
php: 7.4 php: 7.4
- wp: 'latest'
php: '7.4'
hpos: true
services: services:
database: database:
image: mysql:5.6 image: mysql:5.6

View File

@ -0,0 +1,48 @@
name: Remind reviewers to also review the testing instructions.
on:
pull_request:
types: [review_requested]
permissions: {}
jobs:
add-testing-instructions-review-comment:
runs-on: ubuntu-20.04
permissions:
pull-requests: write
steps:
- name: Get the username of requested reviewers
id: get_reviewer_username
run: |
# Retrieves the username of all reviewers and stores them in a comma-separated list
reviewers=$(echo '${{ toJson(github.event.pull_request.requested_reviewers[*].login) }}' | jq -r 'map("@\(.)") | join(", ")')
echo "REVIEWERS=$reviewers" >> $GITHUB_ENV
- name: Get the name of requested teams
id: get_team_name
run: |
# Retrieves the name of all teams asked for review and stores them in a comma-separated list
teams=$(echo '${{ toJson(github.event.pull_request.requested_teams[*].slug) }}' | jq -r 'map("@woocommerce/\(.)") | join(", ")')
echo "TEAMS=$teams" >> $GITHUB_ENV
- name: Find the comment by github-actions[bot] asking for reviewing the testing instructions
uses: peter-evans/find-comment@034abe94d3191f9c89d870519735beae326f2bdb
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: please make sure to review the testing instructions
- name: Create or update PR comment asking for reviewers to review the testing instructions
uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Hi ${{ env.REVIEWERS }}, ${{ env.TEAMS }}
Apart from reviewing the code changes, please make sure to review the testing instructions as well.
You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions
edit-mode: replace

View File

@ -0,0 +1,168 @@
name: Run tests against trunk after PR merge
on:
pull_request:
types:
- closed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions: {}
jobs:
api:
name: Run API tests
runs-on: ubuntu-20.04
if: (github.event.pull_request.merged == true) && (github.event.pull_request.base.ref == 'trunk')
permissions:
contents: read
env:
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-results
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-report
ARTIFACT_NAME: api-pr-merge-${{ github.event.pull_request.number }}-run-${{ github.run_number }}
steps:
- name: Checkout merge commit on trunk
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
build-filters: woocommerce
- name: Setup local test environment
uses: ./.github/actions/tests/setup-local-test-environment
with:
test-type: api
- name: Run API tests
id: run-api-composite-action
uses: ./.github/actions/tests/run-api-tests
with:
report-name: ${{ env.ARTIFACT_NAME }}
- name: Upload Allure files to bucket
if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
uses: ./.github/actions/tests/upload-allure-files-to-bucket
with:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.ARTIFACT_NAME }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish Allure report
if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
run: |
gh workflow run publish-test-reports-trunk-merge.yml \
-f run_id=${{ github.run_id }} \
-f artifact=${{ env.ARTIFACT_NAME }} \
-f pr_number=${{ github.event.pull_request.number }} \
-f test_type="api" \
--repo woocommerce/woocommerce-test-reports
- name: Send Slack alert on test failure
if: failure() && steps.run-api-composite-action.conclusion == 'failure'
uses: ./.github/actions/tests/slack-alert-on-pr-merge
with:
slack-bot-token: ${{ secrets.E2E_SLACK_TOKEN }}
channel-id: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }}
test-type: API
e2e:
name: Run E2E tests
needs: [api]
runs-on: ubuntu-20.04
permissions:
contents: read
env:
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-results
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-report
ARTIFACT_NAME: e2e-pr-merge-${{ github.event.pull_request.number }}-run-${{ github.run_number }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
build-filters: woocommerce
- name: Setup local test environment
uses: ./.github/actions/tests/setup-local-test-environment
with:
test-type: e2e
- name: Run E2E tests
id: run-e2e-composite-action
timeout-minutes: 60
uses: ./.github/actions/tests/run-e2e-tests
env:
E2E_MAX_FAILURES: 15
with:
report-name: ${{ env.ARTIFACT_NAME }}
- name: Upload Allure files to bucket
if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
uses: ./.github/actions/tests/upload-allure-files-to-bucket
with:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.ARTIFACT_NAME }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
include-allure-results: false
- name: Publish Allure report
if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
run: |
gh workflow run publish-test-reports-trunk-merge.yml \
-f run_id=${{ github.run_id }} \
-f artifact=${{ env.ARTIFACT_NAME }} \
-f pr_number=${{ github.event.pull_request.number }} \
-f test_type="e2e" \
--repo woocommerce/woocommerce-test-reports
- name: Send Slack alert on test failure
if: failure() && steps.run-e2e-composite-action.conclusion == 'failure'
uses: ./.github/actions/tests/slack-alert-on-pr-merge
with:
slack-bot-token: ${{ secrets.E2E_SLACK_TOKEN }}
channel-id: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }}
test-type: E2E
k6:
name: Run k6 Performance tests
needs: [api]
runs-on: ubuntu-20.04
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
- name: Setup local test environment
uses: ./.github/actions/tests/setup-local-test-environment
with:
test-type: k6
- name: Run k6 performance tests
id: run-k6-composite-action
uses: './.github/actions/tests/run-k6-tests'
- name: Send Slack alert on test failure
if: failure() && steps.run-k6-composite-action.conclusion == 'failure'
uses: ./.github/actions/tests/slack-alert-on-pr-merge
with:
slack-bot-token: ${{ secrets.E2E_SLACK_TOKEN }}
channel-id: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }}
test-type: k6

View File

@ -12,9 +12,8 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
permissions: {} permissions: {}
env: env:
E2E_WP_LATEST_ARTIFACT: e2e-wp-latest--run-${{ github.run_number }} E2E_WP_LATEST_ARTIFACT: E2E test on release smoke test site with WP Latest (run ${{ github.run_number }})
E2E_UPDATE_WC_ARTIFACT: e2e-update-wc--run-${{ github.run_number }} E2E_UPDATE_WC_ARTIFACT: WooCommerce version update test on release smoke test site (run ${{ github.run_number }})
FORCE_COLOR: 1
jobs: jobs:
get-tag: get-tag:
@ -80,12 +79,13 @@ jobs:
install-filters: woocommerce install-filters: woocommerce
build: false build: false
- name: Download and install Chromium browser. - name: Run E2E tests
working-directory: plugins/woocommerce id: run-e2e-composite-action
run: pnpm exec playwright install chromium timeout-minutes: 60
uses: ./.github/actions/tests/run-e2e-tests
- name: Run 'Update WooCommerce' test. with:
working-directory: plugins/woocommerce report-name: ${{ env.E2E_UPDATE_WC_ARTIFACT }}
tests: update-woocommerce.spec.js
env: env:
ADMIN_PASSWORD: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }} ADMIN_PASSWORD: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }}
ADMIN_USER: ${{ secrets.RELEASE_TEST_ADMIN_USER }} ADMIN_USER: ${{ secrets.RELEASE_TEST_ADMIN_USER }}
@ -95,36 +95,19 @@ jobs:
DEFAULT_TIMEOUT_OVERRIDE: 120000 DEFAULT_TIMEOUT_OVERRIDE: 120000
GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
UPDATE_WC: ${{ needs.get-tag.outputs.tag }} UPDATE_WC: ${{ needs.get-tag.outputs.tag }}
run: |
pnpm exec playwright test \
--config=tests/e2e-pw/playwright.config.js \
update-woocommerce.spec.js
- name: Generate 'Update WooCommerce' test report. - name: Upload Allure artifacts to bucket
if: success() || failure() if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
working-directory: plugins/woocommerce uses: ./.github/actions/tests/upload-allure-files-to-bucket
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
- name: Configure AWS credentials
if: success() || failure()
uses: aws-actions/configure-aws-credentials@v1-node16
with: with:
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.E2E_WP_LATEST_ARTIFACT }}
- name: Upload Allure files to bucket s3-bucket: ${{ secrets.REPORTS_BUCKET }}
if: success() || failure()
run: |
aws s3 sync ${{ env.ALLURE_RESULTS_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_WP_LATEST_ARTIFACT }}/allure-results \
--quiet
aws s3 sync ${{ env.ALLURE_REPORT_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_WP_LATEST_ARTIFACT }}/allure-report \
--quiet
- name: Publish E2E Allure report - name: Publish E2E Allure report
if: success() || failure() if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
env: env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
ENV_DESCRIPTION: wp-latest ENV_DESCRIPTION: wp-latest
@ -139,17 +122,6 @@ jobs:
-f test_type="e2e" \ -f test_type="e2e" \
--repo woocommerce/woocommerce-test-reports --repo woocommerce/woocommerce-test-reports
- name: Archive 'Update WooCommerce' test report
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: ${{ env.E2E_UPDATE_WC_ARTIFACT }}
path: |
${{ env.ALLURE_RESULTS_DIR }}
${{ env.ALLURE_REPORT_DIR }}
if-no-files-found: ignore
retention-days: 5
api-wp-latest: api-wp-latest:
name: API on WP Latest name: API on WP Latest
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -159,7 +131,7 @@ jobs:
env: env:
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-report ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-report
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-results ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-results
API_WP_LATEST_ARTIFACT: api-wp-latest--run-${{ github.run_number }} API_WP_LATEST_ARTIFACT: API test on release smoke test site with WP Latest (run ${{ github.run_number }})
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -169,41 +141,29 @@ jobs:
install-filters: woocommerce install-filters: woocommerce
build: false build: false
- name: Run API tests. - name: Run API tests
working-directory: plugins/woocommerce id: run-api-composite-action
uses: ./.github/actions/tests/run-api-tests
with:
report-name: ${{ env.API_WP_LATEST_ARTIFACT }}
tests: hello
env: env:
BASE_URL: ${{ secrets.RELEASE_TEST_URL }} BASE_URL: ${{ secrets.RELEASE_TEST_URL }}
USER_KEY: ${{ secrets.RELEASE_TEST_ADMIN_USER }} USER_KEY: ${{ secrets.RELEASE_TEST_ADMIN_USER }}
USER_SECRET: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }} USER_SECRET: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }}
run: pnpm exec playwright test --config=tests/api-core-tests/playwright.config.js hello
- name: Generate API Test report. - name: Upload Allure artifacts to bucket
if: success() || failure() if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
working-directory: plugins/woocommerce uses: ./.github/actions/tests/upload-allure-files-to-bucket
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
- name: Configure AWS credentials
if: success() || failure()
uses: aws-actions/configure-aws-credentials@v1-node16
with: with:
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.API_WP_LATEST_ARTIFACT }}
- name: Upload Allure files to bucket s3-bucket: ${{ secrets.REPORTS_BUCKET }}
if: success() || failure()
run: |
aws s3 cp ${{ env.ALLURE_RESULTS_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.API_WP_LATEST_ARTIFACT }}/allure-results \
--recursive \
--quiet
aws s3 cp ${{ env.ALLURE_REPORT_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.API_WP_LATEST_ARTIFACT }}/allure-report \
--recursive \
--quiet
- name: Publish API Allure report - name: Publish API Allure report
if: success() || failure() if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
env: env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
ENV_DESCRIPTION: wp-latest ENV_DESCRIPTION: wp-latest
@ -218,17 +178,6 @@ jobs:
-f test_type="api" \ -f test_type="api" \
--repo woocommerce/woocommerce-test-reports --repo woocommerce/woocommerce-test-reports
- name: Archive API test report
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: ${{ env.API_WP_LATEST_ARTIFACT }}
path: |
${{ env.ALLURE_RESULTS_DIR }}
${{ env.ALLURE_REPORT_DIR }}
if-no-files-found: ignore
retention-days: 5
e2e-wp-latest: e2e-wp-latest:
name: E2E on WP Latest name: E2E on WP Latest
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -247,11 +196,13 @@ jobs:
install-filters: woocommerce install-filters: woocommerce
build: false build: false
- name: Download and install Chromium browser.
working-directory: plugins/woocommerce
run: pnpm exec playwright install chromium
- name: Run E2E tests - name: Run E2E tests
id: run-e2e-composite-action
timeout-minutes: 60
uses: ./.github/actions/tests/run-e2e-tests
with:
report-name: e2e-wp-latest--partial--run-${{ github.run_number }}
playwright-config: ignore-plugin-tests.playwright.config.js
env: env:
ADMIN_PASSWORD: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }} ADMIN_PASSWORD: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }}
ADMIN_USER: ${{ secrets.RELEASE_TEST_ADMIN_USER }} ADMIN_USER: ${{ secrets.RELEASE_TEST_ADMIN_USER }}
@ -262,9 +213,6 @@ jobs:
DEFAULT_TIMEOUT_OVERRIDE: 120000 DEFAULT_TIMEOUT_OVERRIDE: 120000
E2E_MAX_FAILURES: 25 E2E_MAX_FAILURES: 25
RESET_SITE: true RESET_SITE: true
timeout-minutes: 60
working-directory: plugins/woocommerce
run: pnpm exec playwright test --config=tests/e2e-pw/ignore-plugin-tests.playwright.config.js
- name: Download 'e2e-update-wc' artifact - name: Download 'e2e-update-wc' artifact
if: success() || failure() if: success() || failure()
@ -283,23 +231,26 @@ jobs:
working-directory: plugins/woocommerce working-directory: plugins/woocommerce
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }} run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
- name: Configure AWS credentials - name: Archive E2E test report
if: success() || failure() if: success() || failure()
uses: aws-actions/configure-aws-credentials@v1-node16 uses: actions/upload-artifact@v3
with: with:
aws-region: ${{ secrets.REPORTS_AWS_REGION }} name: ${{ env.E2E_WP_LATEST_ARTIFACT }}
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }} path: |
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }} ${{ env.ALLURE_RESULTS_DIR }}
${{ env.ALLURE_REPORT_DIR }}
if-no-files-found: ignore
retention-days: 5
- name: Upload report to bucket - name: Upload Allure artifacts to bucket
if: success() || failure() if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
run: | uses: ./.github/actions/tests/upload-allure-files-to-bucket
aws s3 sync ${{ env.ALLURE_RESULTS_DIR }} \ with:
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_WP_LATEST_ARTIFACT }}/allure-results \ aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
--quiet aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws s3 sync ${{ env.ALLURE_REPORT_DIR }} \ aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_WP_LATEST_ARTIFACT }}/allure-report \ artifact-name: ${{ env.E2E_WP_LATEST_ARTIFACT }}
--quiet s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report - name: Publish E2E Allure report
if: success() || failure() if: success() || failure()
@ -317,17 +268,6 @@ jobs:
-f test_type="e2e" \ -f test_type="e2e" \
--repo woocommerce/woocommerce-test-reports --repo woocommerce/woocommerce-test-reports
- name: Archive E2E test report
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: ${{ env.E2E_WP_LATEST_ARTIFACT }}
path: |
${{ env.ALLURE_RESULTS_DIR }}
${{ env.ALLURE_REPORT_DIR }}
if-no-files-found: ignore
retention-days: 5
get-wp-versions: get-wp-versions:
name: Get WP L-1 & L-2 version numbers name: Get WP L-1 & L-2 version numbers
needs: [get-tag] needs: [get-tag]
@ -371,14 +311,15 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: [get-wp-versions] needs: [get-wp-versions]
strategy: strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.get-wp-versions.outputs.matrix) }} matrix: ${{ fromJSON(needs.get-wp-versions.outputs.matrix) }}
env: env:
API_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/api/allure-report API_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/api/allure-report
API_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/api/allure-results API_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/api/allure-results
API_WP_LATEST_X_ARTIFACT: api-${{ matrix.version.env_description }}--run-${{ github.run_number }} API_WP_LATEST_X_ARTIFACT: API test on wp-env with WordPress ${{ matrix.version.number }} (run ${{ github.run_number }})
E2E_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/e2e/allure-report E2E_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/e2e/allure-report
E2E_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/e2e/allure-results E2E_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/e2e/allure-results
E2E_WP_LATEST_X_ARTIFACT: e2e-${{ matrix.version.env_description }}--run-${{ github.run_number }} E2E_WP_LATEST_X_ARTIFACT: E2E test on wp-env with WordPress ${{ matrix.version.number }} (run ${{ github.run_number }})
permissions: permissions:
contents: read contents: read
steps: steps:
@ -414,38 +355,31 @@ jobs:
pnpm exec wp-env run tests-cli "wp theme list" pnpm exec wp-env run tests-cli "wp theme list"
pnpm exec wp-env run tests-cli "wp user list" pnpm exec wp-env run tests-cli "wp user list"
- name: Run API tests. - name: Run API tests
id: api id: run-api-composite-action
working-directory: plugins/woocommerce uses: ./.github/actions/tests/run-api-tests
with:
report-name: ${{ env.API_WP_LATEST_X_ARTIFACT }}
tests: hello
env: env:
ALLURE_RESULTS_DIR: ${{ env.API_ALLURE_RESULTS_DIR }} ALLURE_RESULTS_DIR: ${{ env.API_ALLURE_RESULTS_DIR }}
run: pnpm exec playwright test --config=tests/api-core-tests/playwright.config.js hello ALLURE_REPORT_DIR: ${{ env.API_ALLURE_REPORT_DIR }}
- name: Generate API Allure report. - name: Upload Allure artifacts to bucket
if: success() || failure() if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
working-directory: plugins/woocommerce uses: ./.github/actions/tests/upload-allure-files-to-bucket
run: pnpm exec allure generate --clean ${{ env.API_ALLURE_RESULTS_DIR }} --output ${{ env.API_ALLURE_REPORT_DIR }} env:
ALLURE_RESULTS_DIR: ${{ env.API_ALLURE_RESULTS_DIR }}
- name: Configure AWS credentials ALLURE_REPORT_DIR: ${{ env.API_ALLURE_REPORT_DIR }}
if: success() || failure()
uses: aws-actions/configure-aws-credentials@v1-node16
with: with:
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.API_WP_LATEST_X_ARTIFACT }}
- name: Upload API Allure artifacts to bucket s3-bucket: ${{ secrets.REPORTS_BUCKET }}
if: success() || failure()
run: |
aws s3 sync ${{ env.API_ALLURE_RESULTS_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.API_WP_LATEST_X_ARTIFACT }}/allure-results \
--quiet
aws s3 sync ${{ env.API_ALLURE_REPORT_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.API_WP_LATEST_X_ARTIFACT }}/allure-report \
--quiet
- name: Publish API Allure report - name: Publish API Allure report
if: success() || failure() if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
env: env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
ENV_DESCRIPTION: ${{ matrix.version.env_description }} ENV_DESCRIPTION: ${{ matrix.version.env_description }}
@ -460,65 +394,33 @@ jobs:
-f test_type="api" \ -f test_type="api" \
--repo woocommerce/woocommerce-test-reports --repo woocommerce/woocommerce-test-reports
- name: Archive API Allure reports - name: Run E2E tests
if: success() || failure() id: run-e2e-composite-action
uses: actions/upload-artifact@v3
with:
name: ${{ env.API_WP_LATEST_X_ARTIFACT }}
path: |
${{ env.API_ALLURE_RESULTS_DIR }}
${{ env.API_ALLURE_REPORT_DIR }}
if-no-files-found: ignore
retention-days: 5
- name: Download and install Chromium browser.
if: success() || failure()
working-directory: plugins/woocommerce
run: pnpm exec playwright install chromium
- name: Run E2E tests.
if: |
success() ||
( failure() && steps.api.conclusion == 'success' )
timeout-minutes: 60 timeout-minutes: 60
id: e2e uses: ./.github/actions/tests/run-e2e-tests
env: env:
USE_WP_ENV: 1
E2E_MAX_FAILURES: 15 E2E_MAX_FAILURES: 15
FORCE_COLOR: 1
ALLURE_RESULTS_DIR: ${{ env.E2E_ALLURE_RESULTS_DIR }} ALLURE_RESULTS_DIR: ${{ env.E2E_ALLURE_RESULTS_DIR }}
ALLURE_REPORT_DIR: ${{ env.E2E_ALLURE_REPORT_DIR }}
DEFAULT_TIMEOUT_OVERRIDE: 120000 DEFAULT_TIMEOUT_OVERRIDE: 120000
working-directory: plugins/woocommerce
run: pnpm exec playwright test --config=tests/e2e-pw/playwright.config.js
- name: Generate E2E Allure report.
if: success() || failure()
working-directory: plugins/woocommerce
run: pnpm exec allure generate --clean ${{ env.E2E_ALLURE_RESULTS_DIR }} --output ${{ env.E2E_ALLURE_REPORT_DIR }}
- name: Upload E2E Allure artifacts to bucket
if: success() || failure()
run: |
aws s3 sync ${{ env.E2E_ALLURE_RESULTS_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_WP_LATEST_X_ARTIFACT }}/allure-results \
--quiet
aws s3 sync ${{ env.E2E_ALLURE_REPORT_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_WP_LATEST_X_ARTIFACT }}/allure-report \
--quiet
- name: Archive E2E Allure reports
if: success() || failure()
uses: actions/upload-artifact@v3
with: with:
name: ${{ env.E2E_WP_LATEST_X_ARTIFACT }} report-name: ${{ env.E2E_WP_LATEST_X_ARTIFACT }}
path: |
${{ env.E2E_ALLURE_RESULTS_DIR }} - name: Upload Allure artifacts to bucket
${{ env.E2E_ALLURE_REPORT_DIR }} if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
if-no-files-found: ignore uses: ./.github/actions/tests/upload-allure-files-to-bucket
retention-days: 5 env:
ALLURE_RESULTS_DIR: ${{ env.E2E_ALLURE_RESULTS_DIR }}
ALLURE_REPORT_DIR: ${{ env.E2E_ALLURE_REPORT_DIR }}
with:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.E2E_WP_LATEST_X_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report - name: Publish E2E Allure report
if: success() || failure() if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
env: env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
ENV_DESCRIPTION: ${{ matrix.version.env_description }} ENV_DESCRIPTION: ${{ matrix.version.env_description }}
@ -538,15 +440,16 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: [get-tag] needs: [get-tag]
strategy: strategy:
fail-fast: false
matrix: matrix:
php_version: ['7.4', '8.1'] php_version: ['7.4', '8.1']
env: env:
API_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-report API_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-report
API_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-results API_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-results
API_ARTIFACT: api-php-${{ matrix.php_version }}--run-${{ github.run_number }} API_ARTIFACT: API test on wp-env with PHP ${{ matrix.php_version }} (run ${{ github.run_number }})
E2E_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-report E2E_ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-report
E2E_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-results E2E_ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-results
E2E_ARTIFACT: e2e-php-${{ matrix.php_version }}--run-${{ github.run_number }} E2E_ARTIFACT: E2E test on wp-env with PHP ${{ matrix.php_version }} (run ${{ github.run_number }})
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -574,38 +477,31 @@ jobs:
- name: Replace `plugins/woocommerce` with unzipped woocommerce release build - name: Replace `plugins/woocommerce` with unzipped woocommerce release build
run: unzip -d plugins -o tmp/woocommerce.zip run: unzip -d plugins -o tmp/woocommerce.zip
- name: Run API tests. - name: Run API tests
id: api id: run-api-composite-action
working-directory: plugins/woocommerce uses: ./.github/actions/tests/run-api-tests
with:
report-name: ${{ env.API_ARTIFACT }}
tests: hello
env: env:
ALLURE_RESULTS_DIR: ${{ env.API_ALLURE_RESULTS_DIR }} ALLURE_RESULTS_DIR: ${{ env.API_ALLURE_RESULTS_DIR }}
run: pnpm exec playwright test --config=tests/api-core-tests/playwright.config.js hello ALLURE_REPORT_DIR: ${{ env.API_ALLURE_REPORT_DIR }}
- name: Generate API Allure report. - name: Upload Allure artifacts to bucket
if: success() || failure() if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
working-directory: plugins/woocommerce uses: ./.github/actions/tests/upload-allure-files-to-bucket
run: pnpm exec allure generate --clean ${{ env.API_ALLURE_RESULTS_DIR }} --output ${{ env.API_ALLURE_REPORT_DIR }} env:
ALLURE_RESULTS_DIR: ${{ env.API_ALLURE_RESULTS_DIR }}
- name: Configure AWS credentials ALLURE_REPORT_DIR: ${{ env.API_ALLURE_REPORT_DIR }}
if: success() || failure()
uses: aws-actions/configure-aws-credentials@v1-node16
with: with:
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.API_ARTIFACT }}
- name: Upload API Allure artifacts to bucket s3-bucket: ${{ secrets.REPORTS_BUCKET }}
if: success() || failure()
run: |
aws s3 sync ${{ env.API_ALLURE_RESULTS_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.API_ARTIFACT }}/allure-results \
--quiet
aws s3 sync ${{ env.API_ALLURE_REPORT_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.API_ARTIFACT }}/allure-report \
--quiet
- name: Publish API Allure report - name: Publish API Allure report
if: success() || failure() if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
env: env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
ENV_DESCRIPTION: php-${{ matrix.php_version }} ENV_DESCRIPTION: php-${{ matrix.php_version }}
@ -620,63 +516,33 @@ jobs:
-f test_type="api" \ -f test_type="api" \
--repo woocommerce/woocommerce-test-reports --repo woocommerce/woocommerce-test-reports
- name: Archive API Allure reports - name: Run E2E tests
if: success() || failure() id: run-e2e-composite-action
uses: actions/upload-artifact@v3
with:
name: ${{ env.API_ARTIFACT }}
path: |
${{ env.API_ALLURE_RESULTS_DIR }}
${{ env.API_ALLURE_REPORT_DIR }}
if-no-files-found: ignore
retention-days: 5
- name: Download and install Chromium browser.
working-directory: plugins/woocommerce
run: pnpm exec playwright install chromium
- name: Run E2E tests.
if: |
success() ||
( failure() && steps.api.conclusion == 'success' )
timeout-minutes: 60 timeout-minutes: 60
uses: ./.github/actions/tests/run-e2e-tests
env: env:
USE_WP_ENV: 1
E2E_MAX_FAILURES: 15
FORCE_COLOR: 1
ALLURE_RESULTS_DIR: ${{ env.E2E_ALLURE_RESULTS_DIR }} ALLURE_RESULTS_DIR: ${{ env.E2E_ALLURE_RESULTS_DIR }}
ALLURE_REPORT_DIR: ${{ env.E2E_ALLURE_REPORT_DIR }}
DEFAULT_TIMEOUT_OVERRIDE: 120000 DEFAULT_TIMEOUT_OVERRIDE: 120000
working-directory: plugins/woocommerce E2E_MAX_FAILURES: 15
run: pnpm exec playwright test --config=tests/e2e-pw/playwright.config.js
- name: Generate E2E Allure report.
if: success() || failure()
working-directory: plugins/woocommerce
run: pnpm exec allure generate --clean ${{ env.E2E_ALLURE_RESULTS_DIR }} --output ${{ env.E2E_ALLURE_REPORT_DIR }}
- name: Upload E2E Allure artifacts to bucket
if: success() || failure()
run: |
aws s3 sync ${{ env.E2E_ALLURE_RESULTS_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_ARTIFACT }}/allure-results \
--quiet
aws s3 sync ${{ env.E2E_ALLURE_REPORT_DIR }} \
${{ secrets.REPORTS_BUCKET }}/artifacts/${{ github.run_id }}/${{ env.E2E_ARTIFACT }}/allure-report \
--quiet
- name: Archive E2E Allure reports
if: success() || failure()
uses: actions/upload-artifact@v3
with: with:
name: ${{ env.E2E_ARTIFACT }} report-name: ${{ env.E2E_ARTIFACT }}
path: |
${{ env.E2E_ALLURE_RESULTS_DIR }} - name: Upload Allure artifacts to bucket
${{ env.E2E_ALLURE_REPORT_DIR }} if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
if-no-files-found: ignore uses: ./.github/actions/tests/upload-allure-files-to-bucket
retention-days: 5 env:
ALLURE_RESULTS_DIR: ${{ env.E2E_ALLURE_RESULTS_DIR }}
ALLURE_REPORT_DIR: ${{ env.E2E_ALLURE_REPORT_DIR }}
with:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.E2E_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report - name: Publish E2E Allure report
if: success() || failure() if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
env: env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
ENV_DESCRIPTION: php-${{ matrix.php_version }} ENV_DESCRIPTION: php-${{ matrix.php_version }}
@ -690,3 +556,103 @@ jobs:
-f env_description="${{ env.ENV_DESCRIPTION }}" \ -f env_description="${{ env.ENV_DESCRIPTION }}" \
-f test_type="e2e" \ -f test_type="e2e" \
--repo woocommerce/woocommerce-test-reports --repo woocommerce/woocommerce-test-reports
test-plugins:
name: With ${{ matrix.plugin }}
runs-on: ubuntu-20.04
needs: [get-tag]
env:
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/allure-results
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/allure-report
ARTIFACT_NAME: E2E test on wp-env with ${{ matrix.plugin }} installed (run ${{ github.run_number }})
strategy:
fail-fast: false
matrix:
include:
- plugin: 'WooCommerce Payments'
repo: 'automattic/woocommerce-payments'
env_description: 'woocommerce-payments'
- plugin: 'WooCommerce PayPal Payments'
repo: 'woocommerce/woocommerce-paypal-payments'
env_description: 'woocommerce-paypal-payments'
- plugin: 'WooCommerce Shipping & Tax'
repo: 'automattic/woocommerce-services'
env_description: 'woocommerce-shipping-&-tax'
- plugin: 'WooCommerce Subscriptions'
repo: WC_SUBSCRIPTIONS_REPO
private: true
env_description: 'woocommerce-subscriptions'
- plugin: 'WordPress SEO' # Yoast SEO in the UI, but the slug is wordpress-seo
repo: 'Yoast/wordpress-seo'
env_description: 'wordpress-seo'
- plugin: 'Contact Form 7'
repo: 'takayukister/contact-form-7'
env_description: 'contact-form-7'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
- name: Launch WP Env
working-directory: plugins/woocommerce
run: pnpm run env:test
- name: Download release zip
env:
GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
run: gh release download ${{ needs.get-tag.outputs.tag }} --dir tmp
- name: Replace `plugins/woocommerce` with unzipped woocommerce release build
run: unzip -d plugins -o tmp/woocommerce.zip
- name: Run 'Upload plugin' test
id: run-upload-test
timeout-minutes: 60
uses: ./.github/actions/tests/run-e2e-tests
with:
report-name: ${{ env.ARTIFACT_NAME }}
tests: upload-plugin.spec.js
env:
GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
PLUGIN_NAME: ${{ matrix.plugin }}
PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }}
- name: Run the rest of E2E tests
id: run-e2e-composite-action
timeout-minutes: 60
uses: ./.github/actions/tests/run-e2e-tests
with:
playwright-config: ignore-plugin-tests.playwright.config.js
report-name: ${{ env.ARTIFACT_NAME }}
env:
E2E_MAX_FAILURES: 15
- name: Upload Allure artifacts to bucket
if: |
success() ||
( failure() &&
( steps.run-upload-test.conclusion == 'failure' || steps.run-e2e-composite-action.conclusion == 'failure' ) )
uses: ./.github/actions/tests/upload-allure-files-to-bucket
with:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
artifact-name: ${{ env.ARTIFACT_NAME }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report
if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
env:
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
run: |
gh workflow run publish-test-reports-release.yml \
-f created_at="${{ needs.get-tag.outputs.created }}" \
-f run_id=${{ github.run_id }} \
-f run_number=${{ github.run_number }} \
-f release_tag=${{ needs.get-tag.outputs.tag }} \
-f artifact="${{ env.ARTIFACT_NAME }}" \
-f env_description="${{ matrix.env_description }}" \
-f test_type="e2e" \
--repo woocommerce/woocommerce-test-reports

View File

@ -1,6 +1,6 @@
{ {
"dev": true, "dev": true,
"filter": "^(?:config|react|react-dom|eslint|typescript|@typescript-eslint|@types/react|@wordpress|@types/wordpress__components|postcss).*$", "filter": "^(?:config|react|react-dom|eslint|typescript|@typescript-eslint|@types/react|@wordpress|@types/wordpress__components|postcss|@types/node).*$",
"indent": "\t", "indent": "\t",
"overrides": true, "overrides": true,
"peer": true, "peer": true,
@ -59,7 +59,7 @@
"packages": [ "packages": [
"**" "**"
], ],
"pinVersion": "^4.8.3" "pinVersion": "^4.9.5"
}, },
{ {
"dependencies": [ "dependencies": [
@ -154,6 +154,15 @@
"**" "**"
], ],
"pinVersion": "^8.4.7" "pinVersion": "^8.4.7"
},
{
"dependencies": [
"@types/node"
],
"packages": [
"**"
],
"pinVersion": "^16.18.18"
} }
] ]
} }

View File

@ -1,5 +1,78 @@
== Changelog == == Changelog ==
= 7.5.1 2023-03-21 =
**WooCommerce**
* Fix - Fix no enforcing of min/max limits in quantity selector of variable products. [#36871](https://github.com/woocommerce/woocommerce/pull/36871)
* Dev - Update column definitions with synonymous types to prevent dbDelta from trying to ALTER them on each install. [#37277](https://github.com/woocommerce/woocommerce/pull/37277)
* Update - Update WooCommerce Blocks to 9.6.6. [#37298](https://github.com/woocommerce/woocommerce/pull/37298)
= 7.5.0 2023-03-14 =
**WooCommerce**
* Fix - Add HPOS support to the reserved stock query [#36535](https://github.com/woocommerce/woocommerce/pull/36535)
* Fix - Comment: Fix inconsistencies on Analytics > Orders table when using date_paid or date_completed [#36876](https://github.com/woocommerce/woocommerce/pull/36876)
* Fix - Define a public `api` property in the WooCommerce class to prevent a PHP deprecation warning [#36545](https://github.com/woocommerce/woocommerce/pull/36545)
* Fix - Don't delete order from posts table when deleted from orders table if the later is authoritative and sync is off [#36617](https://github.com/woocommerce/woocommerce/pull/36617)
* Fix - Eliminate data store internal meta keys duplicates [#36611](https://github.com/woocommerce/woocommerce/pull/36611)
* Fix - Ensure changes made via the `woocommerce_order_list_table_prepare_items_query_args` are observed. [#36649](https://github.com/woocommerce/woocommerce/pull/36649)
* Fix - Ensuring that we know if allowTracking is true before adding exit page. [#36656](https://github.com/woocommerce/woocommerce/pull/36656)
* Fix - Fix Ampersand changed to &amp on product attribute export [#36525](https://github.com/woocommerce/woocommerce/pull/36525)
* Fix - Fix decimal points for NOK currency [#36780](https://github.com/woocommerce/woocommerce/pull/36780)
* Fix - Fix inconsitent product task icon colors [#36889](https://github.com/woocommerce/woocommerce/pull/36889)
* Fix - Fix WordPress unit tests libraries being installed in a symlinked folder structure [#36641](https://github.com/woocommerce/woocommerce/pull/36641)
* Fix - Make states optional for Hungary and Bulgaria. [#36701](https://github.com/woocommerce/woocommerce/pull/36701)
* Fix - Screen ID matching switched to untranslated 'woocommerce' strings. [#36854](https://github.com/woocommerce/woocommerce/pull/36854)
* Fix - Translate the labels for units of measure. [#36708](https://github.com/woocommerce/woocommerce/pull/36708)
* Fix - Update `config@3.3.7` (from `3.3.3`). Fix `node_env_var_name is not defined` error. [#33828](https://github.com/woocommerce/woocommerce/pull/33828)
* Add - Add 'add_tab' method in FormFactory to allow plugins to extend the WooCommerce admin product form [#36583](https://github.com/woocommerce/woocommerce/pull/36583)
* Add - Add @woocommerce/product-editor dependency and change dependency of ProductSectionLayout component. [#36600](https://github.com/woocommerce/woocommerce/pull/36600)
* Add - Add additional global attributes and local attributes information when saving product attributes [#36858](https://github.com/woocommerce/woocommerce/pull/36858)
* Add - Add a new Channels card in multichannel marketing page. [#36541](https://github.com/woocommerce/woocommerce/pull/36541)
* Add - Add an experimental slot for marketing overview extensibility [#36828](https://github.com/woocommerce/woocommerce/pull/36828)
* Add - Add slot fill support for tabs for the new product management MVP. [#36551](https://github.com/woocommerce/woocommerce/pull/36551)
* Add - Add survey after disabling new experience [#36544](https://github.com/woocommerce/woocommerce/pull/36544)
* Add - Add unique sku option to error data when setting product sku [#36612](https://github.com/woocommerce/woocommerce/pull/36612)
* Add - Add WC-specific criteria to the Site Health test for persistent object caches [#35202](https://github.com/woocommerce/woocommerce/pull/35202)
* Add - Enable new experience when new user selects "Physical product". [#36406](https://github.com/woocommerce/woocommerce/pull/36406)
* Update - Update WooCommerce Blocks to 9.6.5 [#37051](https://github.com/woocommerce/woocommerce/pull/37051)
* Update - Update WooCommerce Blocks to 9.6.3 [#36992](https://github.com/woocommerce/woocommerce/pull/36992)
* Update - Update WooCommerce Blocks to 9.6.2 [#36919](https://github.com/woocommerce/woocommerce/pull/36919)
* Update - Add date_paid and date_completed date sorting options for Revenue and Order reports [#36492](https://github.com/woocommerce/woocommerce/pull/36492)
* Update - Add default value for backorders [#36607](https://github.com/woocommerce/woocommerce/pull/36607)
* Update - Add Skydropx, Envia, Sendcloud, Packlink to shipping task [#36873](https://github.com/woocommerce/woocommerce/pull/36873)
* Update - Always show comments for product feedback form [#36484](https://github.com/woocommerce/woocommerce/pull/36484)
* Update - Delete FlexSlider code for legacy browsers. [#36690](https://github.com/woocommerce/woocommerce/pull/36690)
* Update - Disable the new product editor, pending design updates. [#36894](https://github.com/woocommerce/woocommerce/pull/36894)
* Update - Have "Grow your store" appear first in marketing task by default [#36826](https://github.com/woocommerce/woocommerce/pull/36826)
* Update - Migrating product editor pricing section to slot fills. [#36500](https://github.com/woocommerce/woocommerce/pull/36500)
* Update - Refactor slot fills to ensure variant fills have distinct slots. [#36646](https://github.com/woocommerce/woocommerce/pull/36646)
* Update - Removed I.D column from product import samples [#36857](https://github.com/woocommerce/woocommerce/pull/36857)
* Update - Remove Meta from grow your store list [#36886](https://github.com/woocommerce/woocommerce/pull/36886)
* Update - Remove opinionated styles from buttons in block themes so they inherit theme styles more accurately [#36651](https://github.com/woocommerce/woocommerce/pull/36651)
* Update - Replace $.ajax() calls with browser-native window.fetch() calls. [#36275](https://github.com/woocommerce/woocommerce/pull/36275)
* Update - Update payment gateway list ordering priority and remove Klarna from North America [#36550](https://github.com/woocommerce/woocommerce/pull/36550)
* Update - Update Playwright version from 1.28.0 -> 1.30.0 [#36789](https://github.com/woocommerce/woocommerce/pull/36789)
* Update - Updates to product editor fill to support new prop API. [#36592](https://github.com/woocommerce/woocommerce/pull/36592)
* Update - Update WooCommerce Blocks 9.6.0 & 9.6.1 [#36852](https://github.com/woocommerce/woocommerce/pull/36852)
* Dev - Add attribute creation form when there are no attributes [#36606](https://github.com/woocommerce/woocommerce/pull/36606)
* Dev - Add a unit test for woocommerce_admin_experimental_onboarding_tasklists filter [#36827](https://github.com/woocommerce/woocommerce/pull/36827)
* Dev - Code refactor on marketing components. [#36540](https://github.com/woocommerce/woocommerce/pull/36540)
* Dev - Made e2e selectors more robust [#36499](https://github.com/woocommerce/woocommerce/pull/36499)
* Dev - Remove attribute type logic from attribute component [#36563](https://github.com/woocommerce/woocommerce/pull/36563)
* Dev - Update eslint to 8.32.0 across the monorepo. [#36700](https://github.com/woocommerce/woocommerce/pull/36700)
* Dev - Update pnpm command to run e2e tests for consistency. Also update docs with new command. [#35287](https://github.com/woocommerce/woocommerce/pull/35287)
* Tweak - Add IR and fields priorities to list of get_country_locale() method to follow conventional way of addressing in Iran. [#36491](https://github.com/woocommerce/woocommerce/pull/36491)
* Tweak - Add missing deprecation notice for filter hook woocommerce_my_account_my_orders_columns. [#36356](https://github.com/woocommerce/woocommerce/pull/36356)
* Tweak - Adjust default sizes for the quantity and coupon input fields within the cart page. [#29122](https://github.com/woocommerce/woocommerce/pull/29122)
* Tweak - Do not display low/out-of-stock information in the dashboard status widget when stock management is disabled. [#36703](https://github.com/woocommerce/woocommerce/pull/36703)
* Tweak - Remove free trial terms from Avalara tax task [#36888](https://github.com/woocommerce/woocommerce/pull/36888)
* Tweak - Tweak product link description and display in the new product management experience [#36591](https://github.com/woocommerce/woocommerce/pull/36591)
* Enhancement - Change the sass variable names to more predictable ones. [#28908](https://github.com/woocommerce/woocommerce/pull/28908)
= 7.4.1 2023-03-01 = = 7.4.1 2023-03-01 =
**WooCommerce** **WooCommerce**

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fix the incorrect workflow input for uploading Allure reports.

View File

@ -3,6 +3,10 @@
"title": "WooCommerce Monorepo", "title": "WooCommerce Monorepo",
"description": "Monorepo for the WooCommerce ecosystem", "description": "Monorepo for the WooCommerce ecosystem",
"homepage": "https://woocommerce.com/", "homepage": "https://woocommerce.com/",
"engines": {
"node": "^16.13.1",
"pnpm": "^7.13.3"
},
"private": true, "private": true,
"repository": { "repository": {
"type": "git", "type": "git",
@ -25,41 +29,41 @@
"sync-dependencies": "pnpm exec syncpack -- fix-mismatches" "sync-dependencies": "pnpm exec syncpack -- fix-mismatches"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-env": "^7.16.11", "@babel/preset-env": "^7.20.2",
"@babel/runtime": "^7.17.2", "@babel/runtime": "^7.21.0",
"@types/node": "14.14.33", "@types/node": "^16.18.18",
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
"@wordpress/data": "wp-6.0", "@wordpress/data": "wp-6.0",
"@wordpress/eslint-plugin": "^11.1.0", "@wordpress/eslint-plugin": "^11.1.0",
"@wordpress/prettier-config": "^1.1.1", "@wordpress/prettier-config": "^1.4.0",
"babel-loader": "^8.2.3", "babel-loader": "^8.3.0",
"chalk": "^4.1.2", "chalk": "^4.1.2",
"copy-webpack-plugin": "^10.2.4", "copy-webpack-plugin": "^10.2.4",
"core-js": "^3.21.1", "core-js": "^3.29.1",
"css-loader": "^6.7.0", "css-loader": "^6.7.3",
"glob": "^7.2.0", "glob": "^7.2.3",
"husky": "^7.0.4", "husky": "^7.0.4",
"jest": "^27.3.1", "jest": "^27.5.1",
"lint-staged": "^12.3.7", "lint-staged": "^12.5.0",
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",
"moment": "^2.29.1", "moment": "^2.29.4",
"node-stream-zip": "^1.15.0", "node-stream-zip": "^1.15.0",
"postcss-loader": "^4.3.0", "postcss-loader": "^4.3.0",
"prettier": "npm:wp-prettier@^2.2.1-beta-1", "prettier": "npm:wp-prettier@^2.6.2",
"regenerator-runtime": "^0.13.9", "regenerator-runtime": "^0.13.11",
"request": "^2.88.2", "request": "^2.88.2",
"sass": "^1.49.9", "sass": "^1.59.3",
"sass-loader": "^10.2.1", "sass-loader": "^10.4.1",
"syncpack": "^9.8.4", "syncpack": "^9.8.4",
"turbo": "^1.8.3", "turbo": "^1.8.5",
"typescript": "^4.8.3", "typescript": "^4.9.5",
"url-loader": "^1.1.2", "url-loader": "^1.1.2",
"webpack": "^5.70.0" "webpack": "^5.76.2"
}, },
"dependencies": { "dependencies": {
"@babel/core": "7.12.9", "@babel/core": "7.12.9",
"@wordpress/babel-plugin-import-jsx-pragma": "^3.1.0", "@wordpress/babel-plugin-import-jsx-pragma": "^3.2.0",
"@wordpress/babel-preset-default": "^6.4.1", "@wordpress/babel-preset-default": "^6.17.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"wp-textdomain": "1.0.1" "wp-textdomain": "1.0.1"
}, },

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -50,18 +50,18 @@
"jest-mock-extended": "^1.0.18", "jest-mock-extended": "^1.0.18",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3" "typescript": "^4.9.5"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"scripts": { "scripts": {
"turbo:build": "tsc --build", "turbo:build": "tsc --project tsconfig.json",
"prepare": "composer install", "prepare": "composer install",
"changelog": "composer exec -- changelogger", "changelog": "composer exec -- changelogger",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
"start": "tsc --build --watch", "start": "tsc --project tsconfig.json --watch",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*", "clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"lint:fix": "eslint src --fix", "lint:fix": "eslint src --fix",
"prepack": "pnpm run clean && pnpm run build" "prepack": "pnpm run clean && pnpm run build"

View File

@ -1,8 +1,11 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true,
"rootDir": "src", "rootDir": "src",
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Adding support for modifying fill name to WooHeaderItem.

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -34,9 +34,9 @@
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*", "clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "build:js": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json",
"build:css": "webpack", "build:css": "webpack",
"start": "concurrently \"tsc --build --watch\" \"webpack --watch\"", "start": "concurrently \"tsc --project tsconfig.json --watch\" \"tsc --project tsconfig-cjs.json --watch\" \"webpack --watch\"",
"prepack": "pnpm run clean && pnpm run build", "prepack": "pnpm run clean && pnpm run build",
"lint:fix": "eslint src --fix" "lint:fix": "eslint src --fix"
}, },
@ -50,12 +50,13 @@
"eslint": "^8.32.0", "eslint": "^8.32.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"jest-cli": "^27.5.1", "jest-cli": "^27.5.1",
"concurrently": "^7.0.0",
"postcss-loader": "^4.3.0", "postcss-loader": "^4.3.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"sass-loader": "^10.2.1", "sass-loader": "^10.2.1",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3", "typescript": "^4.9.5",
"webpack": "^5.70.0", "webpack": "^5.70.0",
"webpack-cli": "^3.3.12" "webpack-cli": "^3.3.12"
}, },

View File

@ -11,6 +11,20 @@ import {
export const WC_HEADER_SLOT_NAME = 'woocommerce_header_item'; export const WC_HEADER_SLOT_NAME = 'woocommerce_header_item';
/**
* Get the slot fill name for the generic header slot or a specific header if provided.
*
* @param name Name of the specific header.
* @return string
*/
const getSlotFillName = ( name?: string ) => {
if ( ! name || ! name.length ) {
return WC_HEADER_SLOT_NAME;
}
return `${ WC_HEADER_SLOT_NAME }/${ name }`;
};
/** /**
* Create a Fill for extensions to add items to the WooCommerce Admin header. * Create a Fill for extensions to add items to the WooCommerce Admin header.
* *
@ -26,17 +40,19 @@ export const WC_HEADER_SLOT_NAME = 'woocommerce_header_item';
* scope: 'woocommerce-admin', * scope: 'woocommerce-admin',
* } ); * } );
* @param {Object} param0 * @param {Object} param0
* @param {Array} param0.name - Header name.
* @param {Array} param0.children - Node children. * @param {Array} param0.children - Node children.
* @param {Array} param0.order - Node order. * @param {Array} param0.order - Node order.
*/ */
export const WooHeaderItem: React.FC< { export const WooHeaderItem: React.FC< {
name?: string;
children?: React.ReactNode; children?: React.ReactNode;
order?: number; order?: number;
} > & { } > & {
Slot: React.FC< Slot.Props >; Slot: React.FC< Slot.Props & { name?: string } >;
} = ( { children, order = 1 } ) => { } = ( { children, order = 1, name = '' } ) => {
return ( return (
<Fill name={ WC_HEADER_SLOT_NAME }> <Fill name={ getSlotFillName( name ) }>
{ ( fillProps: Fill.Props ) => { { ( fillProps: Fill.Props ) => {
return createOrderedChildren( children, order, fillProps ); return createOrderedChildren( children, order, fillProps );
} } } }
@ -44,8 +60,8 @@ export const WooHeaderItem: React.FC< {
); );
}; };
WooHeaderItem.Slot = ( { fillProps } ) => ( WooHeaderItem.Slot = ( { fillProps, name = '' } ) => (
<Slot name={ WC_HEADER_SLOT_NAME } fillProps={ fillProps }> <Slot name={ getSlotFillName( name ) } fillProps={ fillProps }>
{ sortFillsByOrder } { sortFillsByOrder }
</Slot> </Slot>
); );

View File

@ -1,6 +1,10 @@
{ {
"extends": "../tsconfig-cjs", "extends": "../tsconfig-cjs",
"compilerOptions": { "compilerOptions": {
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -5,6 +5,10 @@
"outDir": "build-module", "outDir": "build-module",
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"declarationDir": "./build-types" "declarationDir": "./build-types",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -36,7 +36,7 @@
"prepare": "composer install", "prepare": "composer install",
"changelog": "composer exec -- changelogger", "changelog": "composer exec -- changelogger",
"clean": "rm -rf ./dist ./tsconfig.tsbuildinfo", "clean": "rm -rf ./dist ./tsconfig.tsbuildinfo",
"compile": "tsc -b", "compile": "tsc --project tsconfig.json",
"prepack": "pnpm run build", "prepack": "pnpm run build",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
@ -50,7 +50,7 @@
"devDependencies": { "devDependencies": {
"@types/create-hmac": "1.1.0", "@types/create-hmac": "1.1.0",
"@types/jest": "^27.4.1", "@types/jest": "^27.4.1",
"@types/node": "13.13.5", "@types/node": "^16.18.18",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^5.54.0",
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
@ -58,7 +58,7 @@
"eslint": "^8.32.0", "eslint": "^8.32.0",
"jest": "^27", "jest": "^27",
"ts-jest": "^27", "ts-jest": "^27",
"typescript": "^4.8.3" "typescript": "^4.9.5"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@ -4,7 +4,11 @@
"types": [ "node", "jest", "axios", "create-hmac" ], "types": [ "node", "jest", "axios", "create-hmac" ],
"rootDir": "src", "rootDir": "src",
"outDir": "dist", "outDir": "dist",
"target": "es5" "target": "es5",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
}, },
"include": [ "src/" ] "include": [ "src/" ]
} }

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Adding simple DisplayState wrapper and modifying Collapsible component to allow rendering hidden content.

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Prevent duplicate registration of core blocks in client

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -1,4 +1,4 @@
{ {
"rootDir": "./src", "rootDir": "./src",
"preset": "../../internal-js-tests/jest.config.js" "preset": "../node_modules/@woocommerce/internal-js-tests/jest-preset.js"
} }

View File

@ -128,6 +128,7 @@
"@types/wordpress__viewport": "^2.5.4", "@types/wordpress__viewport": "^2.5.4",
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
"@woocommerce/internal-style-build": "workspace:*", "@woocommerce/internal-style-build": "workspace:*",
"@woocommerce/internal-js-tests": "workspace:*",
"@wordpress/browserslist-config": "wp-6.0", "@wordpress/browserslist-config": "wp-6.0",
"@wordpress/scripts": "^12.6.1", "@wordpress/scripts": "^12.6.1",
"concurrently": "^7.0.0", "concurrently": "^7.0.0",
@ -141,7 +142,7 @@
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sass-loader": "^10.2.1", "sass-loader": "^10.2.1",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3", "typescript": "^4.9.5",
"uuid": "^8.3.0", "uuid": "^8.3.0",
"webpack": "^5.70.0", "webpack": "^5.70.0",
"webpack-cli": "^3.3.12" "webpack-cli": "^3.3.12"
@ -154,12 +155,12 @@
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name", "test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src --ext=js,ts,tsx", "lint": "eslint src --ext=js,ts,tsx",
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "build:js": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json",
"build:css": "webpack", "build:css": "webpack",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*", "clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"lint:fix": "eslint src --ext=js,ts,tsx --fix", "lint:fix": "eslint src --ext=js,ts,tsx --fix",
"prepack": "pnpm run clean && pnpm run build", "prepack": "pnpm run clean && pnpm run build",
"start": "concurrently \"tsc --build ./tsconfig.json --watch\" \"webpack --watch\"", "start": "concurrently \"tsc --project tsconfig.json --watch\" \"tsc --project tsconfig-cjs.json --watch\" \"webpack --watch\"",
"test:update-snapshots": "pnpm run test -- --updateSnapshot", "test:update-snapshots": "pnpm run test -- --updateSnapshot",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" "test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"
}, },

View File

@ -7,10 +7,12 @@ import { Icon, chevronDown, chevronUp } from '@wordpress/icons';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { DisplayState } from '../display-state';
export type CollapsedProps = { export type CollapsedProps = {
initialCollapsed?: boolean; initialCollapsed?: boolean;
toggleText: string; toggleText: string;
persistRender?: boolean;
children: React.ReactNode; children: React.ReactNode;
} & React.HTMLAttributes< HTMLDivElement >; } & React.HTMLAttributes< HTMLDivElement >;
@ -18,9 +20,19 @@ export const CollapsibleContent: React.FC< CollapsedProps > = ( {
initialCollapsed = true, initialCollapsed = true,
toggleText, toggleText,
children, children,
persistRender = false,
...props ...props
}: CollapsedProps ) => { }: CollapsedProps ) => {
const [ collapsed, setCollapsed ] = useState( initialCollapsed ); const [ collapsed, setCollapsed ] = useState( initialCollapsed );
const getState = () => {
if ( ! collapsed ) {
return 'visible';
}
return persistRender ? 'visually-hidden' : 'hidden';
};
return ( return (
<div <div
aria-expanded={ collapsed ? 'false' : 'true' } aria-expanded={ collapsed ? 'false' : 'true' }
@ -38,14 +50,14 @@ export const CollapsibleContent: React.FC< CollapsedProps > = ( {
/> />
</div> </div>
</button> </button>
{ ! collapsed && ( <DisplayState state={ getState() }>
<div <div
{ ...props } { ...props }
className="woocommerce-collapsible-content__content" className="woocommerce-collapsible-content__content"
> >
{ children } { children }
</div> </div>
) } </DisplayState>
</div> </div>
); );
}; };

View File

@ -0,0 +1,28 @@
/**
* External dependencies
*/
import { createElement, Fragment } from '@wordpress/element';
/**
* Internal dependencies
*/
export type DisplayStateProps = {
state?: 'visible' | 'visually-hidden' | 'hidden';
children: React.ReactNode;
} & React.HTMLAttributes< HTMLDivElement >;
export const DisplayState: React.FC< DisplayStateProps > = ( {
state = 'visible',
children,
} ) => {
if ( state === 'visible' ) {
return <>{ children }</>;
}
if ( state === 'visually-hidden' ) {
return <div style={ { display: 'none' } }>{ children }</div>;
}
return null;
};

View File

@ -0,0 +1 @@
export * from './display-state';

View File

@ -66,7 +66,8 @@ export type TreeProps = BaseTreeProps &
> & { > & {
level?: number; level?: number;
items: LinkedTree[]; items: LinkedTree[];
/** It gives a way to render a different Element as the /**
* It gives a way to render a different Element as the
* tree item label. * tree item label.
* *
* @example * @example

View File

@ -18,7 +18,7 @@ export type FormErrors< Values > = {
}; };
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export type FormContext< Values extends Record< string, any > > = { export type FormContextType< Values extends Record< string, any > > = {
values: Values; values: Values;
errors: FormErrors< Values >; errors: FormErrors< Values >;
isDirty: boolean; isDirty: boolean;
@ -51,14 +51,16 @@ export type FormContext< Values extends Record< string, any > > = {
}; };
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export const FormContext = createContext< FormContext< any > >( export const FormContext: React.Context< FormContextType< any > > =
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
{} as FormContext< any > createContext< FormContextType< any > >(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
{} as FormContextType< any >
); );
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export function useFormContext< Values extends Record< string, any > >() { export function useFormContext< Values extends Record< string, any > >() {
const formContext = useContext< FormContext< Values > >( FormContext ); const formContext = useContext< FormContextType< Values > >( FormContext );
return formContext; return formContext;
} }

View File

@ -10,7 +10,7 @@ import { TextControl } from '@wordpress/components';
* Internal dependencies * Internal dependencies
*/ */
import { Form, useFormContext } from '../'; import { Form, useFormContext } from '../';
import type { FormContext } from '../'; import type { FormContextType } from '../';
import { DateTimePickerControl } from '../../date-time-picker-control'; import { DateTimePickerControl } from '../../date-time-picker-control';
const TestInputWithContext = () => { const TestInputWithContext = () => {
@ -44,7 +44,7 @@ describe( 'Form', () => {
> >
{ ( { { ( {
handleSubmit, handleSubmit,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return <button onClick={ handleSubmit }>Submit</button>; return <button onClick={ handleSubmit }>Submit</button>;
} } } }
</Form> </Form>
@ -71,7 +71,7 @@ describe( 'Form', () => {
onChange={ mockOnChange } onChange={ mockOnChange }
validate={ () => ( {} ) } validate={ () => ( {} ) }
> >
{ ( { setValue }: FormContext< Record< string, string > > ) => { { ( { setValue }: FormContextType< Record< string, string > > ) => {
return ( return (
<button <button
onClick={ () => { onClick={ () => {
@ -103,7 +103,7 @@ describe( 'Form', () => {
<Form onSubmit={ mockOnSubmit } validate={ () => ( {} ) }> <Form onSubmit={ mockOnSubmit } validate={ () => ( {} ) }>
{ ( { { ( {
handleSubmit, handleSubmit,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return <button onClick={ handleSubmit }>Submit</button>; return <button onClick={ handleSubmit }>Submit</button>;
} } } }
</Form> </Form>
@ -124,7 +124,7 @@ describe( 'Form', () => {
const { queryByText } = render( const { queryByText } = render(
<Form onChange={ mockOnChange } validate={ () => ( {} ) }> <Form onChange={ mockOnChange } validate={ () => ( {} ) }>
{ ( { setValue }: FormContext< Record< string, string > > ) => { { ( { setValue }: FormContextType< Record< string, string > > ) => {
return ( return (
<button <button
onClick={ () => { onClick={ () => {
@ -156,7 +156,7 @@ describe( 'Form', () => {
{ ( { { ( {
setValue, setValue,
getInputProps, getInputProps,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return ( return (
<TextControl <TextControl
label={ 'First Name' } label={ 'First Name' }
@ -206,7 +206,7 @@ describe( 'Form', () => {
{ ( { { ( {
setValue, setValue,
getInputProps, getInputProps,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return ( return (
<TextControl <TextControl
label={ 'First Name' } label={ 'First Name' }
@ -243,7 +243,7 @@ describe( 'Form', () => {
{ ( { { ( {
setValue, setValue,
getInputProps, getInputProps,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return ( return (
<TextControl <TextControl
label={ 'First Name' } label={ 'First Name' }
@ -293,7 +293,7 @@ describe( 'Form', () => {
{ ( { { ( {
setValue, setValue,
getInputProps, getInputProps,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return ( return (
<TextControl <TextControl
label={ 'First Name' } label={ 'First Name' }
@ -329,7 +329,7 @@ describe( 'Form', () => {
<Form onChanges={ mockOnChanges } validate={ () => ( {} ) }> <Form onChanges={ mockOnChanges } validate={ () => ( {} ) }>
{ ( { { ( {
setValues, setValues,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return ( return (
<button <button
onClick={ () => { onClick={ () => {
@ -379,7 +379,7 @@ describe( 'Form', () => {
<Form onChanges={ mockOnChanges } validate={ validate }> <Form onChanges={ mockOnChanges } validate={ validate }>
{ ( { { ( {
setValues, setValues,
}: FormContext< Record< string, string > > ) => { }: FormContextType< Record< string, string > > ) => {
return ( return (
<button <button
onClick={ () => { onClick={ () => {
@ -428,7 +428,7 @@ describe( 'Form', () => {
const { container, queryByText } = render( const { container, queryByText } = render(
<Form< TestData > onChange={ mockOnChange } validate={ validate }> <Form< TestData > onChange={ mockOnChange } validate={ validate }>
{ ( { getInputProps, values }: FormContext< TestData > ) => { { ( { getInputProps, values }: FormContextType< TestData > ) => {
return ( return (
<DateTimePickerControl <DateTimePickerControl
label={ 'Date' } label={ 'Date' }

View File

@ -16,7 +16,7 @@ export { default as EmptyContent } from './empty-content';
export { default as Flag } from './flag'; export { default as Flag } from './flag';
export { Form, useFormContext } from './form'; export { Form, useFormContext } from './form';
export { FormSection } from './form-section'; export { FormSection } from './form-section';
export type { FormContext, FormRef, FormErrors } from './form'; export type { FormContext, FormContextType, FormRef, FormErrors } from './form';
export { default as FilterPicker } from './filter-picker'; export { default as FilterPicker } from './filter-picker';
export { H, Section } from './section'; export { H, Section } from './section';
export { ImageGallery, ImageGalleryItem } from './image-gallery'; export { ImageGallery, ImageGalleryItem } from './image-gallery';
@ -103,3 +103,4 @@ export {
ProductSectionLayout as __experimentalProductSectionLayout, ProductSectionLayout as __experimentalProductSectionLayout,
ProductFieldSection as __experimentalProductFieldSection, ProductFieldSection as __experimentalProductFieldSection,
} from './product-section-layout'; } from './product-section-layout';
export { DisplayState } from './display-state';

View File

@ -1,7 +1,7 @@
/** /**
* External dependencies * External dependencies
*/ */
import { BlockInstance } from '@wordpress/blocks'; import { BlockInstance, getBlockType } from '@wordpress/blocks';
import { import {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We need this to import the block modules for registration. // @ts-ignore We need this to import the block modules for registration.
@ -29,9 +29,10 @@ const ALLOWED_CORE_BLOCKS = [
const registerCoreBlocks = () => { const registerCoreBlocks = () => {
const coreBlocks = __experimentalGetCoreBlocks(); const coreBlocks = __experimentalGetCoreBlocks();
const blocks = coreBlocks.filter( ( block: BlockInstance ) => const blocks = coreBlocks.filter( ( block: BlockInstance ) => {
ALLOWED_CORE_BLOCKS.includes( block.name ) const isRegistered = !! getBlockType( block.name );
); return ! isRegistered && ALLOWED_CORE_BLOCKS.includes( block.name );
} );
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore An argument is allowed to specify which blocks to register. // @ts-ignore An argument is allowed to specify which blocks to register.

View File

@ -8,6 +8,6 @@ import { createContext } from '@wordpress/element';
* *
* See https://medium.com/@Heydon/managing-heading-levels-in-design-systems-18be9a746fa3 * See https://medium.com/@Heydon/managing-heading-levels-in-design-systems-18be9a746fa3
*/ */
const Level = createContext( 2 ); const Level: React.Context< number > = createContext( 2 );
export { Level }; export { Level };

View File

@ -43,7 +43,7 @@ export type SortableProps = {
const THROTTLE_TIME = 16; const THROTTLE_TIME = 16;
export const SortableContext = createContext( {} ); export const SortableContext: React.Context< object > = createContext( {} );
export const Sortable = ( { export const Sortable = ( {
children, children,

View File

@ -64,7 +64,7 @@ function createOrderedChildren< T = Fill.Props, S = Record< string, unknown > >(
order: number, order: number,
props: T, props: T,
injectProps?: S injectProps?: S
) { ): React.ReactElement {
const { children: childrenToRender, props: propsToRender } = const { children: childrenToRender, props: propsToRender } =
getChildrenAndProps( children, order, props, injectProps ); getChildrenAndProps( children, order, props, injectProps );
return cloneElement( childrenToRender, propsToRender ); return cloneElement( childrenToRender, propsToRender );

View File

@ -1,6 +1,10 @@
{ {
"extends": "../tsconfig-cjs", "extends": "../tsconfig-cjs",
"compilerOptions": { "compilerOptions": {
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -6,6 +6,10 @@
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"declarationDir": "./build-types", "declarationDir": "./build-types",
"composite": true "composite": true,
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -1,4 +1,4 @@
{ {
"rootDir": "./src", "rootDir": "./src",
"preset": "../../internal-js-tests/jest.config.js" "preset": "../node_modules/@woocommerce/internal-js-tests/jest-preset.js"
} }

View File

@ -26,6 +26,7 @@
"types": "build-types", "types": "build-types",
"react-native": "src/index", "react-native": "src/index",
"dependencies": { "dependencies": {
"@types/node": "^16.18.18",
"browser-filesaver": "^1.1.1", "browser-filesaver": "^1.1.1",
"moment": "^2.29.1" "moment": "^2.29.1"
}, },
@ -33,7 +34,7 @@
"access": "public" "access": "public"
}, },
"scripts": { "scripts": {
"turbo:build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "turbo:build": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json",
"turbo:test": "jest --config ./jest.config.json", "turbo:test": "jest --config ./jest.config.json",
"prepare": "composer install", "prepare": "composer install",
"changelog": "composer exec -- changelogger", "changelog": "composer exec -- changelogger",
@ -41,7 +42,7 @@
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name", "test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
"start": "tsc --build --watch", "start": "concurrently \"tsc --project tsconfig.json --watch\" \"tsc --project tsconfig-cjs.json --watch\"",
"prepack": "pnpm run clean && pnpm run build", "prepack": "pnpm run clean && pnpm run build",
"lint:fix": "eslint src --fix", "lint:fix": "eslint src --fix",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" "test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"
@ -50,12 +51,14 @@
"@babel/core": "^7.17.5", "@babel/core": "^7.17.5",
"@types/jest": "^27.4.1", "@types/jest": "^27.4.1",
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
"@woocommerce/internal-js-tests": "workspace:*",
"eslint": "^8.32.0", "eslint": "^8.32.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"jest-cli": "^27.5.1", "jest-cli": "^27.5.1",
"concurrently": "^7.0.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3" "typescript": "^4.9.5"
}, },
"lint-staged": { "lint-staged": {
"*.(t|j)s?(x)": [ "*.(t|j)s?(x)": [

View File

@ -1,6 +1,10 @@
{ {
"extends": "../tsconfig-cjs", "extends": "../tsconfig-cjs",
"compilerOptions": { "compilerOptions": {
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -6,6 +6,10 @@
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"declarationDir": "./build-types", "declarationDir": "./build-types",
"composite": true "composite": true,
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -1,4 +1,4 @@
{ {
"rootDir": "./src", "rootDir": "./src",
"preset": "../../internal-js-tests/jest.config.js" "preset": "../node_modules/@woocommerce/internal-js-tests/jest-preset.js"
} }

View File

@ -37,7 +37,7 @@
"access": "public" "access": "public"
}, },
"scripts": { "scripts": {
"turbo:build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "turbo:build": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json",
"turbo:test": "jest --config ./jest.config.json", "turbo:test": "jest --config ./jest.config.json",
"prepare": "composer install", "prepare": "composer install",
"changelog": "composer exec -- changelogger", "changelog": "composer exec -- changelogger",
@ -45,7 +45,7 @@
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name", "test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
"start": "tsc --build --watch", "start": "concurrently \"tsc --project tsconfig.json --watch\" \"tsc --project tsconfig-cjs.json --watch\"",
"prepack": "pnpm run clean && pnpm run build", "prepack": "pnpm run clean && pnpm run build",
"lint:fix": "eslint src --fix", "lint:fix": "eslint src --fix",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" "test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"
@ -54,12 +54,14 @@
"@babel/core": "^7.17.5", "@babel/core": "^7.17.5",
"@types/jest": "^27.4.1", "@types/jest": "^27.4.1",
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
"@woocommerce/internal-js-tests": "workspace:*",
"eslint": "^8.32.0", "eslint": "^8.32.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"jest-cli": "^27.5.1", "jest-cli": "^27.5.1",
"concurrently": "^7.0.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3" "typescript": "^4.9.5"
}, },
"lint-staged": { "lint-staged": {
"*.(t|j)s?(x)": [ "*.(t|j)s?(x)": [

View File

@ -2,6 +2,10 @@
"extends": "../tsconfig-cjs", "extends": "../tsconfig-cjs",
"compilerOptions": { "compilerOptions": {
"declaration": true, "declaration": true,
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -5,6 +5,10 @@
"outDir": "build-module", "outDir": "build-module",
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"declarationDir": "./build-types" "declarationDir": "./build-types",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -0,0 +1,4 @@
Significance: minor
Type: dev
Move additional components to @woocommerce/customer-effort-score.

View File

@ -1,4 +1,4 @@
{ {
"rootDir": "./src", "rootDir": "./src",
"preset": "../../internal-js-tests/jest.config.js" "preset": "../node_modules/@woocommerce/internal-js-tests/jest-preset.js"
} }

View File

@ -51,6 +51,8 @@
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
"@woocommerce/internal-style-build": "workspace:*", "@woocommerce/internal-style-build": "workspace:*",
"@woocommerce/navigation": "workspace:*", "@woocommerce/navigation": "workspace:*",
"@woocommerce/tracks": "workspace:*",
"@woocommerce/internal-js-tests": "workspace:*",
"@wordpress/browserslist-config": "wp-6.0", "@wordpress/browserslist-config": "wp-6.0",
"concurrently": "^7.0.0", "concurrently": "^7.0.0",
"css-loader": "^3.6.0", "css-loader": "^3.6.0",
@ -62,7 +64,7 @@
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sass-loader": "^10.2.1", "sass-loader": "^10.2.1",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3", "typescript": "^4.9.5",
"webpack": "^5.70.0", "webpack": "^5.70.0",
"webpack-cli": "^3.3.12" "webpack-cli": "^3.3.12"
}, },
@ -79,9 +81,9 @@
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name", "test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "build:js": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json",
"build:css": "webpack", "build:css": "webpack",
"start": "concurrently \"tsc --build --watch\" \"webpack --watch\"", "start": "concurrently \"tsc --project tsconfig.json --watch\" \"tsc --project tsconfig-cjs.json --watch\" \"webpack --watch\"",
"prepack": "pnpm run clean && pnpm run build", "prepack": "pnpm run clean && pnpm run build",
"lint:fix": "eslint src --fix", "lint:fix": "eslint src --fix",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" "test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -3,18 +3,17 @@
*/ */
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { useDispatch, useSelect } from '@wordpress/data'; import { useDispatch, useSelect } from '@wordpress/data';
import {
CustomerFeedbackModal,
STORE_KEY,
} from '@woocommerce/customer-effort-score';
import { recordEvent } from '@woocommerce/tracks';
import { OPTIONS_STORE_NAME } from '@woocommerce/data'; import { OPTIONS_STORE_NAME } from '@woocommerce/data';
import { createElement } from '@wordpress/element';
import { recordEvent } from '@woocommerce/tracks';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { getStoreAgeInWeeks } from './utils'; import { CustomerFeedbackModal } from '../';
import { ADMIN_INSTALL_TIMESTAMP_OPTION_NAME } from './constants'; import { getStoreAgeInWeeks } from '../../utils';
import { STORE_KEY } from '../../store';
import { ADMIN_INSTALL_TIMESTAMP_OPTION_NAME } from '../../constants';
export const PRODUCT_MVP_CES_ACTION_OPTION_NAME = export const PRODUCT_MVP_CES_ACTION_OPTION_NAME =
'woocommerce_ces_product_mvp_ces_action'; 'woocommerce_ces_product_mvp_ces_action';

View File

@ -4,17 +4,15 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { compose } from '@wordpress/compose'; import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data'; import { withDispatch, withSelect } from '@wordpress/data';
import { import { createElement, Fragment } from '@wordpress/element';
QUEUE_OPTION_NAME,
STORE_KEY,
} from '@woocommerce/customer-effort-score';
import { OPTIONS_STORE_NAME } from '@woocommerce/data'; import { OPTIONS_STORE_NAME } from '@woocommerce/data';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import CustomerEffortScoreTracks from './customer-effort-score-tracks'; import { CustomerEffortScoreTracks } from '../';
import { QUEUE_OPTION_NAME, STORE_KEY } from '../../store';
/** /**
* Maps the queue of CES tracks surveys to CustomerEffortScoreTracks * Maps the queue of CES tracks surveys to CustomerEffortScoreTracks
@ -27,7 +25,7 @@ import CustomerEffortScoreTracks from './customer-effort-score-tracks';
* @param {boolean} props.resolving Whether the queue is resolving. * @param {boolean} props.resolving Whether the queue is resolving.
* @param {Function} props.clearQueue Sets up clearing of the queue on the next page load. * @param {Function} props.clearQueue Sets up clearing of the queue on the next page load.
*/ */
function CustomerEffortScoreTracksContainer( { function _CustomerEffortScoreTracksContainer( {
queue, queue,
resolving, resolving,
clearQueue, clearQueue,
@ -67,7 +65,7 @@ function CustomerEffortScoreTracksContainer( {
); );
} }
CustomerEffortScoreTracksContainer.propTypes = { _CustomerEffortScoreTracksContainer.propTypes = {
/** /**
* The queue of CES tracks surveys to display. * The queue of CES tracks surveys to display.
*/ */
@ -82,7 +80,7 @@ CustomerEffortScoreTracksContainer.propTypes = {
clearQueue: PropTypes.func, clearQueue: PropTypes.func,
}; };
export default compose( export const CustomerEffortScoreTracksContainer = compose(
withSelect( ( select ) => { withSelect( ( select ) => {
const { getCesSurveyQueue, isResolving } = select( STORE_KEY ); const { getCesSurveyQueue, isResolving } = select( STORE_KEY );
const queue = getCesSurveyQueue(); const queue = getCesSurveyQueue();
@ -109,4 +107,4 @@ export default compose(
}, },
}; };
} ) } )
)( CustomerEffortScoreTracksContainer ); )( _CustomerEffortScoreTracksContainer );

View File

@ -1,26 +1,24 @@
/** /**
* External dependencies * External dependencies
*/ */
import { useState } from '@wordpress/element';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { recordEvent } from '@woocommerce/tracks';
import {
ALLOW_TRACKING_OPTION_NAME,
CustomerEffortScore,
} from '@woocommerce/customer-effort-score';
import { compose } from '@wordpress/compose'; import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data'; import { withSelect, withDispatch } from '@wordpress/data';
import { createElement, useState } from '@wordpress/element';
import { OPTIONS_STORE_NAME } from '@woocommerce/data'; import { OPTIONS_STORE_NAME } from '@woocommerce/data';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { recordEvent } from '@woocommerce/tracks';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { CustomerEffortScore } from '../';
import { import {
SHOWN_FOR_ACTIONS_OPTION_NAME,
ADMIN_INSTALL_TIMESTAMP_OPTION_NAME, ADMIN_INSTALL_TIMESTAMP_OPTION_NAME,
} from './constants'; ALLOW_TRACKING_OPTION_NAME,
import { getStoreAgeInWeeks } from './utils'; SHOWN_FOR_ACTIONS_OPTION_NAME,
} from '../../constants';
import { getStoreAgeInWeeks } from '../../utils';
/** /**
* A CustomerEffortScore wrapper that uses tracks to track the selected * A CustomerEffortScore wrapper that uses tracks to track the selected
@ -43,7 +41,7 @@ import { getStoreAgeInWeeks } from './utils';
* @param {Function} props.updateOptions Function to update options. * @param {Function} props.updateOptions Function to update options.
* @param {Function} props.createNotice Function to create a snackbar. * @param {Function} props.createNotice Function to create a snackbar.
*/ */
function CustomerEffortScoreTracks( { function _CustomerEffortScoreTracks( {
action, action,
trackProps, trackProps,
title, title,
@ -176,7 +174,7 @@ function CustomerEffortScoreTracks( {
); );
} }
CustomerEffortScoreTracks.propTypes = { _CustomerEffortScoreTracks.propTypes = {
/** /**
* The action name sent to Tracks. * The action name sent to Tracks.
*/ */
@ -219,7 +217,7 @@ CustomerEffortScoreTracks.propTypes = {
createNotice: PropTypes.func, createNotice: PropTypes.func,
}; };
export default compose( export const CustomerEffortScoreTracks = compose(
withSelect( ( select ) => { withSelect( ( select ) => {
const { getOption, hasFinishedResolution } = const { getOption, hasFinishedResolution } =
select( OPTIONS_STORE_NAME ); select( OPTIONS_STORE_NAME );
@ -262,4 +260,4 @@ export default compose(
createNotice, createNotice,
}; };
} ) } )
)( CustomerEffortScoreTracks ); )( _CustomerEffortScoreTracks );

View File

@ -0,0 +1,8 @@
export * from './customer-effort-score';
export * from './customer-effort-score-modal-container';
export * from './customer-effort-score-tracks';
export * from './customer-effort-score-tracks-container';
export * from './customer-feedback-simple';
export * from './customer-feedback-modal';
export * from './product-mvp-feedback-modal';
export * from './feedback-modal';

View File

@ -1 +1,7 @@
export const ADMIN_INSTALL_TIMESTAMP_OPTION_NAME =
'woocommerce_admin_install_timestamp';
export const ALLOW_TRACKING_OPTION_NAME = 'woocommerce_allow_tracking'; export const ALLOW_TRACKING_OPTION_NAME = 'woocommerce_allow_tracking';
export const SHOWN_FOR_ACTIONS_OPTION_NAME =
'woocommerce_ces_shown_for_actions';

View File

@ -0,0 +1 @@
export * from './use-customer-effort-score-exit-page-tracker';

View File

@ -1,9 +1,5 @@
export * from './components/customer-effort-score'; export * from './components';
export * from './components/customer-feedback-simple';
export * from './components/customer-feedback-modal';
export * from './components/product-mvp-feedback-modal';
export * from './components/feedback-modal';
export * from './hooks/use-customer-effort-score-exit-page-tracker';
export * from './store';
export * from './utils/customer-effort-score-exit-page';
export * from './constants'; export * from './constants';
export * from './hooks';
export * from './store';
export * from './utils';

View File

@ -0,0 +1,2 @@
export * from './customer-effort-score-exit-page';
export * from './get-store-age-in-weeks';

View File

@ -1,6 +1,10 @@
{ {
"extends": "../tsconfig-cjs", "extends": "../tsconfig-cjs",
"compilerOptions": { "compilerOptions": {
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -5,6 +5,10 @@
"outDir": "build-module", "outDir": "build-module",
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"declarationDir": "./build-types" "declarationDir": "./build-types",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Fix linter errors

View File

@ -0,0 +1,4 @@
Significance: minor
Type: enhancement
Add tracks for plugin actions and handle plugin error properly

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -1,4 +1,4 @@
{ {
"rootDir": "./src", "rootDir": "./src",
"preset": "../../internal-js-tests/jest.config.js" "preset": "../node_modules/@woocommerce/internal-js-tests/jest-preset.js"
} }

View File

@ -28,6 +28,7 @@
"dependencies": { "dependencies": {
"@woocommerce/date": "workspace:*", "@woocommerce/date": "workspace:*",
"@woocommerce/navigation": "workspace:*", "@woocommerce/navigation": "workspace:*",
"@woocommerce/tracks": "workspace:*",
"@wordpress/api-fetch": "wp-6.0", "@wordpress/api-fetch": "wp-6.0",
"@wordpress/compose": "wp-6.0", "@wordpress/compose": "wp-6.0",
"@wordpress/core-data": "wp-6.0", "@wordpress/core-data": "wp-6.0",
@ -58,18 +59,21 @@
"@types/md5": "^2.3.2", "@types/md5": "^2.3.2",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@types/react": "^17.0.2", "@types/react": "^17.0.2",
"@types/node": "^16.18.18",
"@types/wordpress__compose": "^4.0.1", "@types/wordpress__compose": "^4.0.1",
"@types/wordpress__core-data": "^2.4.5", "@types/wordpress__core-data": "^2.4.5",
"@types/wordpress__data": "^6.0.0", "@types/wordpress__data": "^6.0.0",
"@types/wordpress__data-controls": "^2.2.0", "@types/wordpress__data-controls": "^2.2.0",
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
"@woocommerce/internal-js-tests": "workspace:*",
"eslint": "^8.32.0", "eslint": "^8.32.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"jest-cli": "^27.5.1", "jest-cli": "^27.5.1",
"concurrently": "^7.0.0",
"redux": "^4.1.0", "redux": "^4.1.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3" "typescript": "^4.9.5"
}, },
"peerDependencies": { "peerDependencies": {
"@wordpress/core-data": "wp-6.0", "@wordpress/core-data": "wp-6.0",
@ -78,7 +82,7 @@
"react-dom": "^17.0.2" "react-dom": "^17.0.2"
}, },
"scripts": { "scripts": {
"turbo:build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "turbo:build": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json",
"turbo:test": "jest --config ./jest.config.json", "turbo:test": "jest --config ./jest.config.json",
"prepare": "composer install", "prepare": "composer install",
"changelog": "composer exec -- changelogger", "changelog": "composer exec -- changelogger",
@ -86,7 +90,7 @@
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name", "test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
"start": "tsc --build --watch ./tsconfig.json ./tsconfig-cjs.json", "start": "concurrently \"tsc --project tsconfig.json --watch\" \"tsc --project tsconfig-cjs.json --watch\"",
"prepack": "pnpm run clean && pnpm run build", "prepack": "pnpm run clean && pnpm run build",
"lint:fix": "eslint src --fix", "lint:fix": "eslint src --fix",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" "test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -9,6 +9,7 @@ import {
import { _n, sprintf } from '@wordpress/i18n'; import { _n, sprintf } from '@wordpress/i18n';
import { DispatchFromMap } from '@automattic/data-stores'; import { DispatchFromMap } from '@automattic/data-stores';
import { controls } from '@wordpress/data'; import { controls } from '@wordpress/data';
import { recordEvent } from '@woocommerce/tracks';
/** /**
* Internal dependencies * Internal dependencies
@ -49,21 +50,22 @@ const isPluginResponseError = (
typeof error === 'object' && error !== null && plugins[ 0 ] in error; typeof error === 'object' && error !== null && plugins[ 0 ] in error;
const formatErrorMessage = ( const formatErrorMessage = (
pluginErrors: PluginResponseErrors, actionType: 'install' | 'activate' = 'install',
actionType = 'install' plugins: Partial< PluginNames >[],
rawErrorMessage: string
) => { ) => {
return sprintf( return sprintf(
/* translators: %(actionType): install or activate (the plugin). %(pluginName): a plugin slug (e.g. woocommerce-services). %(error): a single error message or in plural a comma separated error message list.*/ /* translators: %(actionType): install or activate (the plugin). %(pluginName): a plugin slug (e.g. woocommerce-services). %(error): a single error message or in plural a comma separated error message list.*/
_n( _n(
'Could not %(actionType)s %(pluginName)s plugin, %(error)s', 'Could not %(actionType)s %(pluginName)s plugin, %(error)s',
'Could not %(actionType)s the following plugins: %(pluginName)s with these Errors: %(error)s', 'Could not %(actionType)s the following plugins: %(pluginName)s with these Errors: %(error)s',
Object.keys( pluginErrors ).length || 1, Object.keys( plugins ).length || 1,
'woocommerce' 'woocommerce'
), ),
{ {
actionType, actionType,
pluginName: Object.keys( pluginErrors ).join( ', ' ), pluginName: plugins.join( ', ' ),
error: Object.values( pluginErrors ).join( ', \n' ), error: rawErrorMessage,
} }
); );
}; };
@ -174,35 +176,42 @@ export function setRecommendedPlugins(
} }
function* handlePluginAPIError( function* handlePluginAPIError(
actionType: string, actionType: 'install' | 'activate',
plugins: Partial< PluginNames >[], plugins: Partial< PluginNames >[],
error: unknown error: unknown
) { ) {
yield setError( 'installPlugins', error ); let rawErrorMessage;
let pluginResponseError = error; if ( isPluginResponseError( plugins, error ) ) {
if ( // Backend error messages are in the form of { plugin-slug: [ error messages ] }.
( error instanceof Error || isRestApiError( error ) ) && rawErrorMessage = Object.values( error ).join( ', \n' );
plugins[ 0 ]
) {
pluginResponseError = {
[ plugins[ 0 ] ]: [ error.message ],
};
}
if ( isPluginResponseError( plugins, pluginResponseError ) ) {
throw new PluginError(
formatErrorMessage( pluginResponseError, actionType ),
pluginResponseError
);
} else { } else {
throw new PluginError( // Other error such as API connection errors.
`Unexpected Plugin Error: ${ JSON.stringify( rawErrorMessage =
pluginResponseError isRestApiError( error ) || error instanceof Error
) }`, ? error.message
pluginResponseError : JSON.stringify( error );
);
} }
// Track the error.
switch ( actionType ) {
case 'install':
recordEvent( 'install_plugins_error', {
plugins: plugins.join( ', ' ),
message: rawErrorMessage,
} );
break;
case 'activate':
recordEvent( 'activate_plugins_error', {
plugins: plugins.join( ', ' ),
message: rawErrorMessage,
} );
}
throw new PluginError(
formatErrorMessage( actionType, plugins, rawErrorMessage ),
error
);
} }
// Action Creator Generators // Action Creator Generators
@ -225,6 +234,7 @@ export function* installPlugins( plugins: Partial< PluginNames >[] ) {
return results; return results;
} catch ( error ) { } catch ( error ) {
yield setError( 'installPlugins', error );
yield handlePluginAPIError( 'install', plugins, error ); yield handlePluginAPIError( 'install', plugins, error );
} finally { } finally {
yield setIsRequesting( 'installPlugins', false ); yield setIsRequesting( 'installPlugins', false );
@ -251,6 +261,7 @@ export function* activatePlugins( plugins: Partial< PluginNames >[] ) {
return results; return results;
} catch ( error ) { } catch ( error ) {
yield setError( 'activatePlugins', error );
yield handlePluginAPIError( 'activate', plugins, error ); yield handlePluginAPIError( 'activate', plugins, error );
} finally { } finally {
yield setIsRequesting( 'activatePlugins', false ); yield setIsRequesting( 'activatePlugins', false );
@ -305,7 +316,7 @@ export function* connectToJetpack(
} }
export function* installJetpackAndConnect( export function* installJetpackAndConnect(
errorAction: ( errorMesage: string ) => void, errorAction: ( errorMessage: string ) => void,
getAdminLink: ( endpoint: string ) => string getAdminLink: ( endpoint: string ) => string
) { ) {
try { try {
@ -329,7 +340,7 @@ export function* installJetpackAndConnect(
export function* connectToJetpackWithFailureRedirect( export function* connectToJetpackWithFailureRedirect(
failureRedirect: string, failureRedirect: string,
errorAction: ( errorMesage: string ) => void, errorAction: ( errorMessage: string ) => void,
getAdminLink: ( endpoint: string ) => string getAdminLink: ( endpoint: string ) => string
) { ) {
try { try {

View File

@ -1,6 +1,10 @@
{ {
"extends": "../tsconfig-cjs", "extends": "../tsconfig-cjs",
"compilerOptions": { "compilerOptions": {
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -5,6 +5,10 @@
"outDir": "build-module", "outDir": "build-module",
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"declarationDir": "./build-types" "declarationDir": "./build-types",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: TypeScript build change

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -1,4 +1,4 @@
{ {
"rootDir": "./src", "rootDir": "./src",
"preset": "../../internal-js-tests/jest.config.js" "preset": "../node_modules/@woocommerce/internal-js-tests/jest-preset.js"
} }

View File

@ -35,17 +35,20 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.17.5", "@babel/core": "^7.17.5",
"@types/node": "^16.18.18",
"@types/jest": "^27.4.1", "@types/jest": "^27.4.1",
"@types/lodash": "^4.14.182", "@types/lodash": "^4.14.182",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/eslint-plugin": "workspace:*",
"@woocommerce/internal-js-tests": "workspace:*",
"d3-time-format": "^2.3.0", "d3-time-format": "^2.3.0",
"eslint": "^8.32.0", "eslint": "^8.32.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"jest-cli": "^27.5.1", "jest-cli": "^27.5.1",
"concurrently": "^7.0.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3" "typescript": "^4.9.5"
}, },
"peerDependencies": { "peerDependencies": {
"lodash": "^4.17.0" "lodash": "^4.17.0"
@ -54,7 +57,7 @@
"access": "public" "access": "public"
}, },
"scripts": { "scripts": {
"turbo:build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", "turbo:build": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json",
"turbo:test": "jest --config ./jest.config.json", "turbo:test": "jest --config ./jest.config.json",
"prepare": "composer install", "prepare": "composer install",
"changelog": "composer exec -- changelogger", "changelog": "composer exec -- changelogger",
@ -62,7 +65,7 @@
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name", "build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name", "test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src", "lint": "eslint src",
"start": "tsc --build --watch", "start": "concurrently \"tsc --project tsconfig.json --watch\" \"tsc --project tsconfig-cjs.json --watch\"",
"prepack": "pnpm run clean && pnpm run build", "prepack": "pnpm run clean && pnpm run build",
"lint:fix": "eslint src --fix", "lint:fix": "eslint src --fix",
"test-staged": "jest --bail --config ./jest.config.json --findRelatedTests" "test-staged": "jest --bail --config ./jest.config.json --findRelatedTests"

View File

@ -2,7 +2,7 @@
* External dependencies * External dependencies
*/ */
import moment from 'moment'; import moment from 'moment';
import 'moment-timezone'; import momentTz from 'moment-timezone';
import { find, memoize } from 'lodash'; import { find, memoize } from 'lodash';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { parse } from 'qs'; import { parse } from 'qs';
@ -181,7 +181,7 @@ export function getStoreTimeZoneMoment() {
return moment().utcOffset( window.wcSettings.timeZone ); return moment().utcOffset( window.wcSettings.timeZone );
} }
return moment().tz( window.wcSettings.timeZone ); return ( moment() as momentTz.Moment ).tz( window.wcSettings.timeZone );
} }
/** /**

View File

@ -1,6 +1,10 @@
{ {
"extends": "../tsconfig-cjs", "extends": "../tsconfig-cjs",
"compilerOptions": { "compilerOptions": {
"outDir": "build" "outDir": "build",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -5,6 +5,10 @@
"outDir": "build-module", "outDir": "build-module",
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"declarationDir": "./build-types" "declarationDir": "./build-types",
"typeRoots": [
"./typings",
"./node_modules/@types"
]
} }
} }

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

View File

@ -35,7 +35,7 @@
"jest-cli": "^27.5.1", "jest-cli": "^27.5.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"typescript": "^4.8.3", "typescript": "^4.9.5",
"webpack": "^5.70.0", "webpack": "^5.70.0",
"webpack-cli": "^3.3.12" "webpack-cli": "^3.3.12"
}, },

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Configuration change only

Some files were not shown because too many files have changed in this diff Show More