Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Site Scan Feature #6610

Merged
merged 122 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
1e6878f
Add Site Scan step bare bones to Onboarding Wizard
delawski Sep 15, 2021
79af03d
Add `ProgressBar` component
delawski Sep 15, 2021
4bd7a32
Move `SiteScanContextProvider` to common components folder
delawski Sep 16, 2021
df37573
Add `amp/v1/scannable-urls` REST endpoint
delawski Sep 16, 2021
b84e7b0
Refactor validation endpoint to allow validating by URL
delawski Sep 16, 2021
241e1b8
Apply suggestions from code review
delawski Sep 20, 2021
5bd0575
Revert "Refactor validation endpoint to allow validating by URL"
delawski Sep 20, 2021
97dfb1f
Fix issues and update docs
delawski Sep 20, 2021
8815b9a
Ensure scannable URLs are AMP endpoints
delawski Sep 20, 2021
900503f
Scan pages sequentially and visualize current scan state
delawski Sep 20, 2021
947ba18
Improve scan progress animation
delawski Sep 22, 2021
29c2e28
Add checked page labels
delawski Sep 22, 2021
577ccac
Retrieve theme and plugin names that cause AMP validation errors
delawski Sep 23, 2021
9bc44c0
Update look and feel of scan complete Onboarding Wizard step
delawski Sep 23, 2021
a88316a
Add missing snapshot
delawski Sep 23, 2021
f834380
Add `SourcesList` sub-component
delawski Sep 23, 2021
fbe3bf3
Omit optional `.php` plugin extension in site scan results
delawski Sep 24, 2021
96438ba
Add plugins context provider and use in site scan summary
delawski Sep 24, 2021
bfd3d5f
Add themes context provider and use in site scan summary
delawski Sep 24, 2021
7b7f296
Extract themes and plugins with issues lists to sub-components
delawski Sep 24, 2021
bbaaac0
Improve site scan flow and allow cancelling
delawski Sep 24, 2021
a648443
Fix stylelint issue
delawski Sep 24, 2021
49cf60e
Add final message for when site scan reveals no issues
delawski Sep 27, 2021
a42e8c3
Add links to Validated URL page to Site Scan summary step
delawski Sep 27, 2021
3812189
Revert debug code
delawski Sep 27, 2021
c0a18af
Allow going forward from theme selection step
delawski Sep 27, 2021
e500f70
Minor code cleanup
delawski Sep 27, 2021
c3f616c
Fix phpcs issues
delawski Sep 27, 2021
3171385
Use scannable URL label provided by backend
delawski Sep 30, 2021
1ab1b73
Use ScannableURLs REST endpoint for getting preview URLs
delawski Sep 30, 2021
faea80f
Extract site scan results tables to standalone components
delawski Sep 30, 2021
bdba451
Display Validated URL link only to technical users
delawski Sep 30, 2021
147a5f1
Migrate `SiteScanResults` related CSS to component folder
delawski Oct 1, 2021
c0f1183
Add site scan panel on AMP settings page
delawski Oct 1, 2021
9fa9146
Use correct icon in Site Scan panel
delawski Oct 1, 2021
e2b6f14
Reverse order of template mode recommendations in Onboarding Wizard
delawski Oct 6, 2021
58d1b48
Add header copy and links to Template Modes step
delawski Oct 6, 2021
695fe03
Update CSS and copy of template mode selection Wizard step
delawski Oct 6, 2021
6e47aa6
Update function and prop names related to template mode selection
delawski Oct 6, 2021
a300ffb
Construct AMP validation URL on the client-side
delawski Oct 7, 2021
4d5e265
Revamp site scan context provider and UI components
delawski Oct 8, 2021
98bc435
Add validation_errors, validated_url_post, and stale to scannable-urls
westonruter Oct 7, 2021
f861d55
Fetch cached validation errors in Site Scan on Settings page
delawski Oct 11, 2021
ebfeaf2
Add pre- and post-scan messages; add staleness notices
delawski Oct 11, 2021
1ccee27
Fix lint errors
delawski Oct 11, 2021
5c65e55
Add ampFirst prop to SiteScanContextProvider and set as false on sett…
westonruter Oct 11, 2021
428be92
Ignore some validation error codes in site scan
delawski Oct 12, 2021
6ec0572
Swap conditions
delawski Oct 12, 2021
290d42f
Use default page URL only when validating in standard mode
delawski Oct 12, 2021
54223a3
Remove redundant constant and prop
delawski Oct 12, 2021
d77ce62
Minor styling updates
delawski Oct 12, 2021
5557da3
Cancel and invalidate scan when theme support changes
delawski Oct 12, 2021
a8e4719
Prevent Site Scan container re-rendering on status change
delawski Oct 12, 2021
ee14171
Unify naming convention; refactor delayed flag into a custom hook
delawski Oct 12, 2021
f1ae8e6
Remove needless condition
delawski Oct 12, 2021
e136b4b
Fix JS lint issue
delawski Oct 12, 2021
ceeb40b
Patch holes in scanner UI state logic
delawski Oct 12, 2021
8c1350c
Apply suggestions from code review
delawski Oct 13, 2021
25a552a
Simplify site scan reducer and add failed scan state
delawski Oct 13, 2021
3994353
Preload themes and plugins data
delawski Oct 13, 2021
4dd1fcb
Fix JS test
delawski Oct 13, 2021
7b51924
Determine `previewPermalink` in Site Scan context provider
delawski Oct 13, 2021
16d7038
Fix `scannable-urls` preload path in Onboarding Wizard
delawski Oct 13, 2021
73156df
Do not determine site issues if scan is in progress
delawski Oct 13, 2021
00d34b6
Focus on Site Scan panel when starting scan
delawski Oct 13, 2021
7e6ec7e
Add missing useEffect dependency
delawski Oct 13, 2021
3c36262
Update E2E tests: increase stepper items count (Site Scan added)
delawski Oct 14, 2021
95e74d8
Allow invalidating `scannableUrl` in the READY status
delawski Oct 14, 2021
b53c7bd
Invalidate Site Scan results whenever specific options change
delawski Oct 14, 2021
745039e
Use post or page URL for previewPermalink in Reader mode
delawski Oct 15, 2021
61f958c
Ensure it's possible to go through entire Onboarding Wizard in E2E tests
delawski Oct 15, 2021
95b7f93
Fix template mode recommendations verification (E2E tests)
delawski Oct 15, 2021
19bed46
Clean up `transitional-recommendation` spec - overlap with `template-…
delawski Oct 15, 2021
c1f5f41
Add E2E tests for site scanning in Wizard and Settings page
delawski Oct 18, 2021
640c81b
Extract AMP Setting page Review panel E2E tests to separate file
delawski Oct 19, 2021
ce4d1c6
Add E2E tests for Site Scan results on AMP Settings screen
delawski Oct 20, 2021
4985064
Use Twenty Twenty as default theme in Site Scan
delawski Oct 20, 2021
54ce73c
Ensure wizard button tests are async functions
delawski Oct 20, 2021
b3c00ea
Add E2E tests covering Site Scan summary in Onboarding Wizard
delawski Oct 20, 2021
220fd8c
Add notices for inactive and uninstalled sources
delawski Oct 22, 2021
37eeac8
Show correct message if there are no site scan results yet
delawski Oct 22, 2021
cd7fb88
Invalidate scan results based on staleness of scannable URLs
delawski Oct 25, 2021
70fcc43
Address code review feedback
delawski Oct 25, 2021
ddeb234
Merge branch 'add/validate-store-url-query-var' into feature/4719-sit…
westonruter Oct 25, 2021
0e134aa
Add tests for add_preload_rest_paths
westonruter Oct 25, 2021
74b82c0
Use AMP_Validation_Manager::has_cap() in get_items_permissions_check()
westonruter Oct 25, 2021
d1db12c
Avoid adding paired endpoint to scannable URLs when AMP-first
westonruter Oct 25, 2021
b0d446a
Add tests for ScannableURLsRestController and improve controller stru…
westonruter Oct 25, 2021
32bf22a
Merge branch 'develop' of github.com:ampproject/amp-wp into feature/4…
westonruter Oct 26, 2021
7403381
Skip Gutenberg as a source if there are more than one
westonruter Oct 26, 2021
3eba944
Apply suggestions from code review
delawski Oct 26, 2021
2c66292
Fix comment alignment
delawski Oct 26, 2021
65fc288
Use more correct 'AMP incompatibility' instead of 'issues' term
delawski Oct 26, 2021
cfcbc92
Improve plugin sources normalization and slug retrieval logic
delawski Oct 26, 2021
a797f78
Keep new helper in separate file to prevent build errors
delawski Oct 26, 2021
7ad3998
Use 'AMP incompatibility' instead of 'issues'
delawski Oct 26, 2021
5ed62f8
Use clearer name for `Array.reduce` accumulator property
delawski Oct 26, 2021
1313a0f
Always allow re-running Site Scan
delawski Oct 26, 2021
16586ff
Allow scanning only if there are scannable URLs
delawski Oct 26, 2021
dcd9a44
Replace `WithAMPIncompatibility` with `WithAmpIncompatibility`
delawski Oct 26, 2021
2b02071
Get plugin slug using similar logic as in PHP
delawski Oct 26, 2021
d5a3103
Don't use external link for Validated URLs page on Settings screen
delawski Oct 26, 2021
3f80f6e
Ensure site scan is cancelled whenever AMP options are changed
delawski Oct 26, 2021
22ec597
Remove unused imports
delawski Oct 26, 2021
021df6f
Improve logic for getting plugin slug from file path
delawski Oct 27, 2021
68011a8
Ensure `gutenberg` is excluded only if there are other error sources
delawski Oct 27, 2021
4b4d7ea
Update "Validated URLs" link text
delawski Oct 27, 2021
bd39a6e
Rename test to match tested file and remove impossible test case
delawski Oct 27, 2021
7d2f1d1
Add test for when `gutenberg` isn't the only plugin for validation error
delawski Oct 27, 2021
cf218ea
Refactor template mode recommendation logic; use it on AMP Settings
delawski Oct 27, 2021
27a11e2
Prevent running E2E tests on empty WordPress instance
delawski Oct 27, 2021
4cb3597
Update Onboarding Wizard Site Scan E2E test
delawski Oct 27, 2021
807532c
Fix E2E tests for Site Scan panel on AMP Settings screen
delawski Oct 27, 2021
c83a2a9
Fix E2E tests for Site Review panel on AMP Settings screen
delawski Oct 27, 2021
cc9653c
Disable Template Mode E2E tests on AMP Settings screen
delawski Oct 27, 2021
891b1d5
E2E: Ensure Reader Themes drawer is expanded before testing contents
delawski Oct 27, 2021
7920d78
Convert template mode recommendation function into custom hook
delawski Oct 28, 2021
5073e8b
E2E: test if template mode recommendation is marked as stale after sc…
delawski Oct 28, 2021
4a9f875
Increase JS unit test coverage, remove impossible cases
delawski Oct 28, 2021
9949c8a
Use current user option in Wizard template mode recommendation
delawski Oct 28, 2021
88a1fd9
Add missing comma
delawski Oct 28, 2021
8836b54
Try fixing E2E tests
delawski Oct 28, 2021
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
1 change: 1 addition & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'reader_theme_loader' => \AmpProject\AmpWP\ReaderThemeLoader::class,
'reader_theme_support_features' => \AmpProject\AmpWP\ReaderThemeSupportFeatures::class,
'rest.options_controller' => \AmpProject\AmpWP\OptionsRESTController::class,
'rest.scannable_urls_controller' => \AmpProject\AmpWP\Validation\ScannableURLsRestController::class,
'rest.validation_counts_controller' => \AmpProject\AmpWP\Validation\ValidationCountsRestController::class,
'sandboxing' => \AmpProject\AmpWP\Sandboxing::class,
'save_post_validation_event' => \AmpProject\AmpWP\Validation\SavePostValidationEvent::class,
Expand Down
16 changes: 16 additions & 0 deletions assets/src/common/helpers/get-plugin-slug-from-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Get plugin slug from file path.
*
* If the plugin file is in a directory, then the slug is just the directory name. Otherwise, if the file is not
* inside of a directory and is just a single-file plugin, then the slug is the filename of the PHP file.
*
* If the file path contains a file extension, it will be stripped as well.
*
* See the corresponding PHP logic in `\AmpProject\AmpWP\get_plugin_slug_from_file()`.
*
* @param {string} path Plugin file path.
* @return {string} Plugin slug.
*/
export function getPluginSlugFromFile( path = '' ) {
return path.replace( /\/.*$/, '' ).replace( /\.php$/, '' );
}
13 changes: 13 additions & 0 deletions assets/src/common/helpers/test/get-plugin-slug-from-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Internal dependencies
*/
import { getPluginSlugFromFile } from '../get-plugin-slug-from-file';

describe( 'getPluginSlugFromFile', () => {
it( 'should return correct plugin slug', () => {
expect( getPluginSlugFromFile( 'foo' ) ).toBe( 'foo' );
expect( getPluginSlugFromFile( 'foo.php' ) ).toBe( 'foo' );
expect( getPluginSlugFromFile( 'foo/bar' ) ).toBe( 'foo' );
expect( getPluginSlugFromFile( 'foo/baz.php' ) ).toBe( 'foo' );
} );
} );
40 changes: 33 additions & 7 deletions assets/src/components/amp-drawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,22 @@ export const HANDLE_TYPE_RIGHT = 'right';
* @param {any} props.heading Content for the drawer heading.
* @param {string} props.id A unique ID for the component.
* @param {boolean} props.initialOpen Whether the drawer should be initially open.
* @param {Object} props.labelExtra Optional. Extra content to display on the right side of the option label.
* @param {boolean} props.selected Whether to apply the selectable components selected CSS class.
* @param {string} props.hiddenTitle A title to go with the button that expands the drawer.
* @param {string} props.handleType Display style for the drawer handle. Either 'full-width' or 'right'.
*/
export function AMPDrawer( { children = null, className, heading, handleType = HANDLE_TYPE_FULL_WIDTH, id, initialOpen = false, selected = false, hiddenTitle } ) {
export function AMPDrawer( {
children = null,
className,
heading,
handleType = HANDLE_TYPE_FULL_WIDTH,
id,
initialOpen = false,
labelExtra = null,
selected = false,
hiddenTitle,
} ) {
const [ opened, setOpened ] = useState( initialOpen );
const [ resetStatus, setResetStatus ] = useState( null );

Expand Down Expand Up @@ -94,9 +105,16 @@ export function AMPDrawer( { children = null, className, heading, handleType = H
selected={ selected }
>
{ handleType === HANDLE_TYPE_RIGHT && (
<div className="amp-drawer__heading">
{ heading }
</div>
<>
<div className="amp-drawer__heading">
{ heading }
</div>
{ labelExtra && (
<div className="amp-drawer__label-extra">
{ labelExtra }
</div>
) }
</>
) }
{ 'resetting' !== resetStatus && (
<PanelBody
Expand All @@ -105,9 +123,16 @@ export function AMPDrawer( { children = null, className, heading, handleType = H
{ hiddenTitle }
</VisuallyHidden>
) : (
<div className="amp-drawer__heading">
{ heading }
</div>
<>
<div className="amp-drawer__heading">
{ heading }
</div>
{ labelExtra && (
<div className="amp-drawer__label-extra">
{ labelExtra }
</div>
) }
</>
) }
className="amp-drawer__panel-body"
initialOpen={ initialOpen }
Expand All @@ -129,5 +154,6 @@ AMPDrawer.propTypes = {
hiddenTitle: PropTypes.node.isRequired,
id: PropTypes.string.isRequired,
initialOpen: PropTypes.bool,
labelExtra: PropTypes.node,
selected: PropTypes.bool,
};
29 changes: 20 additions & 9 deletions assets/src/components/amp-drawer/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
padding-left: 0.75rem;
padding-right: 0.75rem;
overflow: hidden;
position: absolute;
top: 0;
z-index: 1;
flex-grow: 1;

@media (min-width: 783px) {
padding-left: 3rem;
Expand All @@ -45,6 +43,14 @@
margin-bottom: 0;
}

.amp-drawer__heading svg {
margin-right: 1rem;
}

.amp-drawer__label-extra svg {
fill: none;
}

.amp .amp-drawer .components-panel__body-title {
height: var(--heading-height);
margin: 0 0 0 auto;
Expand All @@ -63,7 +69,6 @@
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
}

.amp .amp-drawer .components-panel__body-title button {
Expand All @@ -77,16 +82,15 @@
}


.amp .amp-drawer .components-panel__body-title button span {
.amp .amp-drawer .components-panel__body-title > button > span {
align-items: center;
display: flex;
height: 100%;
margin-left: auto;
justify-content: center;
width: var(--panel-button-width);
order: 100;
}

.amp .amp-drawer .components-panel__body-title svg {
.amp .amp-drawer .components-panel__body-toggle.components-button .components-panel__arrow {
height: 30px;
position: static;
transform: none;
Expand All @@ -98,7 +102,8 @@
}
}

.amp .amp-drawer--handle-type-full-width .components-panel__body-title svg {

.amp .amp-drawer--handle-type-full-width .components-panel__body-title > button > svg {
margin-left: auto;

@media (min-width: 783px) {
Expand All @@ -110,6 +115,11 @@
border-radius: 5px;
}

.amp .amp-drawer .components-panel__body-title .amp-notice {
font-family: var(--font-default);
font-weight: 400;
}

.amp .amp-drawer__panel-body {
padding: 0;
border-top-width: 0;
Expand All @@ -135,6 +145,7 @@

.amp .amp-drawer--handle-type-right .amp-drawer__heading {
right: var(--panel-button-width);
width: calc(100% - var(--panel-button-width));
}

.amp-drawer--handle-type-right .components-panel__body-title {
Expand Down
3 changes: 2 additions & 1 deletion assets/src/components/amp-notice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import './style.css';
export const NOTICE_TYPE_ERROR = 'error';
export const NOTICE_TYPE_WARNING = 'warning';
export const NOTICE_TYPE_INFO = 'info';
export const NOTICE_TYPE_PLAIN = 'plain';
export const NOTICE_TYPE_SUCCESS = 'success';

export const NOTICE_SIZE_SMALL = 'small';
Expand Down Expand Up @@ -103,5 +104,5 @@ AMPNotice.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
size: PropTypes.oneOf( [ NOTICE_SIZE_LARGE, NOTICE_SIZE_SMALL ] ),
type: PropTypes.oneOf( [ NOTICE_TYPE_INFO, NOTICE_TYPE_SUCCESS, NOTICE_TYPE_ERROR, NOTICE_TYPE_WARNING ] ),
type: PropTypes.oneOf( [ NOTICE_TYPE_PLAIN, NOTICE_TYPE_INFO, NOTICE_TYPE_SUCCESS, NOTICE_TYPE_ERROR, NOTICE_TYPE_WARNING ] ),
};
7 changes: 6 additions & 1 deletion assets/src/components/amp-notice/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
background-color: #effbff;
}

.amp-notice--info svg {
.amp-notice--info svg,
.amp-notice--plain svg {
color: var(--amp-settings-color-brand);
}

Expand All @@ -51,6 +52,10 @@
background-color: #ffefef;
}

.amp-notice.amp-notice--plain {
padding: 1px 5px;
}

.amp-notice--small {
font-size: 14px;
line-height: 1.5;
Expand Down
21 changes: 20 additions & 1 deletion assets/src/components/amp-notice/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ import { render } from '@wordpress/element';
/**
* Internal dependencies
*/
import { AMPNotice, NOTICE_TYPE_SUCCESS, NOTICE_SIZE_LARGE, NOTICE_TYPE_ERROR, NOTICE_SIZE_SMALL, NOTICE_TYPE_INFO } from '..';
import {
AMPNotice,
NOTICE_TYPE_SUCCESS,
NOTICE_SIZE_LARGE,
NOTICE_TYPE_ERROR,
NOTICE_SIZE_SMALL,
NOTICE_TYPE_INFO,
NOTICE_TYPE_PLAIN,
} from '..';

let container;

Expand Down Expand Up @@ -78,5 +86,16 @@ describe( 'AMPNotice', () => {
} );

expect( container.querySelector( 'div' ).getAttribute( 'class' ) ).toBe( 'amp-notice amp-notice--info amp-notice--small' );

act( () => {
render(
<AMPNotice type={ NOTICE_TYPE_PLAIN } size={ NOTICE_SIZE_SMALL }>
{ 'children' }
</AMPNotice>,
container,
);
} );

expect( container.querySelector( 'div' ).getAttribute( 'class' ) ).toBe( 'amp-notice amp-notice--plain amp-notice--small' );
} );
} );
41 changes: 41 additions & 0 deletions assets/src/components/plugins-context-provider/__mocks__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';

/**
* WordPress dependencies
*/
import { createContext } from '@wordpress/element';

export const Plugins = createContext();

/**
* MOCK.
*
* @param {Object} props
* @param {any} props.children Component children.
* @param {boolean} props.fetchingPlugins Whether fetching plugins or not.
* @param {Array} props.plugins An array of fetched plugins.
*/
export function PluginsContextProvider( {
children,
fetchingPlugins = false,
plugins = [],
} ) {
return (
<Plugins.Provider value={
{
fetchingPlugins,
plugins,
}
}>
{ children }
</Plugins.Provider>
);
}
PluginsContextProvider.propTypes = {
children: PropTypes.any,
fetchingPlugins: PropTypes.bool,
plugins: PropTypes.array,
};
Loading