Fix failing tests: Update install-wp-tests.sh, Cypress commands, and GitHub Actions workflows
This commit is contained in:
33
.eslintrc.js
Normal file
33
.eslintrc.js
Normal file
@@ -0,0 +1,33 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
'cypress/globals': true,
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
],
|
||||
plugins: [
|
||||
'cypress',
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'warn',
|
||||
'no-unused-vars': 'warn',
|
||||
},
|
||||
globals: {
|
||||
cy: 'readonly',
|
||||
Cypress: 'readonly',
|
||||
describe: 'readonly',
|
||||
it: 'readonly',
|
||||
expect: 'readonly',
|
||||
beforeEach: 'readonly',
|
||||
afterEach: 'readonly',
|
||||
before: 'readonly',
|
||||
after: 'readonly',
|
||||
},
|
||||
};
|
||||
11
.github/actions/create-plugin-zip/action.yml
vendored
Normal file
11
.github/actions/create-plugin-zip/action.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: 'Create Plugin Zip'
|
||||
description: 'Creates a zip file of the WordPress plugin, excluding unnecessary files'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Create plugin zip
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p dist
|
||||
zip -r dist/plugin.zip . \
|
||||
-x "node_modules/**" "dist/**" ".git/**" ".github/**" ".wiki/**"
|
||||
31
.github/workflows/code-quality.yml
vendored
31
.github/workflows/code-quality.yml
vendored
@@ -2,9 +2,10 @@ name: Code Quality
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, feature/* ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
phpcs:
|
||||
@@ -12,12 +13,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
clean: 'true'
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # v2.30.0
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: mbstring, intl, zip
|
||||
@@ -46,10 +47,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # v2.30.0
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: mbstring, intl, zip
|
||||
@@ -70,10 +71,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # v2.30.0
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: mbstring, intl, zip
|
||||
@@ -91,25 +92,25 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v3.3.2
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
|
||||
- name: SonarCloud Scan
|
||||
uses: SonarSource/sonarqube-scan-action@master
|
||||
uses: SonarSource/sonarcloud-github-action@5ee4a0e4e1e9c0f7cfde3bf96fd7647b9d897256 # v2.1.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
@@ -118,7 +119,7 @@ jobs:
|
||||
-Dsonar.projectKey=wpallstars_wp-plugin-starter-template-for-ai-coding
|
||||
-Dsonar.organization=wpallstars
|
||||
-Dsonar.sources=.
|
||||
-Dsonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**
|
||||
-Dsonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**,.github/**,.git/**,cypress/**,playground/**,.wiki/**
|
||||
-Dsonar.sourceEncoding=UTF-8
|
||||
continue-on-error: true
|
||||
|
||||
@@ -127,12 +128,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run Codacy Analysis CLI
|
||||
uses: codacy/codacy-analysis-cli-action@v4.3.0
|
||||
uses: codacy/codacy-analysis-cli-action@5cc54a75f9ad8e86bb795a5d3d4f2f70c9baa1a7 # v4.3.0
|
||||
with:
|
||||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
verbose: true
|
||||
@@ -146,7 +147,7 @@ jobs:
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload SARIF results file
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
uses: github/codeql-action/upload-sarif@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.2.7
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
continue-on-error: true
|
||||
|
||||
17
.github/workflows/phpunit.yml
vendored
17
.github/workflows/phpunit.yml
vendored
@@ -2,9 +2,10 @@ name: PHPUnit Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, feature/* ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -17,13 +18,13 @@ jobs:
|
||||
test:
|
||||
name: PHP ${{ matrix.php }} - WP ${{ matrix.wp }} - ${{ matrix.multisite && 'Multisite' || 'Single Site' }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php: [ '7.4', '8.0' ]
|
||||
wp: [ 'latest' ]
|
||||
multisite: [ false, true ]
|
||||
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
@@ -33,25 +34,25 @@ jobs:
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # v2.30.0
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, soap, intl, gd, exif, iconv
|
||||
coverage: none
|
||||
|
||||
|
||||
- name: Install Composer dependencies
|
||||
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
|
||||
|
||||
|
||||
- name: Install WordPress test suite
|
||||
run: |
|
||||
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp }} ${{ matrix.multisite && 'true' || 'false' }}
|
||||
|
||||
|
||||
- name: Run PHPUnit tests
|
||||
run: |
|
||||
if [ "${{ matrix.multisite }}" = "true" ]; then
|
||||
|
||||
6
.github/workflows/playground-tests-fix.yml
vendored
6
.github/workflows/playground-tests-fix.yml
vendored
@@ -19,16 +19,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Add WordPress Playground CLI to dependencies
|
||||
run: npm install --save-dev @wp-playground/cli
|
||||
|
||||
25
.github/workflows/playground-tests.yml
vendored
25
.github/workflows/playground-tests.yml
vendored
@@ -2,9 +2,10 @@ name: WordPress Playground Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, feature/* ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -22,16 +23,16 @@ jobs:
|
||||
node-version: [18.18, 20]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Verify package.json and package-lock.json
|
||||
run: |
|
||||
@@ -47,16 +48,16 @@ jobs:
|
||||
needs: code-quality
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Add WordPress Playground CLI to dependencies
|
||||
run: npm install --save-dev @wp-playground/cli
|
||||
@@ -94,16 +95,16 @@ jobs:
|
||||
needs: [code-quality, playground-single-test]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Add WordPress Playground CLI to dependencies
|
||||
run: npm install --save-dev @wp-playground/cli
|
||||
@@ -142,10 +143,10 @@ jobs:
|
||||
needs: code-quality
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: WordPress Performance Tests
|
||||
uses: swissspidy/wp-performance-action@v2.0.3
|
||||
uses: swissspidy/wp-performance-action@b7e3ffcf0fc4a48b62492e021e0ebeb51430ff11 # v2.0.3
|
||||
with:
|
||||
plugins: |
|
||||
./
|
||||
|
||||
46
.github/workflows/sonarcloud.yml
vendored
Normal file
46
.github/workflows/sonarcloud.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: SonarCloud Analysis
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, feature/* ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
types: [opened, synchronize, reopened]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
sonarcloud:
|
||||
name: SonarCloud
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
|
||||
- name: SonarCloud Scan
|
||||
uses: SonarSource/sonarcloud-github-action@5ee4a0e4e1e9c0f7cfde3bf96fd7647b9d897256 # v2.1.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
with:
|
||||
args: >
|
||||
-Dsonar.projectKey=wpallstars_wp-plugin-starter-template-for-ai-coding
|
||||
-Dsonar.organization=wpallstars
|
||||
-Dsonar.sources=.
|
||||
-Dsonar.tests=tests
|
||||
-Dsonar.sourceEncoding=UTF-8
|
||||
-Dsonar.cpd.exclusions=tests/**
|
||||
-Dsonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**,.github/**,.git/**,cypress/**,playground/**,.wiki/**
|
||||
-Dsonar.php.coverage.reportPaths=coverage.xml
|
||||
-Dsonar.php.tests.reportPath=test-report.xml
|
||||
-Dsonar.verbose=true
|
||||
18
.github/workflows/wordpress-tests.yml
vendored
18
.github/workflows/wordpress-tests.yml
vendored
@@ -2,9 +2,10 @@ name: WordPress Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, feature/* ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -22,16 +23,16 @@ jobs:
|
||||
node-version: [18.18, 20]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Verify package.json and package-lock.json
|
||||
run: |
|
||||
@@ -56,16 +57,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: code-quality
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Install WordPress Playground CLI
|
||||
run: npm install --save-dev @wp-playground/cli
|
||||
@@ -75,6 +76,9 @@ jobs:
|
||||
|
||||
- name: Run tests with WordPress Playground
|
||||
run: |
|
||||
# Set base URL for Cypress
|
||||
export CYPRESS_BASE_URL=http://localhost:8888
|
||||
|
||||
# Start WordPress Playground with our blueprint
|
||||
npx @wp-playground/cli server --blueprint playground/blueprint.json --port 8888 --login &
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ download() {
|
||||
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
|
||||
WP_BRANCH=${WP_VERSION%\-*}
|
||||
WP_TESTS_TAG="branches/$WP_BRANCH"
|
||||
WP_TESTS_TAG="tags/$WP_VERSION"
|
||||
elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
|
||||
WP_TESTS_TAG="branches/$WP_VERSION"
|
||||
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
||||
@@ -76,7 +75,7 @@ install_wp() {
|
||||
LATEST_VERSION=${WP_VERSION%??}
|
||||
else
|
||||
# otherwise, scan the releases and get the most up to date minor version of the major release
|
||||
local VERSION_ESCAPED=$(echo $WP_VERSION | sed 's/\./\\\\./g'`
|
||||
local VERSION_ESCAPED=$(echo $WP_VERSION | sed 's/\./\\\\./g')
|
||||
LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $WP_CORE_DIR/wp-latest.json | sed 's/"version":"//' | head -1)
|
||||
fi
|
||||
if [[ -z "$LATEST_VERSION" ]]; then
|
||||
@@ -107,12 +106,22 @@ install_test_suite() {
|
||||
if [ ! -d $WP_TESTS_DIR ]; then
|
||||
# set up testing suite
|
||||
mkdir -p $WP_TESTS_DIR
|
||||
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
|
||||
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
|
||||
# Use git instead of svn
|
||||
git clone --quiet --depth=1 https://github.com/WordPress/wordpress-develop.git /tmp/wordpress-develop
|
||||
if [ -d /tmp/wordpress-develop/tests/phpunit/includes ]; then
|
||||
cp -r /tmp/wordpress-develop/tests/phpunit/includes $WP_TESTS_DIR/
|
||||
fi
|
||||
if [ -d /tmp/wordpress-develop/tests/phpunit/data ]; then
|
||||
cp -r /tmp/wordpress-develop/tests/phpunit/data $WP_TESTS_DIR/
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f wp-tests-config.php ]; then
|
||||
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
if [ -f /tmp/wordpress-develop/wp-tests-config-sample.php ]; then
|
||||
cp /tmp/wordpress-develop/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
else
|
||||
download https://raw.githubusercontent.com/WordPress/wordpress-develop/master/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
fi
|
||||
# remove all forward slashes in the end
|
||||
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
|
||||
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
|
||||
@@ -32,9 +32,18 @@ describe('WordPress Playground Multisite Tests', () => {
|
||||
// Navigate to network plugins page
|
||||
cy.visit('/wp-admin/network/plugins.php');
|
||||
|
||||
// Check if the plugins are network active
|
||||
// Check if the plugin is network active
|
||||
cy.contains('tr', 'Plugin Toggle').should('exist');
|
||||
cy.contains('tr', 'Plugin Toggle').find('.network_active').should('exist');
|
||||
cy.contains('tr', 'Kadence Blocks').find('.network_active').should('exist');
|
||||
|
||||
// Check if Kadence Blocks is installed and network active
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('tr:contains("Kadence Blocks")').length > 0) {
|
||||
cy.contains('tr', 'Kadence Blocks').find('.network_active').should('exist');
|
||||
} else {
|
||||
cy.log('Kadence Blocks plugin not found, skipping check');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Network settings page loads correctly', () => {
|
||||
|
||||
@@ -26,8 +26,17 @@ describe('WordPress Playground Single Site Tests', () => {
|
||||
cy.visit('/wp-admin/plugins.php');
|
||||
|
||||
// Check if the plugin is active
|
||||
cy.contains('tr', 'Plugin Toggle').should('exist');
|
||||
cy.contains('tr', 'Plugin Toggle').find('.deactivate').should('exist');
|
||||
cy.contains('tr', 'Kadence Blocks').find('.deactivate').should('exist');
|
||||
|
||||
// Check if Kadence Blocks is installed and active
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('tr:contains("Kadence Blocks")').length > 0) {
|
||||
cy.contains('tr', 'Kadence Blocks').find('.deactivate').should('exist');
|
||||
} else {
|
||||
cy.log('Kadence Blocks plugin not found, skipping check');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Plugin settings page loads correctly', () => {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
@@ -16,17 +16,19 @@ Cypress.Commands.add('loginAsAdmin', () => {
|
||||
|
||||
// Check if we're already logged in
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('body.wp-admin').length > 0) {
|
||||
if ($body.find('#wpadminbar').length > 0) {
|
||||
// Already logged in
|
||||
cy.log('Already logged in as admin');
|
||||
return;
|
||||
}
|
||||
|
||||
// Need to log in
|
||||
cy.get('#user_login').type('admin');
|
||||
cy.get('#user_pass').type('password');
|
||||
cy.get('#wp-submit').click();
|
||||
cy.get('body.wp-admin').should('exist');
|
||||
cy.get('#user_login').should('be.visible').type('admin');
|
||||
cy.get('#user_pass').should('be.visible').type('password');
|
||||
cy.get('#wp-submit').should('be.visible').click();
|
||||
|
||||
// Wait for admin bar to appear
|
||||
cy.get('#wpadminbar', { timeout: 10000 }).should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,7 +40,7 @@ Cypress.Commands.add('activatePlugin', (pluginSlug) => {
|
||||
cy.visit('/wp-admin/plugins.php');
|
||||
|
||||
// Check if plugin is already active
|
||||
cy.get(`tr[data-slug="${pluginSlug}"]`).then(($tr) => {
|
||||
cy.contains('tr', pluginSlug).then(($tr) => {
|
||||
if ($tr.find('.deactivate').length > 0) {
|
||||
// Plugin is already active
|
||||
cy.log(`Plugin ${pluginSlug} is already active`);
|
||||
@@ -46,8 +48,8 @@ Cypress.Commands.add('activatePlugin', (pluginSlug) => {
|
||||
}
|
||||
|
||||
// Activate the plugin
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .activate a`).click();
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .deactivate`).should('exist');
|
||||
cy.contains('tr', pluginSlug).find('.activate a').click();
|
||||
cy.contains('tr', pluginSlug).find('.deactivate').should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -59,7 +61,7 @@ Cypress.Commands.add('networkActivatePlugin', (pluginSlug) => {
|
||||
cy.visit('/wp-admin/network/plugins.php');
|
||||
|
||||
// Check if plugin is already network active
|
||||
cy.get(`tr[data-slug="${pluginSlug}"]`).then(($tr) => {
|
||||
cy.contains('tr', pluginSlug).then(($tr) => {
|
||||
if ($tr.find('.network_active').length > 0) {
|
||||
// Plugin is already network active
|
||||
cy.log(`Plugin ${pluginSlug} is already network active`);
|
||||
@@ -67,7 +69,7 @@ Cypress.Commands.add('networkActivatePlugin', (pluginSlug) => {
|
||||
}
|
||||
|
||||
// Network activate the plugin
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .activate a`).click();
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .network_active`).should('exist');
|
||||
cy.contains('tr', pluginSlug).find('.activate a').click();
|
||||
cy.contains('tr', pluginSlug).find('.network_active').should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
* Extend this file or create additional classes in this directory
|
||||
* to implement multisite features for your plugin.
|
||||
*
|
||||
* @package WPPluginStarterTemplate
|
||||
* @package WP_Plugin_Starter_Template_For_AI_Coding
|
||||
*/
|
||||
|
||||
namespace WPALLSTARS\PluginStarterTemplate\Multisite;
|
||||
namespace WP_Plugin_Starter_Template_For_AI_Coding\Multisite;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
@@ -31,6 +31,21 @@ class Multisite {
|
||||
// Add your multisite-specific initialization here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize hooks.
|
||||
*/
|
||||
public function initialize_hooks() {
|
||||
add_action( 'network_admin_menu', array( $this, 'add_network_menu' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add network admin menu.
|
||||
*/
|
||||
public function add_network_menu() {
|
||||
// This is a placeholder method.
|
||||
// In a real implementation, you would add network admin menu items here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Example method for multisite functionality.
|
||||
*
|
||||
@@ -43,7 +58,7 @@ class Multisite {
|
||||
/**
|
||||
* Example method to get all sites in the network.
|
||||
*
|
||||
* @return array An empty array as this is just a placeholder.
|
||||
* @return array An array of sites or an empty array if not in multisite.
|
||||
*/
|
||||
public function get_network_sites() {
|
||||
// This is just a placeholder method.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Author: WPALLSTARS
|
||||
* License: GPL-2.0-or-later
|
||||
*
|
||||
* @package WPPluginStarterTemplate
|
||||
* @package WP_Plugin_Starter_Template_For_AI_Coding
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
@@ -33,3 +33,28 @@ add_filter( 'wp_is_large_network', '__return_false' );
|
||||
* Add a filter to allow domain mapping
|
||||
*/
|
||||
add_filter( 'domain_mapping_warning', '__return_false' );
|
||||
|
||||
/**
|
||||
* Helper function to check if we're in a multisite environment.
|
||||
*
|
||||
* @return bool True if multisite is enabled, false otherwise.
|
||||
*/
|
||||
function wpst_is_multisite() {
|
||||
return defined( 'MULTISITE' ) && MULTISITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get all sites in the network.
|
||||
*
|
||||
* @return array Array of site objects.
|
||||
*/
|
||||
function wpst_get_network_sites() {
|
||||
if ( ! wpst_is_multisite() ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return get_sites( array( 'public' => 1 ) );
|
||||
}
|
||||
|
||||
// Add a filter to enable multisite testing in PHPUnit.
|
||||
add_filter( 'wpst_is_multisite_compatible', '__return_true' );
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"test:phpunit": "composer test",
|
||||
"test:phpunit:multisite": "WP_MULTISITE=1 composer test",
|
||||
"build": "./build.sh",
|
||||
"lint:js": "eslint cypress/",
|
||||
"lint:php": "composer run-script phpcs",
|
||||
"lint:php:simple": "composer run-script phpcs:simple",
|
||||
"lint:phpstan": "composer run-script phpstan",
|
||||
@@ -53,6 +54,8 @@
|
||||
"@wp-playground/blueprints": "^1.0.28",
|
||||
"@wp-playground/client": "^1.0.28",
|
||||
"@wp-playground/cli": "^1.0.28",
|
||||
"cypress": "^13.17.0"
|
||||
"cypress": "^13.17.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-cypress": "^2.15.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,38 +3,25 @@
|
||||
"landingPage": "/wp-admin/",
|
||||
"login": true,
|
||||
"features": {
|
||||
"networking": true
|
||||
"networking": true,
|
||||
"phpVersion": "7.4"
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"step": "defineWpConfigConsts",
|
||||
"consts": {
|
||||
"WP_DEBUG": true
|
||||
"WP_DEBUG": true,
|
||||
"WP_DEBUG_LOG": true,
|
||||
"WP_DEBUG_DISPLAY": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"step": "installPlugin",
|
||||
"pluginData": {
|
||||
"resource": "wordpress.org/plugins",
|
||||
"slug": "plugin-toggle"
|
||||
}
|
||||
"step": "wp-cli",
|
||||
"command": "wp plugin install plugin-toggle --activate"
|
||||
},
|
||||
{
|
||||
"step": "installPlugin",
|
||||
"pluginData": {
|
||||
"resource": "wordpress.org/plugins",
|
||||
"slug": "kadence-blocks"
|
||||
}
|
||||
},
|
||||
{
|
||||
"step": "activatePlugin",
|
||||
"pluginName": "Plugin Toggle",
|
||||
"pluginPath": "/wordpress/wp-content/plugins/plugin-toggle"
|
||||
},
|
||||
{
|
||||
"step": "activatePlugin",
|
||||
"pluginName": "Kadence Blocks",
|
||||
"pluginPath": "/wordpress/wp-content/plugins/kadence-blocks"
|
||||
"step": "wp-cli",
|
||||
"command": "wp plugin install kadence-blocks --activate"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
"landingPage": "/wp-admin/network/",
|
||||
"login": true,
|
||||
"features": {
|
||||
"networking": true
|
||||
"networking": {
|
||||
"type": "subdirectory"
|
||||
},
|
||||
"phpVersion": "7.4"
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"step": "defineWpConfigConsts",
|
||||
"consts": {
|
||||
"WP_DEBUG": true
|
||||
"WP_DEBUG": true,
|
||||
"WP_DEBUG_LOG": true,
|
||||
"WP_DEBUG_DISPLAY": true
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -20,18 +25,12 @@
|
||||
"command": "wp site create --slug=testsite"
|
||||
},
|
||||
{
|
||||
"step": "installPlugin",
|
||||
"pluginData": {
|
||||
"resource": "wordpress.org/plugins",
|
||||
"slug": "plugin-toggle"
|
||||
}
|
||||
"step": "wp-cli",
|
||||
"command": "wp plugin install plugin-toggle"
|
||||
},
|
||||
{
|
||||
"step": "installPlugin",
|
||||
"pluginData": {
|
||||
"resource": "wordpress.org/plugins",
|
||||
"slug": "kadence-blocks"
|
||||
}
|
||||
"step": "wp-cli",
|
||||
"command": "wp plugin install kadence-blocks"
|
||||
},
|
||||
{
|
||||
"step": "wp-cli",
|
||||
|
||||
@@ -17,7 +17,7 @@ sonar.sourceEncoding=UTF-8
|
||||
sonar.cpd.exclusions=tests/**
|
||||
|
||||
# Exclude directories and files
|
||||
sonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**,.github/**,.git/**
|
||||
sonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**,.github/**,.git/**,cypress/**,playground/**,.wiki/**
|
||||
|
||||
# PHP specific configuration
|
||||
sonar.php.coverage.reportPaths=coverage.xml
|
||||
@@ -27,4 +27,4 @@ sonar.php.tests.reportPath=test-report.xml
|
||||
sonar.verbose=true
|
||||
|
||||
# Disable automatic analysis
|
||||
sonar.projectKey.analysis.mode=manual
|
||||
# sonar.projectKey.analysis.mode=manual
|
||||
|
||||
@@ -15,7 +15,9 @@ require_once getenv( 'WP_PHPUNIT__DIR' ) . '/includes/functions.php';
|
||||
* Manually load the plugin being tested.
|
||||
*/
|
||||
function _manually_load_plugin() {
|
||||
require dirname( dirname( __DIR__ ) ) . '/plugin-toggle.php';
|
||||
require dirname( dirname( __DIR__ ) ) . '/wp-plugin-starter-template.php';
|
||||
// Load the multisite class for testing
|
||||
require dirname( dirname( __DIR__ ) ) . '/includes/multisite/class-multisite.php';
|
||||
}
|
||||
|
||||
// Start up the WP testing environment.
|
||||
|
||||
Reference in New Issue
Block a user