Skip to content

Commit cd9f2da

Browse files
authored
Merge branch 'develop' into fix/345-dialog-accessibility
2 parents 374dc13 + ddcd425 commit cd9f2da

File tree

237 files changed

+4279
-2775
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+4279
-2775
lines changed

.eslintrc.json

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@
77
"browser": true,
88
"es6": true
99
},
10-
"settings": {
11-
"react": {
12-
"version": "16.2.0"
13-
}
14-
},
15-
"globals": {
16-
"React": "readonly",
17-
"googlesitekit": "readonly",
18-
"googlesitekitAdminbar": "readonly",
19-
"googlesitekitDashboard": "readonly",
20-
"googlesitekitSettings": "readonly",
21-
"lodash": "readonly",
22-
"googlesitekitCurrentModule": "readonly",
23-
"gtag": "readonly",
24-
"process": "readonly"
25-
},
2610
"rules": {
2711
"no-restricted-globals": [
2812
"error",
@@ -31,7 +15,10 @@
3115
"message": "Use 'global' instead."
3216
}
3317
],
34-
"react/jsx-fragments": ["error", "element"],
18+
"react/jsx-fragments": [
19+
"error",
20+
"element"
21+
],
3522
"valid-jsdoc": "warn"
3623
},
3724
"overrides": [
@@ -44,21 +31,7 @@
4431
},
4532
"globals": {
4633
"browser": true,
47-
"page": true,
48-
"wp": true
49-
},
50-
"rules": {
51-
"no-restricted-globals": [
52-
"off"
53-
]
54-
}
55-
},
56-
{
57-
"files": [
58-
"stories/**/*.js"
59-
],
60-
"globals": {
61-
"window": false
34+
"page": true
6235
},
6336
"rules": {
6437
"no-restricted-globals": [

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ _Do not alter or remove anything below. The following sections will be managed b
4343

4444
* <!-- One or more bullet points for how to technically resolve the issue. -->
4545

46+
## QA Brief
47+
48+
* <!-- One or more bullet points for how to test that the issue has been resolved. -->
49+
4650
## Changelog entry
4751

4852
* <!-- One sentence summarizing the PR, to be used in the changelog. -->

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ _Do not alter or remove anything below. The following sections will be managed b
1818

1919
## Implementation Brief
2020

21-
* <!-- One or more bullet points for how to technically resolve the issue. -->
21+
* <!-- One or more bullet points for how to technically implement the feature. -->
22+
23+
## QA Brief
24+
25+
* <!-- One or more bullet points for how to test that the feature works as expected. -->
2226

2327
## Changelog entry
2428

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ phpunit.xml
1111
npm-debug.log
1212
/dist
1313
/languages
14-
google-site-kit.zip
14+
google-site-kit*.zip
1515

1616
# Editors
1717
*.esproj

.storybook/config.js

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ import {
3535
/**
3636
* Internal dependencies
3737
*/
38-
import '../dist/assets/css/wpdashboard.css';
39-
import '../dist/assets/css/adminbar.css';
40-
import '../dist/assets/css/admin.css';
38+
import '../assets/sass/wpdashboard.scss';
39+
import '../assets/sass/adminbar.scss';
40+
import '../assets/sass/admin.scss';
4141
import '../vendor/johnpbloch/wordpress-core/wp-admin/css/common.css';
4242
import '../vendor/johnpbloch/wordpress-core/wp-admin/css/dashboard.css';
4343
import '../vendor/johnpbloch/wordpress-core/wp-admin/css/edit.css';
@@ -73,42 +73,19 @@ wp.element.createPortal = createPortal;
7373
wp.i18n.__ = __ || {};
7474
wp.i18n.setLocaleData = setLocaleData || {};
7575
wp.i18n.sprintf = sprintf || {};
76-
window.wp = window.wp || wp;
77-
window.React = React;
78-
window.lodash = lodash;
79-
window.googlesitekit = window.googlesitekit || googlesitekit;
80-
window.googlesitekit.setup = window.googlesitekit.setup || googlesitekit.setup;
81-
window.googlesitekit.admin = window.googlesitekit.admin || googlesitekit.admin;
82-
window.googlesitekit.modules = window.googlesitekit.modules || googlesitekit.modules;
83-
window.googlesitekit.admin.assetsRoot = '/assets/';
84-
window.googlesitekit.isStorybook = true;
85-
window._googlesitekitBase = {
76+
global.wp = global.wp || wp;
77+
global.React = React;
78+
global.lodash = lodash;
79+
global.googlesitekit = global.googlesitekit || googlesitekit;
80+
global.googlesitekit.setup = global.googlesitekit.setup || googlesitekit.setup;
81+
global.googlesitekit.admin = global.googlesitekit.admin || googlesitekit.admin;
82+
global.googlesitekit.modules = global.googlesitekit.modules || googlesitekit.modules;
83+
global.googlesitekit.admin.assetsRoot = '/assets/';
84+
global.googlesitekit.isStorybook = true;
85+
global._googlesitekitBase = {
8686
basePrefix: 'wp_',
8787
splashURL: 'http://localhost/wp-admin/admin.php?page=googlesitekit-splash',
8888
};
89-
window.wp.apiFetch = ( vars ) => {
90-
const { modules } = window.googlesitekit;
91-
const match = vars.path.match( /google-site-kit\/v1\/modules\/([\w-]+)\/data\/([\w-]+)/ );
92-
93-
if ( match && match[ 1 ] && match[ 2 ] ) {
94-
const [ , identifier, datapoint ] = match;
95-
96-
if ( identifier && datapoint && modules[ identifier ] && modules[ identifier ][ datapoint ] ) {
97-
return Promise.resolve( modules[ identifier ][ datapoint ] );
98-
}
99-
}
100-
101-
// eslint-disable-next-line no-console
102-
console.warn( 'apiFetch', vars );
103-
104-
return {
105-
then: () => {
106-
return {
107-
catch: () => false,
108-
};
109-
},
110-
};
111-
};
11289

11390
// Global Decorator.
11491
addDecorator( ( story ) => <div className="googlesitekit-plugin-preview">

.storybook/webpack.config.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,47 @@
11
const path = require( 'path' );
2+
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
23

34
module.exports = async ( { config } ) => {
45
config.resolve = {
56
...config.resolve,
67
alias: {
78
...config.resolve.alias,
9+
'@wordpress/api-fetch$': path.resolve( __dirname, 'wp-api-fetch-mock.js' ),
810
SiteKitCore: path.resolve( __dirname, '../assets/js/' ),
911
GoogleComponents: path.resolve( __dirname, '../assets/js/components/' ),
1012
GoogleUtil: path.resolve( __dirname, '../assets/js/util/' ),
1113
GoogleModules: path.resolve( __dirname, '../assets/js/modules/' ),
1214
},
1315
};
1416

17+
config.plugins = [
18+
...config.plugins,
19+
new MiniCssExtractPlugin(),
20+
];
21+
22+
config.module.rules.push(
23+
{
24+
test: /\.scss$/,
25+
use: [
26+
MiniCssExtractPlugin.loader,
27+
'css-loader',
28+
'postcss-loader',
29+
{
30+
loader: 'sass-loader',
31+
options: {
32+
includePaths: [ path.resolve( __dirname, '../node_modules/' ) ],
33+
},
34+
},
35+
],
36+
},
37+
);
38+
1539
config.module.rules.push(
1640
{
1741
test: /\.(png|woff|woff2|eot|ttf|svg|gif)$/,
1842
use: { loader: 'url-loader?limit=100000' },
1943
}
2044
);
2145

22-
config.externals = {
23-
'@wordpress/api-fetch': [ 'wp', 'apiFetch' ],
24-
};
25-
2646
return config;
2747
};

.storybook/wp-api-fetch-mock.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default ( vars ) => {
2+
const { modules } = global.googlesitekit;
3+
const match = vars.path.match( /google-site-kit\/v1\/modules\/([\w-]+)\/data\/([\w-]+)/ );
4+
5+
if ( match && match[ 1 ] && match[ 2 ] ) {
6+
const [ , identifier, datapoint ] = match;
7+
8+
if ( identifier && datapoint && modules[ identifier ] && modules[ identifier ][ datapoint ] ) {
9+
return Promise.resolve( modules[ identifier ][ datapoint ] );
10+
}
11+
}
12+
13+
// eslint-disable-next-line no-console
14+
console.warn( 'apiFetch', vars );
15+
16+
return {
17+
then: () => {
18+
return {
19+
catch: () => false,
20+
};
21+
},
22+
};
23+
};

.travis.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ branches:
3939
# Before install, failures in this section will result in build status 'errored'
4040
before_install:
4141
- |
42-
if [[ "$JS" == "1" ]] || [[ "$E2E" == "1" ]] || [[ "$SNIFF" == "1" ]]; then
42+
if [[ "$JS" == "1" ]] || [[ "$VRT" == "1" ]] || [[ "$E2E" == "1" ]] || [[ "$SNIFF" == "1" ]]; then
4343
nvm install
4444
npm ci
4545
fi
@@ -48,7 +48,7 @@ before_install:
4848
docker run --rm -v "$PWD:/app" -v "$HOME/.cache/composer:/tmp/cache" composer install
4949
fi
5050
- |
51-
if [[ "$JS" == "1" ]]; then
51+
if [[ "$VRT" == "1" ]]; then
5252
docker run --rm -v "$PWD:/app" -v "$HOME/.cache/composer:/tmp/cache" composer install --no-scripts
5353
fi
5454
- |
@@ -74,18 +74,20 @@ script:
7474
fi
7575
- |
7676
if [[ "$JS" == "1" ]]; then
77-
npm run build || exit 1 # Build for tests.
7877
npm run test:js || exit 1 # JS unit tests
7978
npm run test || exit 1 # Bundle size test
80-
travis_retry npm run travis:visualtest || exit 1 # Visual regression tests
79+
fi
80+
- |
81+
if [[ "$VRT" == "1" ]]; then
82+
travis_retry npm run travis:visualtest || exit 1
8183
fi
8284
- |
8385
if [[ "$PHP" == "1" ]]; then
8486
composer test || exit 1
8587
fi
8688
- |
8789
if [[ "$E2E" == "1" ]]; then
88-
npm run build || exit 1 # Build for tests.
90+
npm run build:test || exit 1 # Build for tests.
8991
npm run env:start || exit 1
9092
npm run test:e2e:ci || exit 1 # E2E tests.
9193
fi
@@ -106,10 +108,12 @@ jobs:
106108
env: WP_VERSION=latest PHP=1
107109
- name: PHP Tests (PHP 7.4, WordPress Multisite latest)
108110
php: 7.4
109-
env: WP_VERSION=latest WP_MULTISITE=1 PHP=1 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
111+
env: WP_VERSION=latest WP_MULTISITE=1 PHP=1
110112
- name: JS Tests
111113
php: 7.4
112-
env: WP_VERSION=latest JS=1
114+
env: WP_VERSION=latest JS=1 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
115+
- name: Visual Regression
116+
env: VRT=1
113117
- name: PHP Tests (PHP nightly, WordPress trunk)
114118
stage: test
115119
php: nightly

assets/js/ads.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
* If the file does load, `googlesitekit.canAdsRun` is set to true.
66
*/
77

8-
global.googlesitekit = global.googlesitekit || {};
8+
if ( global.googlesitekit === undefined ) {
9+
global.googlesitekit = {};
10+
}
11+
912
global.googlesitekit.canAdsRun = true;
1013

1114
// Ensure that this flag does not get wiped at a later stage during pageload.

assets/js/api-fetch-shim.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import apiFetch from '@wordpress/api-fetch__non-shim';
5+
6+
if ( global._googlesitekitAPIFetchData ) {
7+
if ( global._googlesitekitAPIFetchData.rootURL ) {
8+
apiFetch.use( apiFetch.createRootURLMiddleware( global._googlesitekitAPIFetchData.rootURL ) );
9+
}
10+
11+
if ( global._googlesitekitAPIFetchData.nonceMiddleware ) {
12+
apiFetch.nonceMiddleware = apiFetch.createNonceMiddleware();
13+
apiFetch.use( apiFetch.createNonceMiddleware( global._googlesitekitAPIFetchData.nonceMiddleware ) );
14+
apiFetch.use( apiFetch.mediaUploadMiddleware );
15+
apiFetch.nonceEndpoint = global._googlesitekitAPIFetchData.nonceEndpoint;
16+
}
17+
}
18+
19+
export * from '@wordpress/api-fetch__non-shim';
20+
21+
export default apiFetch;

0 commit comments

Comments
 (0)