Skip to content

Commit

Permalink
Merge pull request #7490 from ampproject/revert/7421
Browse files Browse the repository at this point in the history
Remove React 17 requirement for `AfterActivationSiteScan` service
  • Loading branch information
westonruter authored Mar 16, 2023
2 parents 96cdfb9 + ba02543 commit 4337065
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 43 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ node_modules

# Generated via bin/transform-readme.php
/readme.txt
/tests/e2e/plugins/gutenberg.14.7.3.zip

# Generated via phpstan analyse --generate-baseline temp-baseline.php
/temp-baseline.php
3 changes: 0 additions & 3 deletions bin/local-env/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ cd "$(dirname "$0")/../.."
# done on every time `npm run test-e2e` is run.
. "$(dirname "$0")/install-wordpress.sh"

# Install specific version of Gutenberg plugin for e2e tests.
download_gutenberg "14.7.3" "tests/e2e/plugins/gutenberg.14.7.3.zip"

! read -d '' AMP <<"EOT"
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMWNXK0OOkkkkOO0KXNWMMMMMMMMMMMMMMMM
Expand Down
12 changes: 0 additions & 12 deletions src/Admin/AfterActivationSiteScan.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace AmpProject\AmpWP\Admin;

use _WP_Dependency;
use AMP_Options_Manager;
use AMP_Validation_Manager;
use AmpProject\AmpWP\Infrastructure\Conditional;
Expand Down Expand Up @@ -42,13 +41,6 @@ final class AfterActivationSiteScan implements Conditional, Delayed, HasRequirem
*/
const APP_ROOT_ID = 'amp-site-scan-notice';

/**
* React dependency handle.
*
* @var string
*/
const REACT = 'react';

/**
* HTML ID for the app root sibling element.
*
Expand Down Expand Up @@ -92,17 +84,13 @@ public function __construct( RESTPreloader $rest_preloader ) {
public static function is_needed() {
global $pagenow;

$react = wp_scripts()->query( self::REACT );

return (
is_admin()
&&
Services::get( 'dependency_support' )->has_support()
&&
! is_network_admin()
&&
( $react instanceof _WP_Dependency && version_compare( $react->ver, '18', '<' ) )
&&
AMP_Validation_Manager::has_cap()
&&
(
Expand Down
20 changes: 0 additions & 20 deletions tests/e2e/specs/admin/after-plugin-activation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import { visitAdminPage } from '@wordpress/e2e-test-utils';
* Internal dependencies
*/
import { completeWizard } from '../../utils/onboarding-wizard-utils';
import {
installPlugin,
installLocalPlugin,
uninstallPlugin,
} from '../../utils/amp-settings-utils';

describe('After plugin activation', () => {
const timeout = 30000;
Expand All @@ -27,23 +22,8 @@ describe('After plugin activation', () => {
}

beforeAll(async () => {
// Uninstall the latest Gutenberg plugin.
await uninstallPlugin('gutenberg');

// Install the Gutenberg 14.7.3 plugin for React 17 compatibility and test SiteScanNotice on plugins page.
await installLocalPlugin('gutenberg.14.7.3');

await completeWizard({ mode: 'transitional' });
await visitAdminPage('plugins.php', '');

await activate('gutenberg');
});

afterAll(async () => {
await uninstallPlugin('gutenberg');

// Install the latest Gutenberg plugin.
await installPlugin('gutenberg');
});

it('site scan is triggered automatically and displays no validation issues for AMP-compatible plugin', async () => {
Expand Down
10 changes: 3 additions & 7 deletions tests/php/src/Admin/AfterActivationSiteScanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use AmpProject\AmpWP\Tests\Helpers\PrivateAccess;
use AmpProject\AmpWP\Tests\Helpers\MockAdminUser;
use AMP_Validation_Manager;
use _WP_Dependency;

/**
* Tests for AfterActivationSiteScan class.
Expand Down Expand Up @@ -68,9 +67,6 @@ public function test__construct() {

/** @return array */
public function get_data_to_test_is_needed() {
$react = wp_scripts()->query( 'react' );
$should_get_site_activation_notice = $react instanceof _WP_Dependency && version_compare( $react->ver, '18', '<' );

return [
'not_admin_screen' => [
'screen_hook' => '',
Expand Down Expand Up @@ -105,7 +101,7 @@ public function get_data_to_test_is_needed() {
'plugins_screen_with_get_activate' => [
'screen_hook' => 'plugins.php',
'query_params' => [ 'activate' ],
'expected' => $should_get_site_activation_notice,
'expected' => true,
'role' => 'administrator',
],
'plugins_screen_with_get_activate_not_admin' => [
Expand All @@ -123,7 +119,7 @@ public function get_data_to_test_is_needed() {
'plugins_screen_with_get_activate_multi' => [
'screen_hook' => 'plugins.php',
'query_params' => [ 'activate-multi' ],
'expected' => $should_get_site_activation_notice,
'expected' => true,
'role' => 'administrator',
],
'plugins_screen_with_get_activated' => [
Expand All @@ -147,7 +143,7 @@ public function get_data_to_test_is_needed() {
'themes_screen_with_get_activated' => [
'screen_hook' => 'themes.php',
'query_params' => [ 'activated' ],
'expected' => $should_get_site_activation_notice,
'expected' => true,
'role' => 'administrator',
],
'themes_screen_with_get_activated_not_admin' => [
Expand Down

0 comments on commit 4337065

Please sign in to comment.