Fix code quality issues: update Cypress tests to use custom commands, fix workflow files, update documentation
This commit is contained in:
23
.github/workflows/playground-tests.yml
vendored
23
.github/workflows/playground-tests.yml
vendored
@@ -2,12 +2,12 @@ name: WordPress Playground Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, feature/*, bugfix/* ]
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
concurrency:
|
||||
group: playground-tests-${{ github.ref }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
@@ -36,10 +36,7 @@ jobs:
|
||||
npm ci --dry-run
|
||||
|
||||
- name: Lint JavaScript files
|
||||
run: |
|
||||
echo "Linting JavaScript files"
|
||||
# Add your linting command here when you have one
|
||||
# For example: npm run lint
|
||||
run: npm run lint:js
|
||||
|
||||
playground-single-test:
|
||||
name: WordPress Playground Single Site Tests
|
||||
@@ -62,10 +59,7 @@ jobs:
|
||||
run: npm install --save-dev @wp-playground/cli
|
||||
|
||||
- name: Create plugin zip
|
||||
run: |
|
||||
mkdir -p dist
|
||||
zip -r dist/plugin.zip . \
|
||||
-x "node_modules/**" "dist/**" ".git/**" ".github/**" ".wiki/**"
|
||||
uses: ./.github/actions/create-plugin-zip
|
||||
|
||||
- name: Run tests with WordPress Playground
|
||||
run: |
|
||||
@@ -112,10 +106,7 @@ jobs:
|
||||
run: npm install --save-dev @wp-playground/cli
|
||||
|
||||
- name: Create plugin zip
|
||||
run: |
|
||||
mkdir -p dist
|
||||
zip -r dist/plugin.zip . \
|
||||
-x "node_modules/**" "dist/**" ".git/**" ".github/**" ".wiki/**"
|
||||
uses: ./.github/actions/create-plugin-zip
|
||||
|
||||
- name: Run tests with WordPress Playground
|
||||
run: |
|
||||
@@ -123,7 +114,7 @@ jobs:
|
||||
export CYPRESS_BASE_URL=http://localhost:80
|
||||
|
||||
# Start WordPress Playground with our blueprint
|
||||
# Use port 80 for multisite as WordPress multisites don't support custom ports
|
||||
# Use port 80 for multisite to avoid port configuration issues with WP Playground CLI
|
||||
npx @wp-playground/cli server --blueprint playground/multisite-blueprint.json --port 80 --login &
|
||||
|
||||
# Wait for WordPress Playground to be ready
|
||||
@@ -159,4 +150,4 @@ jobs:
|
||||
/
|
||||
/wp-admin/
|
||||
php-version: '8.0'
|
||||
wp-version: 'latest'
|
||||
wp-version: '6.4'
|
||||
|
||||
5
.github/workflows/wordpress-tests.yml
vendored
5
.github/workflows/wordpress-tests.yml
vendored
@@ -32,10 +32,7 @@ jobs:
|
||||
npm ci --dry-run
|
||||
|
||||
- name: Lint JavaScript files
|
||||
run: |
|
||||
echo "Linting JavaScript files"
|
||||
# Add your linting command here when you have one
|
||||
# For example: npm run lint
|
||||
run: npm run lint:js
|
||||
|
||||
# Note about e2e tests
|
||||
- name: Note about e2e tests
|
||||
|
||||
@@ -10,7 +10,7 @@ WordPress Multisite allows you to run multiple WordPress sites from a single Wor
|
||||
|
||||
The plugin includes a dedicated directory for multisite-specific functionality:
|
||||
|
||||
```text
|
||||
```bash
|
||||
includes/
|
||||
└── Multisite/
|
||||
├── class-multisite.php # Base class for multisite functionality
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
/* eslint-env node */
|
||||
/* eslint-env node, mocha */
|
||||
|
||||
const { defineConfig } = require('cypress');
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:8888',
|
||||
setupNodeEvents() {
|
||||
setupNodeEvents(on, config) {
|
||||
// This function can be used to register custom Cypress plugins or event listeners.
|
||||
// Currently not in use, but left for future extensibility.
|
||||
return config;
|
||||
},
|
||||
// Add configuration for WordPress Playground
|
||||
experimentalWebKitSupport: true,
|
||||
|
||||
@@ -11,36 +11,37 @@ describe('WordPress Playground Multisite Tests', () => {
|
||||
});
|
||||
|
||||
it('Can access the network admin area', () => {
|
||||
// Use the custom login command
|
||||
cy.loginAsAdmin();
|
||||
|
||||
// Visit the network admin dashboard
|
||||
cy.visit('/wp-admin/network/');
|
||||
|
||||
// Fill in the login form if needed
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.hasClass('login')) {
|
||||
cy.get('#user_login').type('admin');
|
||||
cy.get('#user_pass').type('password');
|
||||
cy.get('#wp-submit').click();
|
||||
}
|
||||
});
|
||||
|
||||
// Check if we're logged in to the network admin
|
||||
cy.get('#wpadminbar').should('exist');
|
||||
});
|
||||
|
||||
it('Plugin is network activated', () => {
|
||||
// Use the custom login command
|
||||
cy.loginAsAdmin();
|
||||
|
||||
// Navigate to network plugins page
|
||||
cy.visit('/wp-admin/network/plugins.php');
|
||||
|
||||
// Check if the plugins are active
|
||||
cy.contains('Plugin Toggle').should('exist');
|
||||
cy.contains('Kadence Blocks').should('exist');
|
||||
// Check if the plugins are network active
|
||||
cy.contains('tr', 'Plugin Toggle').find('.network_active').should('exist');
|
||||
cy.contains('tr', 'Kadence Blocks').find('.network_active').should('exist');
|
||||
});
|
||||
|
||||
it('Network settings page loads correctly', () => {
|
||||
// Use the custom login command
|
||||
cy.loginAsAdmin();
|
||||
|
||||
// Navigate to the network settings page
|
||||
cy.visit('/wp-admin/network/settings.php');
|
||||
|
||||
// Check if the network settings page loaded correctly
|
||||
cy.get('#wpbody-content').should('exist');
|
||||
cy.get('h1').should('contain', 'Network Settings');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,36 +11,34 @@ describe('WordPress Playground Single Site Tests', () => {
|
||||
});
|
||||
|
||||
it('Can access the admin area', () => {
|
||||
// Visit the admin dashboard
|
||||
cy.visit('/wp-admin/');
|
||||
|
||||
// Fill in the login form if needed
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.hasClass('login')) {
|
||||
cy.get('#user_login').type('admin');
|
||||
cy.get('#user_pass').type('password');
|
||||
cy.get('#wp-submit').click();
|
||||
}
|
||||
});
|
||||
// Use the custom login command
|
||||
cy.loginAsAdmin();
|
||||
|
||||
// Check if we're logged in
|
||||
cy.get('#wpadminbar').should('exist');
|
||||
});
|
||||
|
||||
it('Plugin is activated', () => {
|
||||
// Use the custom login command
|
||||
cy.loginAsAdmin();
|
||||
|
||||
// Navigate to plugins page
|
||||
cy.visit('/wp-admin/plugins.php');
|
||||
|
||||
// Check if the plugin is active
|
||||
cy.contains('Plugin Toggle').should('exist');
|
||||
cy.contains('Kadence Blocks').should('exist');
|
||||
cy.contains('tr', 'Plugin Toggle').find('.deactivate').should('exist');
|
||||
cy.contains('tr', 'Kadence Blocks').find('.deactivate').should('exist');
|
||||
});
|
||||
|
||||
it('Plugin settings page loads correctly', () => {
|
||||
// Use the custom login command
|
||||
cy.loginAsAdmin();
|
||||
|
||||
// Navigate to the plugin settings page
|
||||
cy.visit('/wp-admin/options-general.php');
|
||||
|
||||
// Check if the settings page exists
|
||||
cy.get('#wpbody-content').should('exist');
|
||||
cy.get('h1').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user