Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@ jobs:
matrix:
include:
# Latest:
- wp: '7.0'
- wp: '7.1'
php: '8.5'
- wp: '7.0'
- wp: '7.1'
php: '7.4'
# Latest -1:
- wp: '6.9'
- wp: '7.0'
php: '8.5'
- wp: '6.9'
- wp: '7.0'
php: '7.4'
# Latest -2:
- wp: '6.8'
- wp: '6.9'
php: '8.4'
- wp: '6.8'
- wp: '6.9'
php: '7.4'
# Oldest supported:
- wp: '6.2'
- wp: '6.3'
php: '8.2'
- wp: '6.2'
- wp: '6.3'
php: '7.4'
fail-fast: false
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
with:
wp: ${{ matrix.wp }}
php: ${{ matrix.php }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
name: ${{ matrix.label }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-coding-standards.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-coding-standards.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
strategy:
matrix:
label:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: WordPress.org
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-assets.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-assets.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
with:
plugin: user-switching
readme: readme.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
deploy:
name: Deploy Tag
if: github.event_name == 'workflow_dispatch' || github.event.release.prerelease == false
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-tag.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-tag.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
permissions:
contents: write # Required to push the new branch
issues: write # Required for write access to milestones.
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ jobs:
name: WP ${{ matrix.wp }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
strategy:
# See the following for PHP compatibility of WordPress versions:
# https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/
matrix:
include:
# Latest:
- wp: '7.0'
- wp: '7.1'
php: '8.5'
- wp: '7.0'
- wp: '7.1'
php: '7.4'
# Latest -1:
- wp: '6.9'
- wp: '7.0'
php: '8.5'
- wp: '6.9'
- wp: '7.0'
php: '7.4'
# Latest -2:
- wp: '6.8'
- wp: '6.9'
php: '8.4'
- wp: '6.8'
- wp: '6.9'
php: '7.4'
# Oldest supported:
- wp: '6.2'
- wp: '6.3'
php: '8.2'
- wp: '6.2'
- wp: '6.3'
php: '7.4'
fail-fast: false
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
security-events: write # Required for upload-sarif to upload SARIF files.
contents: read # Needed to clone the repo.
actions: read # Needed for upload-sarif to read workflow run info.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-workflow-lint.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-workflow-lint.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
4 changes: 2 additions & 2 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- '8.5'
- '7.4'
fail-fast: false
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
with:
wp: 'nightly'
php: ${{ matrix.php }}
Expand All @@ -52,7 +52,7 @@ jobs:
name: Nightly ${{ matrix.label }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
strategy:
matrix:
label:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: ${{ matrix.label }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-static-analysis.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-static-analysis.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
strategy:
matrix:
label:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
name: Verify Plugin Distribution
permissions:
contents: read # Needed to fetch the latest release via the GitHub API.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-verify-distribution.yml@99fbf371962704dbaef452ebe7ea188d5cfb8069 # 2.9.4
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-verify-distribution.yml@d9a465cfe7c3e582d8712658ff653cc9e259f1ba # 2.9.6
with:
plugin: user-switching
owner: johnbillion
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
"composer/installers": "^1.0 || ^2.0"
},
"require-dev": {
"johnbillion/plugin-infrastructure": "2.9.4",
"johnbillion/wp-compat": "1.5.0",
"php-stubs/wordpress-stubs": "7.0.0 as 6.9.4",
"johnbillion/plugin-infrastructure": "2.9.6",
"johnbillion/wp-compat": "2.0.1",
"php-stubs/wordpress-stubs": "7.1.0",
"phpcompatibility/phpcompatibility-wp": "2.1.8",
"phpstan/phpstan": "2.1.33",
"phpstan/phpstan-phpunit": "2.0.11",
"swissspidy/phpstan-no-private": "1.0.0",
"szepeviktor/phpstan-wordpress": "2.0.3",
"szepeviktor/phpstan-wordpress": "2.0.4",
"wp-coding-standards/wpcs": "3.4.1"
},
"autoload-dev": {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"type": "module",
"devDependencies": {
"@johnbillion/plugin-infrastructure": "2.9.4",
"@johnbillion/plugin-infrastructure": "2.9.6",
"@jsdevtools/version-bump-prompt": "^6.1.0",
"@playwright/test": "^1.55.0",
"@types/node": "^24.3.0",
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<arg name="cache" value="tests/cache/phpcs.json"/>
<arg name="extensions" value="php"/>

<config name="minimum_wp_version" value="6.2"/>
<config name="minimum_wp_version" value="6.3"/>
<config name="testVersion" value="7.4-"/>

<exclude-pattern>/.wordpress-org/*</exclude-pattern>
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# User Switching

Stable tag: 1.12.1
Tested up to: 7.0
Tested up to: 7.1
License: GPL v2 or later
Tags: users, user switching, fast user switching, multisite, woocommerce
Contributors: johnbillion
Expand Down
19 changes: 11 additions & 8 deletions tests/acceptance/CommandPalette.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ interface Admin {
visitAdminPage( path?: string, queryString?: string ): Promise<void>;
}

interface Screen {
name: string;
minVersion?: number;
gotoAndOpen( userSwitching: UserSwitchingUtils, admin: Admin, currentUser: string ): Promise<void>;
}

/**
* The command palette was introduced in the block editor in WordPress 6.3 and
* made available admin-wide (via the admin bar) in WordPress 6.9. Each screen
* runs the same set of command palette tests, guarded by its minimum version.
* The command palette was made available admin-wide (via the admin bar) in WordPress 6.9.
*/
const screens = [
const screens: Screen[] = [
{
name: 'in the block editor',
minVersion: 6.3,
async gotoAndOpen( userSwitching: UserSwitchingUtils, admin: Admin, currentUser: string ) {
await userSwitching.prepareBlockEditor( userSwitching.getUserIdByUsername( currentUser ) );
await admin.visitAdminPage( 'post-new.php' );
Expand Down Expand Up @@ -50,7 +53,7 @@ test.describe( 'Command Palette', () => {
userSwitching,
globalUtils,
}, testInfo ) => {
testInfo.skip( ! globalUtils.isWordPressVersionAtLeast( screen.minVersion ), `This test requires WordPress ${screen.minVersion} or later` );
testInfo.skip( screen.minVersion !== undefined && ! globalUtils.isWordPressVersionAtLeast( screen.minVersion ), `This test requires WordPress ${screen.minVersion} or later` );

// Login as admin
await userSwitching.loginViaPage( 'admin', 'password' );
Expand All @@ -77,7 +80,7 @@ test.describe( 'Command Palette', () => {
userSwitching,
globalUtils,
}, testInfo ) => {
testInfo.skip( ! globalUtils.isWordPressVersionAtLeast( screen.minVersion ), `This test requires WordPress ${screen.minVersion} or later` );
testInfo.skip( screen.minVersion !== undefined && ! globalUtils.isWordPressVersionAtLeast( screen.minVersion ), `This test requires WordPress ${screen.minVersion} or later` );

// Login as admin
await userSwitching.loginViaPage( 'admin', 'password' );
Expand All @@ -101,7 +104,7 @@ test.describe( 'Command Palette', () => {
userSwitching,
globalUtils,
}, testInfo ) => {
testInfo.skip( ! globalUtils.isWordPressVersionAtLeast( screen.minVersion ), `This test requires WordPress ${screen.minVersion} or later` );
testInfo.skip( screen.minVersion !== undefined && ! globalUtils.isWordPressVersionAtLeast( screen.minVersion ), `This test requires WordPress ${screen.minVersion} or later` );

// Login as admin
await userSwitching.loginViaPage( 'admin', 'password' );
Expand Down
5 changes: 2 additions & 3 deletions tests/acceptance/ExpiredNonce.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ test.describe( 'Expired Nonce', () => {
// Click the switch back link - before the fix this showed "The link you followed has expired"
await switchBackLink.click();

// Verify successfully switched back to admin
expect( page.url() ).toContain( 'user_switched=true' );
expect( page.url() ).toContain( 'switched_back=true' );
// Verify successfully switched back to admin.
await userSwitching.seeAdminSuccessNotice( 'Switched back to admin.' );
await expect( page.locator( '#wpadminbar .display-name' ).first() ).toContainText( 'admin' );
} );
} );
6 changes: 1 addition & 5 deletions tests/acceptance/SwitchFromEnglish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ test.describe( 'Switch From English', () => {
page,
admin,
userSwitching,
globalUtils,
}, testInfo ) => {
// Check WordPress version - this test requires 6.2+
testInfo.skip( ! globalUtils.isWordPressVersionAtLeast( 6.2 ), 'This test requires WordPress 6.2 or later' );

} ) => {
// Create Italian author user
userSwitching.createUser( 'autore', 'author', {
name: 'Autore',
Expand Down
6 changes: 1 addition & 5 deletions tests/acceptance/SwitchToEnglish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ test.describe( 'Switch To English', () => {
page,
admin,
userSwitching,
globalUtils,
}, testInfo ) => {
// Check WordPress version - this test requires 6.2+
testInfo.skip( ! globalUtils.isWordPressVersionAtLeast( 6.2 ), 'This test requires WordPress 6.2 or later' );

} ) => {
// Create Italian admin user
await userSwitching.createUser( 'admin_it', 'administrator', {
name: 'Admin IT',
Expand Down
15 changes: 13 additions & 2 deletions tests/acceptance/utils/user-switching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export class UserSwitchingUtils {
* Open the command palette from the block editor (WP 6.3+).
*/
async openCommandPaletteFromEditor() {
// The document bar in the editor header was introduced in WordPress 6.4. Before
// that the palette can only be opened with the keyboard shortcut.
if ( ! this.globalUtils.isWordPressVersionAtLeast( 6.4 ) ) {
await this.openCommandPaletteWithKeyboard();
return;
}

await this.page.locator( '.editor-document-bar__command' ).click();
await expect( this.page.locator( '[cmdk-input]' ) ).toBeVisible();
}
Expand All @@ -86,8 +93,12 @@ export class UserSwitchingUtils {
* Open the command palette via its keyboard shortcut.
*/
async openCommandPaletteWithKeyboard() {
await this.page.keyboard.press( 'ControlOrMeta+k' );
await expect( this.page.locator( '[cmdk-input]' ) ).toBeVisible();
// The shortcut is registered by a script which loads asynchronously, so pressing
// it too early does nothing. Keep pressing until the palette appears.
await expect( async () => {
await this.page.keyboard.press( 'ControlOrMeta+k' );
await expect( this.page.locator( '[cmdk-input]' ) ).toBeVisible( { timeout: 2000 } );
} ).toPass();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion user-switching.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Text Domain: user-switching
* Domain Path: /languages/
* Network: true
* Requires at least: 6.2
* Requires at least: 6.3
* Requires PHP: 7.4
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
Expand Down