Merge branch 'trunk' into e2e/update-command-for-e2e
This commit is contained in:
commit
433357c3e3
|
@ -42,6 +42,7 @@ runs:
|
||||||
with:
|
with:
|
||||||
php-version: ${{ inputs.php-version }}
|
php-version: ${{ inputs.php-version }}
|
||||||
coverage: none
|
coverage: none
|
||||||
|
tools: cs2pr, phpcs
|
||||||
|
|
||||||
- name: Cache Composer Dependencies
|
- name: Cache Composer Dependencies
|
||||||
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77
|
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: Run daily tests in an environment with COT enabled
|
name: Run daily tests in an environment with COT enabled
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "30 2 * * *"
|
- cron: '30 2 * * *'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
|
@ -12,6 +12,9 @@ jobs:
|
||||||
cot-e2e-tests-run:
|
cot-e2e-tests-run:
|
||||||
name: Runs E2E tests with COT enabled.
|
name: Runs E2E tests with COT enabled.
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
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
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ jobs:
|
||||||
steps.run_playwright_e2e_tests.conclusion != 'skipped'
|
steps.run_playwright_e2e_tests.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean e2e/allure-results --output e2e/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive Playwright E2E test report
|
- name: Archive Playwright E2E test report
|
||||||
if: |
|
if: |
|
||||||
|
@ -53,8 +56,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: e2e-test-report---pr-${{ github.event.number }}
|
name: e2e-test-report---pr-${{ github.event.number }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/e2e/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/e2e/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
@ -62,7 +65,8 @@ jobs:
|
||||||
name: Runs API tests with COT enabled.
|
name: Runs API tests with COT enabled.
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
env:
|
env:
|
||||||
API_TEST_REPORT_DIR: ${{ github.workspace }}/api-test-report
|
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-results
|
||||||
|
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-report
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -81,6 +85,7 @@ jobs:
|
||||||
USER_KEY: admin
|
USER_KEY: admin
|
||||||
USER_SECRET: password
|
USER_SECRET: password
|
||||||
run: pnpm exec playwright test --config=tests/api-core-tests/playwright.config.js
|
run: pnpm exec playwright test --config=tests/api-core-tests/playwright.config.js
|
||||||
|
|
||||||
- name: Generate Playwright API Test report.
|
- name: Generate Playwright API Test report.
|
||||||
id: generate_api_report
|
id: generate_api_report
|
||||||
if: |
|
if: |
|
||||||
|
@ -90,7 +95,8 @@ jobs:
|
||||||
steps.run_playwright_api_tests.conclusion != 'skipped'
|
steps.run_playwright_api_tests.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean api-test-report/allure-results --output api-test-report/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive Playwright API test report
|
- name: Archive Playwright API test report
|
||||||
if: |
|
if: |
|
||||||
always() &&
|
always() &&
|
||||||
|
@ -99,8 +105,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: api-test-report---pr-${{ github.event.number }}
|
name: api-test-report---pr-${{ github.event.number }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/api-test-report/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/api-test-report/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ jobs:
|
||||||
name: Runs E2E tests with COT enabled.
|
name: Runs E2E tests with COT enabled.
|
||||||
if: "${{ github.event_name == 'workflow_dispatch' || github.event.label.name == 'focus: custom order tables' }}"
|
if: "${{ github.event_name == 'workflow_dispatch' || github.event.label.name == 'focus: custom order tables' }}"
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
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
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -44,7 +47,7 @@ jobs:
|
||||||
steps.run_playwright_e2e_tests.conclusion != 'skipped'
|
steps.run_playwright_e2e_tests.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean e2e/allure-results --output e2e/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive Playwright E2E test report
|
- name: Archive Playwright E2E test report
|
||||||
if: |
|
if: |
|
||||||
|
@ -54,8 +57,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: e2e-test-report---pr-${{ github.event.number }}
|
name: e2e-test-report---pr-${{ github.event.number }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/e2e/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/e2e/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
@ -64,7 +67,8 @@ jobs:
|
||||||
if: "${{ github.event_name == 'workflow_dispatch' || github.event.label.name == 'focus: custom order tables' }}"
|
if: "${{ github.event_name == 'workflow_dispatch' || github.event.label.name == 'focus: custom order tables' }}"
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
env:
|
env:
|
||||||
API_TEST_REPORT_DIR: ${{ github.workspace }}/api-test-report
|
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-results
|
||||||
|
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-report
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -93,7 +97,7 @@ jobs:
|
||||||
steps.run_playwright_api_tests.conclusion != 'skipped'
|
steps.run_playwright_api_tests.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean api-test-report/allure-results --output api-test-report/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive Playwright API test report
|
- name: Archive Playwright API test report
|
||||||
if: |
|
if: |
|
||||||
|
@ -103,8 +107,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: api-test-report---pr-${{ github.event.number }}
|
name: api-test-report---pr-${{ github.event.number }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/api-test-report/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/api-test-report/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ jobs:
|
||||||
e2e-tests-run:
|
e2e-tests-run:
|
||||||
name: Runs E2E tests.
|
name: Runs E2E tests.
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
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
|
||||||
outputs:
|
outputs:
|
||||||
E2E_GRAND_TOTAL: ${{ steps.count_e2e_total.outputs.E2E_GRAND_TOTAL }}
|
E2E_GRAND_TOTAL: ${{ steps.count_e2e_total.outputs.E2E_GRAND_TOTAL }}
|
||||||
steps:
|
steps:
|
||||||
|
@ -55,7 +58,7 @@ jobs:
|
||||||
steps.run_playwright_e2e_tests.conclusion != 'skipped'
|
steps.run_playwright_e2e_tests.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean e2e/allure-results --output e2e/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive Playwright E2E test report
|
- name: Archive Playwright E2E test report
|
||||||
if: |
|
if: |
|
||||||
|
@ -65,8 +68,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: e2e-test-report---pr-${{ github.event.number }}
|
name: e2e-test-report---pr-${{ github.event.number }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/e2e/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/e2e/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
@ -74,7 +77,8 @@ jobs:
|
||||||
name: Runs API tests.
|
name: Runs API tests.
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
env:
|
env:
|
||||||
API_TEST_REPORT_DIR: ${{ github.workspace }}/api-test-report
|
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-results
|
||||||
|
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-report
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -103,7 +107,7 @@ jobs:
|
||||||
steps.run_playwright_api_tests.conclusion != 'skipped'
|
steps.run_playwright_api_tests.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean api-test-report/allure-results --output api-test-report/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
- name: Archive Playwright API test report
|
- name: Archive Playwright API test report
|
||||||
if: |
|
if: |
|
||||||
always() &&
|
always() &&
|
||||||
|
@ -112,8 +116,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: api-test-report---pr-${{ github.event.number }}
|
name: api-test-report---pr-${{ github.event.number }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/api-test-report/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/api-test-report/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,25 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get Changed Files
|
||||||
|
id: changed-files
|
||||||
|
uses: tj-actions/changed-files@v32
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
**/*.php
|
||||||
|
|
||||||
- name: Setup WooCommerce Monorepo
|
- name: Setup WooCommerce Monorepo
|
||||||
|
if: steps.changed-files.outputs.any_changed == 'true'
|
||||||
uses: ./.github/actions/setup-woocommerce-monorepo
|
uses: ./.github/actions/setup-woocommerce-monorepo
|
||||||
with:
|
with:
|
||||||
build: false
|
build: false
|
||||||
|
|
||||||
- name: Tool versions
|
- name: Tool versions
|
||||||
|
if: steps.changed-files.outputs.any_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
php --version
|
php --version
|
||||||
composer --version
|
composer --version
|
||||||
|
|
||||||
- name: Run code sniffer
|
- name: Run PHPCS
|
||||||
uses: thenabeel/action-phpcs@v8
|
if: steps.changed-files.outputs.any_changed == 'true'
|
||||||
with:
|
run: ./plugins/woocommerce/vendor/bin/phpcs -n -q --report=checkstyle ${{ steps.changed-files.outputs.all_changed_files }} | cs2pr
|
||||||
files: "**.php"
|
|
||||||
phpcs_path: plugins/woocommerce/vendor/bin/phpcs
|
|
||||||
standard: phpcs.xml
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ jobs:
|
||||||
steps.e2e.conclusion != 'skipped'
|
steps.e2e.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean e2e/allure-results --output e2e/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive E2E test report
|
- name: Archive E2E test report
|
||||||
if: |
|
if: |
|
||||||
|
@ -78,8 +78,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: ${{ env.E2E_ARTIFACT }}
|
name: ${{ env.E2E_ARTIFACT }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/e2e/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/e2e/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
@ -88,6 +88,9 @@ jobs:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
needs: [e2e-tests]
|
needs: [e2e-tests]
|
||||||
if: always()
|
if: always()
|
||||||
|
env:
|
||||||
|
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-results
|
||||||
|
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/api-test-report/allure-report
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -119,7 +122,7 @@ jobs:
|
||||||
steps.run_playwright_api_tests.conclusion != 'skipped'
|
steps.run_playwright_api_tests.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean api-test-report/allure-results --output api-test-report/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive API test report
|
- name: Archive API test report
|
||||||
if: |
|
if: |
|
||||||
|
@ -129,8 +132,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: ${{ env.API_ARTIFACT }}
|
name: ${{ env.API_ARTIFACT }}
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/api-test-report/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/api-test-report/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
@ -194,6 +197,8 @@ jobs:
|
||||||
if: always()
|
if: always()
|
||||||
env:
|
env:
|
||||||
USE_WP_ENV: 1
|
USE_WP_ENV: 1
|
||||||
|
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/allure-results
|
||||||
|
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/allure-report
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -254,7 +259,7 @@ jobs:
|
||||||
steps.e2e.conclusion != 'skipped'
|
steps.e2e.conclusion != 'skipped'
|
||||||
)
|
)
|
||||||
working-directory: plugins/woocommerce
|
working-directory: plugins/woocommerce
|
||||||
run: pnpm exec allure generate --clean e2e/allure-results --output e2e/allure-report
|
run: pnpm exec allure generate --clean ${{ env.ALLURE_RESULTS_DIR }} --output ${{ env.ALLURE_REPORT_DIR }}
|
||||||
|
|
||||||
- name: Archive E2E test report
|
- name: Archive E2E test report
|
||||||
if: |
|
if: |
|
||||||
|
@ -264,8 +269,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: Smoke tests with ${{ matrix.plugin }} plugin installed (run ${{ github.run_number }})
|
name: Smoke tests with ${{ matrix.plugin }} plugin installed (run ${{ github.run_number }})
|
||||||
path: |
|
path: |
|
||||||
plugins/woocommerce/e2e/allure-results
|
${{ env.ALLURE_RESULTS_DIR }}
|
||||||
plugins/woocommerce/e2e/allure-report
|
${{ env.ALLURE_REPORT_DIR }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,6 @@ export const PricingSection: React.FC = () => {
|
||||||
<InputControl
|
<InputControl
|
||||||
{ ...regularPriceProps }
|
{ ...regularPriceProps }
|
||||||
label={ __( 'List price', 'woocommerce' ) }
|
label={ __( 'List price', 'woocommerce' ) }
|
||||||
placeholder={ __( '10.59', 'woocommerce' ) }
|
|
||||||
value={ formatCurrencyDisplayValue(
|
value={ formatCurrencyDisplayValue(
|
||||||
String( regularPriceProps?.value ),
|
String( regularPriceProps?.value ),
|
||||||
currencyConfig,
|
currencyConfig,
|
||||||
|
@ -161,7 +160,6 @@ export const PricingSection: React.FC = () => {
|
||||||
<InputControl
|
<InputControl
|
||||||
{ ...salePriceProps }
|
{ ...salePriceProps }
|
||||||
label={ salePriceTitle }
|
label={ salePriceTitle }
|
||||||
placeholder={ __( '8.59', 'woocommerce' ) }
|
|
||||||
value={ formatCurrencyDisplayValue(
|
value={ formatCurrencyDisplayValue(
|
||||||
String( salePriceProps?.value ),
|
String( salePriceProps?.value ),
|
||||||
currencyConfig,
|
currencyConfig,
|
||||||
|
|
|
@ -70,10 +70,6 @@ export const ProductInventorySection: React.FC = () => {
|
||||||
'SKU (Stock Keeping Unit)',
|
'SKU (Stock Keeping Unit)',
|
||||||
'woocommerce'
|
'woocommerce'
|
||||||
) }
|
) }
|
||||||
placeholder={ __(
|
|
||||||
'washed-oxford-button-down-shirt',
|
|
||||||
'woocommerce'
|
|
||||||
) }
|
|
||||||
{ ...getInputProps( 'sku' ) }
|
{ ...getInputProps( 'sku' ) }
|
||||||
/>
|
/>
|
||||||
<div className="woocommerce-product-form__field">
|
<div className="woocommerce-product-form__field">
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: add
|
||||||
|
|
||||||
|
Add playwright api-core-tests for webhooks crud operations
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: add
|
||||||
|
|
||||||
|
Added npm script for Playwright API Core Tests
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Uses the globa-setup.js to setup permalinks structure
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Use plugins/woocommerce/tests/e2e-pw folder for saving test outputs
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: enhancement
|
||||||
|
|
||||||
|
Remove some placeholder values
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: add
|
||||||
|
|
||||||
|
Added states for Senegal.
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: tweak
|
||||||
|
|
||||||
|
typo fix
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Update api-core-tests readme for consistency with new command and updates to other commands too.
|
|
@ -1543,6 +1543,22 @@ return array(
|
||||||
'VS' => __( 'Vaslui', 'woocommerce' ),
|
'VS' => __( 'Vaslui', 'woocommerce' ),
|
||||||
'VN' => __( 'Vrancea', 'woocommerce' ),
|
'VN' => __( 'Vrancea', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
|
'SN' => array( // Regions of Senegal. Ref: https://github.com/unicode-org/cldr/blob/release-42/common/subdivisions/en.xml#L4801.
|
||||||
|
'SNDB' => __( 'Diourbel', 'woocommerce' ),
|
||||||
|
'SNDK' => __( 'Dakar', 'woocommerce' ),
|
||||||
|
'SNFK' => __( 'Fatick', 'woocommerce' ),
|
||||||
|
'SNKA' => __( 'Kaffrine', 'woocommerce' ),
|
||||||
|
'SNKD' => __( 'Kolda', 'woocommerce' ),
|
||||||
|
'SNKE' => __( 'Kédougou', 'woocommerce' ),
|
||||||
|
'SNKL' => __( 'Kaolack', 'woocommerce' ),
|
||||||
|
'SNLG' => __( 'Louga', 'woocommerce' ),
|
||||||
|
'SNMT' => __( 'Matam', 'woocommerce' ),
|
||||||
|
'SNSE' => __( 'Sédhiou', 'woocommerce' ),
|
||||||
|
'SNSL' => __( 'Saint-Louis', 'woocommerce' ),
|
||||||
|
'SNTC' => __( 'Tambacounda', 'woocommerce' ),
|
||||||
|
'SNTH' => __( 'Thiès', 'woocommerce' ),
|
||||||
|
'SNZG' => __( 'Ziguinchor', 'woocommerce' ),
|
||||||
|
),
|
||||||
'SG' => array(),
|
'SG' => array(),
|
||||||
'SK' => array(),
|
'SK' => array(),
|
||||||
'SI' => array(),
|
'SI' => array(),
|
||||||
|
|
|
@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Command for WooCommere CLI.
|
* Main Command for WooCommerce CLI.
|
||||||
*
|
*
|
||||||
* Since a lot of WC operations can be handled via the REST API, we base our CLI
|
* Since a lot of WC operations can be handled via the REST API, we base our CLI
|
||||||
* off of Restful to generate commands for each WooCommerce REST API endpoint
|
* off of Restful to generate commands for each WooCommerce REST API endpoint
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
"env:dev": "pnpm wp-env start",
|
"env:dev": "pnpm wp-env start",
|
||||||
"env:test": "pnpm run env:dev && ./tests/e2e-pw/bin/test-env-setup.sh",
|
"env:test": "pnpm run env:dev && ./tests/e2e-pw/bin/test-env-setup.sh",
|
||||||
"test:e2e-pw": "USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js",
|
"test:e2e-pw": "USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js",
|
||||||
|
"test:api-pw": "USE_WP_ENV=1 pnpm playwright test --config=tests/api-core-tests/playwright.config.js",
|
||||||
"env:test:cot": "pnpm run env:dev && ./tests/e2e-pw/bin/test-env-setup.sh --cot",
|
"env:test:cot": "pnpm run env:dev && ./tests/e2e-pw/bin/test-env-setup.sh --cot",
|
||||||
"env:performance-init": "./tests/performance/bin/init-sample-products.sh",
|
"env:performance-init": "./tests/performance/bin/init-sample-products.sh",
|
||||||
"env:down": "pnpm wp-env stop",
|
"env:down": "pnpm wp-env stop",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Loads WooCommece packages from the /packages directory. These are packages developed outside of core.
|
* Loads WooCommerce packages from the /packages directory. These are packages developed outside of core.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Automattic\WooCommerce;
|
namespace Automattic\WooCommerce;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# WooCommerce Playwright End to End Tests
|
# WooCommerce Core API Test Suite
|
||||||
|
|
||||||
This is the documentation for the new api-core-tests setup based on Playwright and wp-env. It superseedes the Puppeteer and e2e-environment [setup](../tests/e2e), which we will gradually deprecate.
|
This package contains automated API tests for WooCommerce, based on Playwright and `wp-env`. It supersedes the SuperTest based [api-core-tests package](https://www.npmjs.com/package/@woocommerce/api-core-tests) and e2e-environment [setup](../tests/e2e), which we will gradually deprecate.
|
||||||
|
|
||||||
## Table of contents
|
## Table of contents
|
||||||
|
|
||||||
|
@ -21,36 +21,33 @@ This is the documentation for the new api-core-tests setup based on Playwright a
|
||||||
- PNPM ([Installation instructions](https://pnpm.io/installation))
|
- PNPM ([Installation instructions](https://pnpm.io/installation))
|
||||||
- Docker and Docker Compose ([Installation instructions](https://docs.docker.com/engine/install/))
|
- Docker and Docker Compose ([Installation instructions](https://docs.docker.com/engine/install/))
|
||||||
|
|
||||||
Note, that if you are on Mac and you install docker through other methods such as homebrew, for example, your steps to set it up might be different. The commands listed in steps below may also vary.
|
Note, that if you are on Mac and you install Docker through other methods such as homebrew, for example, your steps to set it up might be different. The commands listed in steps below may also vary.
|
||||||
|
|
||||||
If you are using Windows, we recommend using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) for running E2E tests. Follow the [WSL Setup Instructions](../tests/e2e/WSL_SETUP_INSTRUCTIONS.md) first before proceeding with the steps below.
|
If you are using Windows, we recommend using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) for running tests. Follow the [WSL Setup Instructions](../tests/e2e/WSL_SETUP_INSTRUCTIONS.md) first before proceeding with the steps below.
|
||||||
|
|
||||||
### Introduction
|
### Introduction
|
||||||
|
|
||||||
api-core-tests are powered by Playwright. The test site is spinned up using `wp-env` (recommended), but we will continue to support `e2e-environment` in the meantime.
|
WooCommerce's `api-core-tests` are powered by Playwright. The test site is spun up using `wp-env` (recommended), but we will continue to support `e2e-environment` in the meantime.
|
||||||
|
|
||||||
**Running tests for the first time:**
|
**Running tests for the first time:**
|
||||||
Note: the commands may need to be executed in `plugins/woocommerce` (or a subdirectory thereof)
|
|
||||||
|
|
||||||
- `nvm use`
|
- `nvm use`
|
||||||
- `pnpm install`
|
- `pnpm install`
|
||||||
- `pnpm run build --filter=woocommerce`
|
- `pnpm run build --filter=woocommerce`
|
||||||
- `pnpm env:test --filter=woocommerce`
|
- `cd plugins/woocommerce`
|
||||||
|
- `pnpm env:test`
|
||||||
Then execute the tests with the following command:
|
- `pnpm test:api-pw`
|
||||||
|
|
||||||
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/api-core-tests/playwright.config.js` (headless)
|
|
||||||
|
|
||||||
To run the test again, re-create the environment to start with a fresh state
|
To run the test again, re-create the environment to start with a fresh state
|
||||||
|
|
||||||
- `pnpm env:destroy --filter=woocommerce`
|
- `pnpm env:destroy`
|
||||||
- `pnpm env:test --filter=woocommerce`
|
- `pnpm env:test`
|
||||||
|
- `pnpm test:api-pw`
|
||||||
|
|
||||||
Other ways of running tests:
|
Other ways of running tests:
|
||||||
|
|
||||||
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/api-core-tests/playwright.config.js --headed` (headed)
|
- `pnpm test:api-pw --debug` (debug)
|
||||||
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/api-core-tests/playwright.config.js --debug` (debug)
|
- `pnpm test:api-pw ./tests/api-core-tests/tests/hello/hello.test.js` (running a single test)
|
||||||
- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/api-core-tests/playwright.config.js ./tests/api-core-tests/tests/hello/hello.test.js` (running a single test)
|
|
||||||
|
|
||||||
To see all options, run `cd plugins/woocommerce && pnpm playwright test --help`
|
To see all options, run `cd plugins/woocommerce && pnpm playwright test --help`
|
||||||
|
|
||||||
|
@ -69,8 +66,7 @@ USER_KEY=""
|
||||||
USER_SECRET=""
|
USER_SECRET=""
|
||||||
```
|
```
|
||||||
|
|
||||||
For local setup, create a `.env` file in the `woocommerce/plugins/woocommerce` folder with the three required values described above.
|
For local setup, create a `.env` file in the `woocommerce/plugins/woocommerce` folder with the three required values described above. If any of these variables are configured they will override the values automatically set in the `playwright.config.js`
|
||||||
If any of these variables are configured they will override the values automatically set in the `playwright.config.js`
|
|
||||||
|
|
||||||
When using a username and password combination instead of a consumer secret and consumer key, make sure to have the [JSON Basic Authentication plugin](https://github.com/WP-API/Basic-Auth) installed and activated on the test site.
|
When using a username and password combination instead of a consumer secret and consumer key, make sure to have the [JSON Basic Authentication plugin](https://github.com/WP-API/Basic-Auth) installed and activated on the test site.
|
||||||
|
|
||||||
|
@ -113,11 +109,11 @@ The test environment uses the following test variables:
|
||||||
|
|
||||||
If you need to modify the port for your local test environment (eg. port is already in use) or use, edit [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js). Depending on what environment tool you are using, you will need to also edit the respective `.json` file.
|
If you need to modify the port for your local test environment (eg. port is already in use) or use, edit [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js). Depending on what environment tool you are using, you will need to also edit the respective `.json` file.
|
||||||
|
|
||||||
**Modiify the port wp-env**
|
**Modify the port wp-env**
|
||||||
|
|
||||||
Edit [.wp-env.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/.wp-env.json) and [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js).
|
Edit [.wp-env.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/.wp-env.json) and [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js).
|
||||||
|
|
||||||
**Modiify port for e2e-environment**
|
**Modify port for e2e-environment**
|
||||||
|
|
||||||
Edit [tests/e2e/config/default.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/config/default.json).****
|
Edit [tests/e2e/config/default.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/config/default.json).****
|
||||||
|
|
||||||
|
@ -125,9 +121,9 @@ Edit [tests/e2e/config/default.json](https://github.com/woocommerce/woocommerce/
|
||||||
|
|
||||||
After you run a test, it's best to restart the environment to start from a fresh state. We are currently working to reset the state more efficiently to avoid the restart being needed, but this is a work-in-progress.
|
After you run a test, it's best to restart the environment to start from a fresh state. We are currently working to reset the state more efficiently to avoid the restart being needed, but this is a work-in-progress.
|
||||||
|
|
||||||
- `pnpm env:down --filter=woocommerce` to stop the environment
|
- `pnpm env:down` to stop the environment
|
||||||
- `pnpm env:destroy --filter=woocommerce` when you make changes to `.wp-env.json`
|
- `pnpm env:destroy` when you make changes to `.wp-env.json`
|
||||||
- `pnpm env:test --filter=woocommerce` to spin up the test environment
|
- `pnpm env:test` to spin up the test environment
|
||||||
|
|
||||||
## Guide for writing tests
|
## Guide for writing tests
|
||||||
|
|
||||||
|
@ -142,17 +138,11 @@ Based on our example, the test skeleton would look as follows:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
test.describe( 'Merchant can create virtual product', () => {
|
test.describe( 'Merchant can create virtual product', () => {
|
||||||
test( 'merchant can log in', async () => {
|
test( 'merchant can log in', async () => { } );
|
||||||
|
|
||||||
} );
|
test( 'merchant can create virtual product', async () => { } );
|
||||||
|
|
||||||
test( 'merchant can create virtual product', async () => {
|
test( 'merchant can verify that virtual product was created', async () => { } );
|
||||||
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'merchant can verify that virtual product was created', async () => {
|
|
||||||
|
|
||||||
} );
|
|
||||||
} );
|
} );
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,19 @@ const config = {
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'allure-playwright',
|
'allure-playwright',
|
||||||
{ outputFolder: 'api-test-report/allure-results' },
|
{
|
||||||
|
outputFolder:
|
||||||
|
process.env.ALLURE_RESULTS_DIR ??
|
||||||
|
'tests/api-core-tests/api-test-report/allure-results',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'json',
|
||||||
|
{
|
||||||
|
outputFile:
|
||||||
|
'tests/api-core-tests/api-test-report/test-results.json',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
[ 'json', { outputFile: 'api-test-report/test-results.json' } ],
|
|
||||||
],
|
],
|
||||||
use: {
|
use: {
|
||||||
screenshot: 'only-on-failure',
|
screenshot: 'only-on-failure',
|
||||||
|
|
|
@ -0,0 +1,254 @@
|
||||||
|
const {
|
||||||
|
test,
|
||||||
|
expect
|
||||||
|
} = require('@playwright/test');
|
||||||
|
const exp = require('constants');
|
||||||
|
const {
|
||||||
|
refund
|
||||||
|
} = require('../../data');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the WooCommerce Refunds API.
|
||||||
|
*
|
||||||
|
* @group api
|
||||||
|
* @group webhooks
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
test.describe('Webhooks API tests', () => {
|
||||||
|
let webhookId;
|
||||||
|
|
||||||
|
test.describe('Create a webhook', () => {
|
||||||
|
|
||||||
|
test('can create a webhook', async ({
|
||||||
|
request,
|
||||||
|
}) => {
|
||||||
|
// call API to create a webhook
|
||||||
|
const response = await request.post(
|
||||||
|
'/wp-json/wc/v3/webhooks', {
|
||||||
|
data: {
|
||||||
|
name: "Order updated",
|
||||||
|
topic: "order.updated",
|
||||||
|
delivery_url: "http://requestb.in/1g0sxmo1"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const responseJSON = await response.json();
|
||||||
|
expect(response.status()).toEqual(201);
|
||||||
|
expect(typeof responseJSON.id).toEqual('number');
|
||||||
|
expect(responseJSON.name).toEqual("Order updated");
|
||||||
|
expect(responseJSON.status).toEqual("active");
|
||||||
|
expect(responseJSON.topic).toEqual("order.updated");
|
||||||
|
expect(responseJSON.delivery_url).toEqual("http://requestb.in/1g0sxmo1");
|
||||||
|
expect(responseJSON.hooks).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
"woocommerce_update_order",
|
||||||
|
"woocommerce_order_refunded"
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
webhookId = responseJSON.id;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Retrieve after create', () => {
|
||||||
|
test('can retrieve a webhook', async ({
|
||||||
|
request
|
||||||
|
}) => {
|
||||||
|
// call API to retrieve the previously saved webhook
|
||||||
|
const response = await request.get(
|
||||||
|
`/wp-json/wc/v3/webhooks/${webhookId}`
|
||||||
|
);
|
||||||
|
const responseJSON = await response.json();
|
||||||
|
expect(response.status()).toEqual(200);
|
||||||
|
expect(Array.isArray(responseJSON)).toBe(false);
|
||||||
|
expect(typeof responseJSON.id).toEqual('number');
|
||||||
|
expect(responseJSON.name).toEqual("Order updated");
|
||||||
|
expect(responseJSON.status).toEqual("active");
|
||||||
|
expect(responseJSON.topic).toEqual("order.updated");
|
||||||
|
expect(responseJSON.delivery_url).toEqual("http://requestb.in/1g0sxmo1");
|
||||||
|
expect(responseJSON.hooks).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
"woocommerce_update_order",
|
||||||
|
"woocommerce_order_refunded"
|
||||||
|
])
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can retrieve all webhooks', async ({
|
||||||
|
request
|
||||||
|
}) => {
|
||||||
|
// call API to retrieve all webhooks
|
||||||
|
const response = await request.get('/wp-json/wc/v3/webhooks');
|
||||||
|
const responseJSON = await response.json();
|
||||||
|
expect(response.status()).toEqual(200);
|
||||||
|
expect(Array.isArray(responseJSON));
|
||||||
|
expect(responseJSON.length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Update a webhook', () => {
|
||||||
|
test(`can update a web hook`, async ({
|
||||||
|
request,
|
||||||
|
}) => {
|
||||||
|
// update webhook
|
||||||
|
const response = await request.put(
|
||||||
|
`/wp-json/wc/v3/webhooks/${ webhookId }`, {
|
||||||
|
data: {
|
||||||
|
status: "paused"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const responseJSON = await response.json();
|
||||||
|
expect(response.status()).toEqual(200);
|
||||||
|
expect(responseJSON.status).toEqual("paused");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Delete a webhook', () => {
|
||||||
|
test('can permanently delete a webhook', async ({
|
||||||
|
request
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
// Delete the webhook
|
||||||
|
const response = await request.delete(`/wp-json/wc/v3/webhooks/${ webhookId }`, {
|
||||||
|
data: {
|
||||||
|
force: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(response.status()).toEqual(200);
|
||||||
|
|
||||||
|
// Verify that the webhook can no longer be retrieved
|
||||||
|
const getDeletedWebhookResponse = await request.get(
|
||||||
|
`/wp-json/wc/v3/webhooks/${ webhookId }`
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue raised as we would expect this to return a 400 to be
|
||||||
|
* consistent with the other API calls
|
||||||
|
* Issue: https://github.com/woocommerce/woocommerce/issues/35290
|
||||||
|
*/
|
||||||
|
expect(getDeletedWebhookResponse.status()).toEqual(400);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test.describe('Batch webhook operations', () => {
|
||||||
|
let webhookId1;
|
||||||
|
let webhookId2;
|
||||||
|
let webhookId3;
|
||||||
|
test('can batch create webhooks', async ({
|
||||||
|
request
|
||||||
|
}) => {
|
||||||
|
// Batch create webhooks
|
||||||
|
// call API to batch create a webhook
|
||||||
|
const response = await request.post('wp-json/wc/v3/webhooks/batch', {
|
||||||
|
data: {
|
||||||
|
create: [{
|
||||||
|
name: "Round toe",
|
||||||
|
topic: "coupon.created",
|
||||||
|
delivery_url: "http://requestb.in/1g0sxmo1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Customer deleted",
|
||||||
|
topic: "customer.deleted",
|
||||||
|
delivery_url: "http://requestb.in/1g0sxmo1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const responseJSON = await response.json();
|
||||||
|
expect(response.status()).toEqual(200);
|
||||||
|
|
||||||
|
// Verify that the new webhooks were created
|
||||||
|
const webhooks = responseJSON.create;
|
||||||
|
expect(webhooks).toHaveLength(2);
|
||||||
|
webhookId1 = webhooks[0].id;
|
||||||
|
webhookId2 = webhooks[1].id;
|
||||||
|
expect(webhookId1).toBeDefined();
|
||||||
|
expect(webhookId2).toBeDefined();
|
||||||
|
expect(webhooks[0].name).toEqual('Round toe');
|
||||||
|
expect(webhooks[1].name).toEqual('Customer deleted');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can batch update webhooks', async ({
|
||||||
|
request
|
||||||
|
}) => {
|
||||||
|
// set payload to create, update and delete webhooks
|
||||||
|
const batchUpdatePayload = {
|
||||||
|
create: [{
|
||||||
|
name: "Order Created",
|
||||||
|
topic: "order.created",
|
||||||
|
delivery_url: "http://requestb.in/1g0sxmo1"
|
||||||
|
}, ],
|
||||||
|
update: [{
|
||||||
|
id: webhookId1,
|
||||||
|
name: 'Square toe',
|
||||||
|
}, ],
|
||||||
|
delete: [webhookId2]
|
||||||
|
};
|
||||||
|
|
||||||
|
// Call API to batch update the webhooks
|
||||||
|
const response = await request.post(
|
||||||
|
'wp-json/wc/v3/webhooks/batch', {
|
||||||
|
data: batchUpdatePayload,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const responseJSON = await response.json();
|
||||||
|
expect(response.status()).toEqual(200);
|
||||||
|
expect(responseJSON.create).toHaveLength(1);
|
||||||
|
|
||||||
|
webhookId3 = responseJSON.create[0].id;
|
||||||
|
expect(webhookId3).toBeDefined();
|
||||||
|
expect(responseJSON.create[0].name).toEqual('Order Created');
|
||||||
|
expect(responseJSON.create[0].topic).toEqual('order.created');
|
||||||
|
expect(responseJSON.create[0].delivery_url).toEqual('http://requestb.in/1g0sxmo1');
|
||||||
|
|
||||||
|
expect(responseJSON.update).toHaveLength(1);
|
||||||
|
expect(responseJSON.update[0].id).toEqual(webhookId1);
|
||||||
|
expect(responseJSON.update[0].name).toEqual('Square toe');
|
||||||
|
|
||||||
|
// Verify that the deleted webhook can no longer be retrieved
|
||||||
|
const getDeletedWebhookResponse = await request.get(
|
||||||
|
`/wp-json/wc/v3/webhooks/${ webhookId2 }`
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* Issue raised as we would expect this to return a 400 to be
|
||||||
|
* consistent with the other API calls
|
||||||
|
* Issue: https://github.com/woocommerce/woocommerce/issues/35290
|
||||||
|
*/
|
||||||
|
expect(getDeletedWebhookResponse.status()).toEqual(400);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can batch delete webhooks', async ({
|
||||||
|
request
|
||||||
|
}) => {
|
||||||
|
// Batch delete the created webhooks
|
||||||
|
const response = await request.post(
|
||||||
|
'wp-json/wc/v3/webhooks/batch', {
|
||||||
|
data: {
|
||||||
|
delete: [webhookId1, webhookId3]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const responseJSON = await response.json();
|
||||||
|
|
||||||
|
//Call the API to attempte to retrieve the deleted webhooks
|
||||||
|
const deletedResponse1 = await request.get(
|
||||||
|
`wp-json/wc/v3/webhooks/${ webhookId1 }`
|
||||||
|
);
|
||||||
|
const deletedResponse3 = await request.get(
|
||||||
|
`wp-json/wc/v3/webhooks/${ webhookId3 }`
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* Issue raised as we would expect this to return a 400 to be
|
||||||
|
* consistent with the other API calls
|
||||||
|
* Issue: https://github.com/woocommerce/woocommerce/issues/35290
|
||||||
|
*/
|
||||||
|
expect(deletedResponse1.status()).toEqual(400);
|
||||||
|
expect(deletedResponse3.status()).toEqual(400);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -11,6 +11,19 @@ const adminPassword = ADMIN_PASSWORD ?? 'password';
|
||||||
const customerUsername = CUSTOMER_USER ?? 'customer';
|
const customerUsername = CUSTOMER_USER ?? 'customer';
|
||||||
const customerPassword = CUSTOMER_PASSWORD ?? 'password';
|
const customerPassword = CUSTOMER_PASSWORD ?? 'password';
|
||||||
|
|
||||||
|
const setupPermalinks = async ( adminPage, baseURL ) => {
|
||||||
|
console.log( 'Trying to setup permalinks!' );
|
||||||
|
await adminPage.goto( baseURL + '/wp-admin/options-permalink.php' );
|
||||||
|
await expect( adminPage.locator( 'div.wrap > h1' ) ).toHaveText(
|
||||||
|
'Permalink Settings'
|
||||||
|
);
|
||||||
|
await adminPage.click( '#custom_selection' );
|
||||||
|
await adminPage.fill( '#permalink_structure', '/%postname%/' );
|
||||||
|
await adminPage.click( '#submit' );
|
||||||
|
|
||||||
|
console.log( 'Permalinks Set!' );
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = async ( config ) => {
|
module.exports = async ( config ) => {
|
||||||
const { stateDir, baseURL, userAgent } = config.projects[ 0 ].use;
|
const { stateDir, baseURL, userAgent } = config.projects[ 0 ].use;
|
||||||
|
|
||||||
|
@ -129,6 +142,30 @@ module.exports = async ( config ) => {
|
||||||
process.exit( 1 );
|
process.exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that permalinks are correctly setup since we can't set it up using wp-env when not using the default WP version.
|
||||||
|
// More info here: https://github.com/WordPress/gutenberg/issues/28201
|
||||||
|
let permalinkConfigured = false;
|
||||||
|
const permalinkRetries = 5;
|
||||||
|
for ( let i = 0; i < permalinkRetries; i++ ) {
|
||||||
|
try {
|
||||||
|
await setupPermalinks( adminPage, baseURL );
|
||||||
|
permalinkConfigured = true;
|
||||||
|
break;
|
||||||
|
} catch ( e ) {
|
||||||
|
console.log(
|
||||||
|
`Setting permalink failed, Retrying... ${ i }/${ permalinkRetries }`
|
||||||
|
);
|
||||||
|
console.log( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! permalinkConfigured ) {
|
||||||
|
console.error(
|
||||||
|
'Cannot proceed e2e test, as we could not setup permalinks. Please check if the test site has been setup correctly.'
|
||||||
|
);
|
||||||
|
process.exit( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
// Sign in as customer user and save state
|
// Sign in as customer user and save state
|
||||||
const customerRetries = 5;
|
const customerRetries = 5;
|
||||||
for ( let i = 0; i < customerRetries; i++ ) {
|
for ( let i = 0; i < customerRetries; i++ ) {
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
const { devices } = require( '@playwright/test' );
|
const { devices } = require( '@playwright/test' );
|
||||||
const {
|
const {
|
||||||
CI,
|
ALLURE_RESULTS_DIR,
|
||||||
E2E_MAX_FAILURES,
|
|
||||||
BASE_URL,
|
BASE_URL,
|
||||||
|
CI,
|
||||||
DEFAULT_TIMEOUT_OVERRIDE,
|
DEFAULT_TIMEOUT_OVERRIDE,
|
||||||
|
E2E_MAX_FAILURES,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
@ -26,17 +27,23 @@ const config = {
|
||||||
open: CI ? 'never' : 'always',
|
open: CI ? 'never' : 'always',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[ 'allure-playwright', { outputFolder: 'e2e/allure-results' } ],
|
[
|
||||||
[ 'json', { outputFile: 'e2e/test-results.json' } ],
|
'allure-playwright',
|
||||||
|
{
|
||||||
|
outputFolder:
|
||||||
|
ALLURE_RESULTS_DIR ?? 'tests/e2e-pw/allure-results',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[ 'json', { outputFile: 'tests/e2e-pw/test-results.json' } ],
|
||||||
],
|
],
|
||||||
maxFailures: E2E_MAX_FAILURES ? Number( E2E_MAX_FAILURES ) : 0,
|
maxFailures: E2E_MAX_FAILURES ? Number( E2E_MAX_FAILURES ) : 0,
|
||||||
use: {
|
use: {
|
||||||
screenshot: 'only-on-failure',
|
|
||||||
video: 'on-first-retry',
|
|
||||||
trace: 'retain-on-failure',
|
|
||||||
viewport: { width: 1280, height: 720 },
|
|
||||||
baseURL: BASE_URL ?? 'http://localhost:8086',
|
baseURL: BASE_URL ?? 'http://localhost:8086',
|
||||||
stateDir: 'e2e/storage/',
|
screenshot: 'only-on-failure',
|
||||||
|
stateDir: 'tests/e2e-pw/storage/',
|
||||||
|
trace: 'retain-on-failure',
|
||||||
|
video: 'on-first-retry',
|
||||||
|
viewport: { width: 1280, height: 720 },
|
||||||
},
|
},
|
||||||
projects: [
|
projects: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
{
|
|
||||||
"cookies": [
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
|
|
||||||
"value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C8ac4ff905331544a3cbcf0c58840ebfc3f492d4511dd17f48dbed18f5662a2c6",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/wp-content/plugins",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": true,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
|
|
||||||
"value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C8ac4ff905331544a3cbcf0c58840ebfc3f492d4511dd17f48dbed18f5662a2c6",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/wp-admin",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": true,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_test_cookie",
|
|
||||||
"value": "WP%20Cookie%20check",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": false,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_logged_in_dc5025de8b60c0a511df7c07d81ead97",
|
|
||||||
"value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C6de27e0d8393de7715c07e144424d90733d53e65b8665c8a7db1ad94798c369c",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": true,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "tk_ai",
|
|
||||||
"value": "woo%3AT9QFbJmpuSGWcjApaONaBtSB",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": false,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wp-settings-time-1",
|
|
||||||
"value": "1660233126",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/",
|
|
||||||
"expires": 1691769126.937059,
|
|
||||||
"httpOnly": false,
|
|
||||||
"secure": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"origins": []
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
{
|
|
||||||
"cookies": [
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
|
|
||||||
"value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7Cccb6b6b9e1190e94ef751360fded6ec026c89350f9f4695e9bf900ca09d72a84",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/wp-content/plugins",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": true,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_dc5025de8b60c0a511df7c07d81ead97",
|
|
||||||
"value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7Cccb6b6b9e1190e94ef751360fded6ec026c89350f9f4695e9bf900ca09d72a84",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/wp-admin",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": true,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_test_cookie",
|
|
||||||
"value": "WP%20Cookie%20check",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": false,
|
|
||||||
"secure": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sameSite": "Lax",
|
|
||||||
"name": "wordpress_logged_in_dc5025de8b60c0a511df7c07d81ead97",
|
|
||||||
"value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7C869a28fa8ef17799b6d097d84c8155c7d0dd18cd9967f7a18e3f49f41dd71226",
|
|
||||||
"domain": "localhost",
|
|
||||||
"path": "/",
|
|
||||||
"expires": -1,
|
|
||||||
"httpOnly": true,
|
|
||||||
"secure": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"origins": []
|
|
||||||
}
|
|
Loading…
Reference in New Issue