From ef60ce0c9d2e6328b74310921ae0a3f34fd1f779 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Tue, 22 Apr 2025 16:57:56 +0100 Subject: [PATCH] Fix WordPress Playground tests: update port for multisite, improve test reliability --- .github/workflows/playground-tests-fix.yml | 44 ++++++++++++++++++++++ .github/workflows/playground-tests.yml | 6 +-- cypress/e2e/playground-multisite.cy.js | 8 ++-- cypress/e2e/playground-single-site.cy.js | 7 +++- 4 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/playground-tests-fix.yml diff --git a/.github/workflows/playground-tests-fix.yml b/.github/workflows/playground-tests-fix.yml new file mode 100644 index 0000000..13640ae --- /dev/null +++ b/.github/workflows/playground-tests-fix.yml @@ -0,0 +1,44 @@ +name: WordPress Playground Tests Fix + +on: + push: + branches: [ main, feature/*, bugfix/* ] + pull_request: + branches: [ main ] + +jobs: + playground-test: + name: WordPress Playground Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install WordPress Playground CLI + run: npm install -g @wp-playground/cli + + - name: Create plugin zip + run: | + mkdir -p dist + zip -r dist/plugin.zip . -x "node_modules/*" "dist/*" ".git/*" + + - name: Run tests with WordPress Playground + run: | + # Start WordPress Playground with our blueprint + npx @wp-playground/cli server --blueprint playground/blueprint.json --port 8888 --login & + + # Wait for WordPress Playground to be ready + echo "Waiting for WordPress Playground to be ready..." + timeout 60 bash -c 'until curl -s http://localhost:8888; do sleep 2; done' + + # Run Cypress tests against WordPress Playground + npx cypress run --config specPattern=cypress/e2e/playground-single-site.cy.js diff --git a/.github/workflows/playground-tests.yml b/.github/workflows/playground-tests.yml index bc095cd..393f2ac 100644 --- a/.github/workflows/playground-tests.yml +++ b/.github/workflows/playground-tests.yml @@ -102,14 +102,14 @@ jobs: - name: Run tests with WordPress Playground run: | # Start WordPress Playground with our blueprint - npx @wp-playground/cli server --blueprint playground/multisite-blueprint.json --port 8889 --login & + npx @wp-playground/cli server --blueprint playground/multisite-blueprint.json --port 8888 --login & # Wait for WordPress Playground to be ready echo "Waiting for WordPress Playground to be ready..." - timeout 60 bash -c 'until curl -s http://localhost:8889; do sleep 2; done' + timeout 60 bash -c 'until curl -s http://localhost:8888; do sleep 2; done' # Run Cypress tests against WordPress Playground - npx cypress run --config specPattern=cypress/e2e/playground-multisite.cy.js,baseUrl=http://localhost:8889 + npx cypress run --config specPattern=cypress/e2e/playground-multisite.cy.js performance-test: name: WordPress Performance Tests diff --git a/cypress/e2e/playground-multisite.cy.js b/cypress/e2e/playground-multisite.cy.js index 2101030..de26433 100644 --- a/cypress/e2e/playground-multisite.cy.js +++ b/cypress/e2e/playground-multisite.cy.js @@ -11,13 +11,15 @@ describe('WordPress Playground Multisite Tests', () => { }); it('Can access the network admin area', () => { - // WordPress Playground should auto-login as admin - cy.get('#wpadminbar').should('exist'); + // Visit the network admin dashboard + cy.visit('/wp-admin/network/'); + + // Check if we're logged in to the network admin + cy.get('body').should('have.class', 'wp-admin'); }); it('Plugin is network activated', () => { // Navigate to network plugins page - cy.get('#wp-admin-bar-network-admin a').click(); cy.visit('/wp-admin/network/plugins.php'); // Check if the plugins are active diff --git a/cypress/e2e/playground-single-site.cy.js b/cypress/e2e/playground-single-site.cy.js index d466a8c..6770e7f 100644 --- a/cypress/e2e/playground-single-site.cy.js +++ b/cypress/e2e/playground-single-site.cy.js @@ -11,8 +11,11 @@ describe('WordPress Playground Single Site Tests', () => { }); it('Can access the admin area', () => { - // WordPress Playground should auto-login as admin - cy.get('#wpadminbar').should('exist'); + // Visit the admin dashboard + cy.visit('/wp-admin/'); + + // Check if we're logged in + cy.get('body').should('have.class', 'wp-admin'); }); it('Plugin is activated', () => {