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