diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..d67e849 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,94 @@ +name: Playwright E2E + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + e2e: + runs-on: ubuntu-latest + timeout-minutes: 30 + + env: + # Playwright (the acceptance-test-suite reads SHOPWARE_ADMIN_*). + APP_URL: http://localhost:8000 + SHOPWARE_ADMIN_USERNAME: admin + SHOPWARE_ADMIN_PASSWORD: shopware + # Consumed directly by shopware-cli for the Admin API upload — no config + # file needed (these take precedence over any .shopware-project.yml). + SHOPWARE_CLI_API_URL: http://localhost:8000 + SHOPWARE_CLI_API_USERNAME: admin + SHOPWARE_CLI_API_PASSWORD: shopware + + # The demo environment runs as a service container. Its baked-in default + # APP_URL is already http://localhost:8000, matching what we test against, so + # no overrides are needed. The image has no Docker HEALTHCHECK, so readiness + # is polled in a step below rather than via `options: --health-*`. + services: + shopware: + image: ghcr.io/friendsofshopware/shopware-demo-environment:6.7 + ports: + - 8000:8000 + + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Setup shopware-cli + uses: shopware/shopware-cli-action@v3 + + - name: Build extension zip + id: zip + uses: shopwareLabs/build-extension-zip-action@main + with: + output-directory: dist + + - name: Wait for Shopware to be ready + run: | + for i in $(seq 1 60); do + code=$(curl -s -o /dev/null -w "%{http_code}" "${APP_URL}/admin" || true) + echo "attempt ${i}: HTTP ${code}" + if [ "${code}" = "200" ]; then exit 0; fi + sleep 5 + done + echo "Shopware did not become ready in time" >&2 + exit 1 + + - name: Upload and activate the plugin + run: shopware-cli project extension upload dist/FroshAdminDashboard.zip --activate + + - name: Setup Node + uses: actions/setup-node@v6 + with: + node-version: 22 + cache: npm + cache-dependency-path: tests/package-lock.json + + - name: Install test dependencies + working-directory: tests + run: npm ci + + - name: Install Playwright browser + working-directory: tests + run: npx playwright install --with-deps chromium + + - name: Run Playwright tests + working-directory: tests + run: npx playwright test + + - name: Upload Playwright report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v7 + with: + name: playwright-report + path: tests/playwright-report + retention-days: 14 + + - name: Dump Shopware logs on failure + if: failure() + run: | + # Service containers get a generated name; find it by image. + cid=$(docker ps -a --filter "ancestor=ghcr.io/friendsofshopware/shopware-demo-environment:6.7" --format '{{.ID}}' | head -n1) + if [ -n "$cid" ]; then docker logs "$cid"; fi diff --git a/.github/workflows/store-info.yml b/.github/workflows/store-info.yml index 334929e..73ac87f 100644 --- a/.github/workflows/store-info.yml +++ b/.github/workflows/store-info.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Install shopware-cli - uses: shopware/shopware-cli-action@v1 + uses: shopware/shopware-cli-action@v3 - name: Build shell: bash run: shopware-cli account producer extension info push . diff --git a/.gitignore b/.gitignore index 27b6643..9e622d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ /vendor/ /node_modules/ /src/Resources/public/ +/src/Storefront/Resources/public/ +/dist/ *.log .DS_Store .idea/ diff --git a/.shopware-extension.yml b/.shopware-extension.yml index 1e6e133..70a886a 100644 --- a/.shopware-extension.yml +++ b/.shopware-extension.yml @@ -1,4 +1,9 @@ compatibility_date: '2026-02-11' +build: + zip: + assets: + enable_asset_caching: true + store: availabilities: - German diff --git a/tests/.gitignore b/tests/.gitignore index 2e2c064..c86f571 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,5 +1,4 @@ node_modules/ -package-lock.json .env /playwright-report/ /test-results/ diff --git a/tests/README.md b/tests/README.md index 5d0f246..cae3511 100644 --- a/tests/README.md +++ b/tests/README.md @@ -43,3 +43,22 @@ npm run test:report # open the last HTML report Selectors live in `pages/dashboard.page.ts` and use the plugin's BEM classes; widget labels assume the English admin locale. + +## Continuous integration + +`.github/workflows/playwright.yml` runs the suite on every push/PR: + +1. `shopware-cli extension zip` packages the plugin (compiling the admin assets). +2. The [shopware-demo-environment](https://github.com/FriendsOfShopware/shopware-demo-environment) + container is started on `http://localhost:8000`. +3. `shopware-cli project extension upload dist/FroshAdminDashboard.zip --activate` + installs the plugin through the Admin API. The connection is taken straight + from the `SHOPWARE_CLI_API_URL`, `SHOPWARE_CLI_API_USERNAME` and + `SHOPWARE_CLI_API_PASSWORD` environment variables — no config file or + committed credentials needed. +4. Playwright runs against the container and the HTML report is uploaded. + +You can reproduce this locally: start the demo container, then from the plugin +root run `SHOPWARE_CLI_API_URL=… SHOPWARE_CLI_API_USERNAME=admin +SHOPWARE_CLI_API_PASSWORD=shopware shopware-cli project extension upload . --activate`. + diff --git a/tests/e2e/accessibility.spec.ts b/tests/e2e/accessibility.spec.ts index 3839cb7..84c2594 100644 --- a/tests/e2e/accessibility.spec.ts +++ b/tests/e2e/accessibility.spec.ts @@ -12,6 +12,18 @@ test.describe('Frosh Admin Dashboard — accessibility', () => { const dashboard = new DashboardPage(AdminPage); await dashboard.goto(); + // The default dashboard renders two time-series widgets (Total sales, + // Number of orders). Their core sw-chart-card range