From f48276cc5842bdd4fa0ffb649de7ea0ec1c0678b Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Tue, 22 Apr 2025 15:11:56 +0100 Subject: [PATCH] Fix code quality issues: add ESLint config to Cypress files, update documentation, improve HTML accessibility --- .wiki/Playground-Testing.md | 9 +++++---- .wiki/Testing.md | 7 ++++--- cypress/e2e/playground-multisite.cy.js | 13 +++++++------ cypress/e2e/playground-single-site.cy.js | 11 ++++++----- playground/index.html | 2 +- playground/multisite.html | 2 +- playground/test.html | 10 ++++++++-- 7 files changed, 32 insertions(+), 22 deletions(-) diff --git a/.wiki/Playground-Testing.md b/.wiki/Playground-Testing.md index 5ba828c..2e9bf85 100644 --- a/.wiki/Playground-Testing.md +++ b/.wiki/Playground-Testing.md @@ -15,9 +15,9 @@ This document explains how to use WordPress Playground for testing our plugin. The easiest way to test our plugin with WordPress Playground is to use the online version: -1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json&_t=11) +1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/blueprint.json&_t=1) -2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=23) +2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/multisite-blueprint.json&_t=1) These links will automatically set up WordPress with multisite enabled, WP_DEBUG enabled, and both the Plugin Toggle and Kadence Blocks plugins activated. @@ -111,8 +111,8 @@ We have two blueprints for testing: To run tests with WordPress Playground: 1. Open the appropriate WordPress Playground link: - * [Single site](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json&_t=11) - * [Multisite](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=23) + * [Single site](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/blueprint.json&_t=1) + * [Multisite](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/multisite-blueprint.json&_t=1) 2. Test the plugin manually in the browser @@ -122,6 +122,7 @@ We've also included HTML files that embed WordPress Playground: 1. Open `playground/index.html` in your browser for single site testing 2. Open `playground/multisite.html` in your browser for multisite testing +3. Open `playground/test.html` in your browser for a unified interface with buttons to switch between single site and multisite You can serve these files locally with a simple HTTP server: diff --git a/.wiki/Testing.md b/.wiki/Testing.md index bcb86d1..715046b 100644 --- a/.wiki/Testing.md +++ b/.wiki/Testing.md @@ -106,11 +106,11 @@ WordPress Playground runs WordPress entirely in the browser using WebAssembly. T The easiest way to test our plugin with WordPress Playground is to use the online version: -1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json&_t=9) +1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/blueprint.json&_t=1) -2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=23) +2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/multisite-blueprint.json&_t=1) -These links will automatically set up WordPress with multisite enabled, WP_DEBUG enabled, and both the Plugin Toggle and Hello Dolly plugins activated. +These links will automatically set up WordPress with multisite enabled, WP_DEBUG enabled, and both the Plugin Toggle and Kadence Blocks plugins activated. #### Local Testing with HTML Files @@ -118,6 +118,7 @@ We've also included HTML files that embed WordPress Playground: 1. Open `playground/index.html` in your browser for single site testing 2. Open `playground/multisite.html` in your browser for multisite testing +3. Open `playground/test.html` in your browser for a unified interface with buttons to switch between single site and multisite You can serve these files locally with a simple HTTP server: diff --git a/cypress/e2e/playground-multisite.cy.js b/cypress/e2e/playground-multisite.cy.js index b9b18bd..74cd307 100644 --- a/cypress/e2e/playground-multisite.cy.js +++ b/cypress/e2e/playground-multisite.cy.js @@ -1,8 +1,9 @@ +/* eslint-env mocha, jquery, cypress */ describe('WordPress Playground Multisite Tests', () => { beforeEach(() => { // Visit the WordPress Playground page cy.visit('/multisite.html'); - + // Wait for the iframe to load cy.get('iframe').should('be.visible'); }); @@ -29,13 +30,13 @@ describe('WordPress Playground Multisite Tests', () => { // Navigate to network plugins page const $document = $iframe.contents(); const $body = $document.find('body'); - + // Click on Network Admin in the admin bar cy.wrap($body).find('#wpadminbar #wp-admin-bar-network-admin a').click(); - + // Click on Plugins in the network admin menu cy.wrap($body).find('#menu-plugins a[href*="plugins.php"]').first().click(); - + // Check if the plugin is network active cy.wrap($body).find('tr[data-slug="wp-plugin-starter-template-for-ai-coding"]').should('exist'); cy.wrap($body).find('tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .network_active').should('exist'); @@ -46,11 +47,11 @@ describe('WordPress Playground Multisite Tests', () => { cy.get('iframe').then($iframe => { const $document = $iframe.contents(); const $body = $document.find('body'); - + // Navigate to the network settings page cy.wrap($body).find('#wpadminbar #wp-admin-bar-network-admin a').click(); cy.wrap($body).find('#menu-settings a[href*="settings.php"]').first().click(); - + // Check if the network settings page loaded correctly cy.wrap($body).find('h1').should('contain', 'Network Settings'); }); diff --git a/cypress/e2e/playground-single-site.cy.js b/cypress/e2e/playground-single-site.cy.js index 832f077..9f91815 100644 --- a/cypress/e2e/playground-single-site.cy.js +++ b/cypress/e2e/playground-single-site.cy.js @@ -1,8 +1,9 @@ +/* eslint-env mocha, jquery, cypress */ describe('WordPress Playground Single Site Tests', () => { beforeEach(() => { // Visit the WordPress Playground page cy.visit('/index.html'); - + // Wait for the iframe to load cy.get('iframe').should('be.visible'); }); @@ -29,10 +30,10 @@ describe('WordPress Playground Single Site Tests', () => { // Navigate to plugins page const $document = $iframe.contents(); const $body = $document.find('body'); - + // Click on Plugins in the admin menu cy.wrap($body).find('#menu-plugins a[href*="plugins.php"]').first().click(); - + // Check if the plugin is active cy.wrap($body).find('tr[data-slug="wp-plugin-starter-template-for-ai-coding"]').should('exist'); }); @@ -42,11 +43,11 @@ describe('WordPress Playground Single Site Tests', () => { cy.get('iframe').then($iframe => { const $document = $iframe.contents(); const $body = $document.find('body'); - + // Navigate to the plugin settings page cy.wrap($body).find('#menu-settings a[href*="options-general.php"]').first().click(); cy.wrap($body).find('a[href*="options-general.php?page=wp-plugin-starter-template"]').click(); - + // Check if the settings page loaded correctly cy.wrap($body).find('h1').should('contain', 'WP Plugin Starter Template'); }); diff --git a/playground/index.html b/playground/index.html index f4a3862..65f5545 100644 --- a/playground/index.html +++ b/playground/index.html @@ -21,6 +21,6 @@
- +