From 0fc8442a018d8cc714ef2f591d47ef24fd4260f3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 13:21:39 +0000 Subject: [PATCH] feat: Add E2E testing workflow with Playwright and Dockware This commit introduces a new GitHub Actions workflow for end-to-end (E2E) testing. The workflow is manually triggered and runs on a matrix of Shopware versions (6.6 and 6.7). It uses `shopware-cli` to build the plugin into a zip archive. A clean Shopware environment is started using Dockware, and the built plugin zip is copied into the container for installation. A basic Playwright test verifies that the storefront homepage loads successfully. The Playwright report is uploaded as a workflow artifact. --- .github/workflows/e2e-tests.yml | 71 +++++++++++++++++++++++++++++++++ .gitignore | 2 + tests/e2e/docker-compose.yml | 13 ++++++ tests/e2e/example.spec.js | 7 ++++ tests/e2e/package.json | 16 ++++++++ 5 files changed, 109 insertions(+) create mode 100644 .github/workflows/e2e-tests.yml create mode 100644 tests/e2e/docker-compose.yml create mode 100644 tests/e2e/example.spec.js create mode 100644 tests/e2e/package.json diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml new file mode 100644 index 0000000..74b6d34 --- /dev/null +++ b/.github/workflows/e2e-tests.yml @@ -0,0 +1,71 @@ +name: E2E Tests + +on: + workflow_dispatch: + +jobs: + e2e: + runs-on: ubuntu-latest + strategy: + matrix: + shopware-version: ['6.6.10.4', '6.7.2.2'] + php-version: ['8.3'] + node-version: [22] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Get Plugin Name + id: plugin_name + run: echo "PLUGIN_NAME=$(jq -r '.extra."shopware-plugin-class" | split("\\\\") | .[0]' composer.json)" >> $GITHUB_ENV + + - name: Install shopware-cli + run: npm i -g @shopware-ag/shopware-cli + + - name: Build plugin zip + run: shopware-cli extension zip . --disable-git + + - name: Get zip file name + id: zip_name + run: echo "ZIP_NAME=$(ls *.zip)" >> $GITHUB_ENV + + - name: Start Shopware + run: | + docker-compose -f tests/e2e/docker-compose.yml up -d --wait + env: + SHOPWARE_VERSION: ${{ matrix.shopware-version }} + + - name: Copy plugin to container + run: docker cp ${{ env.ZIP_NAME }} shopware:/tmp/${{ env.ZIP_NAME }} + + - name: Unzip plugin in container + run: docker-compose -f tests/e2e/docker-compose.yml exec -T shopware unzip /tmp/${{ env.ZIP_NAME }} -d /var/www/html/custom/plugins/ + + - name: Install Plugin + run: | + docker-compose -f tests/e2e/docker-compose.yml exec -T shopware bin/console plugin:install --activate ${{ env.PLUGIN_NAME }} + docker-compose -f tests/e2e/docker-compose.yml exec -T shopware bin/console theme:change Storefront + + - name: Install Playwright dependencies + run: | + cd tests/e2e + npm install + + - name: Run Playwright tests + run: | + cd tests/e2e + npx playwright test + + - name: Upload Playwright Report + if: always() + uses: actions/upload-artifact@v4 + with: + name: playwright-report-${{ matrix.shopware-version }} + path: tests/e2e/playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index d831134..d598450 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ src/Resources/public/administration src/Resources/public/static +/tests/e2e/node_modules +/tests/e2e/package-lock.json diff --git a/tests/e2e/docker-compose.yml b/tests/e2e/docker-compose.yml new file mode 100644 index 0000000..abbd2fe --- /dev/null +++ b/tests/e2e/docker-compose.yml @@ -0,0 +1,13 @@ +services: + shopware: + image: dockware/dev:${SHOPWARE_VERSION} + container_name: shopware + ports: + - "80:80" + environment: + - SHOPWARE_URL=http://localhost + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost"] + interval: 10s + timeout: 5s + retries: 12 diff --git a/tests/e2e/example.spec.js b/tests/e2e/example.spec.js new file mode 100644 index 0000000..436e550 --- /dev/null +++ b/tests/e2e/example.spec.js @@ -0,0 +1,7 @@ +// @ts-check +const { test, expect } = require('@playwright/test'); + +test('homepage loads successfully', async ({ page }) => { + const response = await page.goto('http://localhost:80'); + expect(response.status()).toBe(200); +}); diff --git a/tests/e2e/package.json b/tests/e2e/package.json new file mode 100644 index 0000000..e235ed7 --- /dev/null +++ b/tests/e2e/package.json @@ -0,0 +1,16 @@ +{ + "name": "e2e", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "playwright test" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "commonjs", + "devDependencies": { + "@playwright/test": "latest" + } +}