Skip to content

Commit

Permalink
fix(deps): update wordpress monorepo (#41207)
Browse files Browse the repository at this point in the history
* Fix oAuthStore test to make it compatible with latest jsdom

* Mock window.location in a jsdom compatible way

* Fix typos in comments

* Apply renovate patch

* Fix z-index map reference

* Remove document.activeElement.blur

* Refactor chai -> jest

* Attach to body to fix activeElement issue

* Unmount

* Fix User mock

Co-authored-by: Sergio Cinos <sergio.cinos@gmail.com>
Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
  • Loading branch information
3 people authored May 8, 2020
1 parent 0a33f41 commit e816f74
Show file tree
Hide file tree
Showing 9 changed files with 1,533 additions and 1,823 deletions.
10 changes: 7 additions & 3 deletions client/components/select-dropdown/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe( 'index', () => {
const escapeKeyCode = 27;
const escEvent = createKeyEvent( escapeKeyCode );

const dropdown = mountDropdown();
const dropdown = mountDropdown( true );
dropdown.setState( { isOpen: true } );

const container = dropdown.find( '.select-dropdown__container' );
Expand All @@ -206,6 +206,7 @@ describe( 'index', () => {
sinon.assert.calledOnce( escEvent.preventDefault );
// check that container was focused
expect( container.instance() ).to.equal( document.activeElement );
dropdown.unmount();
} );

describe( "permits to open the dropdown, and navigate through the dropdown's options by ", () => {
Expand All @@ -232,9 +233,12 @@ describe( 'index', () => {
* Utilities
*/

function mountDropdown() {
function mountDropdown( attach = false ) {
const dropdownOptions = getDropdownOptions();
return mount( <SelectDropdown options={ dropdownOptions } /> );
return mount(
<SelectDropdown options={ dropdownOptions } />,
attach ? { attachTo: document.body } : undefined
);
}

function shallowRenderDropdown( props ) {
Expand Down
177 changes: 81 additions & 96 deletions client/components/token-field/test/index.jsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/landing/gutenboarding/components/header/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $padding--gutenboarding__header: $grid-unit-10;
border-bottom: 1px solid $light-gray-500;
height: $gutenboarding-header-height;
background: $white;
z-index: z-index( '.block-editor-editor-skeleton__header' );
z-index: z-index( '.interface-interface-skeleton__header' );
left: 0;
right: 0;
// Stick the toolbar to the top, because the admin bar is not fixed on mobile.
Expand Down
21 changes: 18 additions & 3 deletions client/lib/oauth-store/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@ import { expect } from 'chai';
import sinon from 'sinon';

describe( 'oAuthStore', () => {
let oAuthStore, oAuthToken;
let oAuthStore, oAuthToken, originalDocumentProperties;

beforeEach( () => {
oAuthToken = require( 'lib/oauth-token' );
oAuthStore = require( 'lib/oauth-store' );

// global.document.location is not configurable and global.document has an empty setter
// so the only way to mock global.document.location.replace is do a full replacement
// of global.document using a property descriptor
originalDocumentProperties = Object.getOwnPropertyDescriptors( global ).document;
Object.defineProperty( global, 'document', {
writable: true,
value: {
location: {
replace: sinon.stub(),
},
},
} );
} );

afterEach( () => {
Object.defineProperty( global, 'document', originalDocumentProperties );
} );

test( 'is in progress when attempting login', () => {
Expand Down Expand Up @@ -92,7 +109,6 @@ describe( 'oAuthStore', () => {
} );

test( 'sets OAuth token when login is correct', () => {
sinon.stub( global.document.location, 'replace' );
sinon.stub( oAuthToken, 'setToken' );

Dispatcher.handleViewAction( { type: actions.AUTH_LOGIN } );
Expand All @@ -118,7 +134,6 @@ describe( 'oAuthStore', () => {
errorLevel: false,
} );

global.document.location.replace.restore();
oAuthToken.setToken.restore();
} );
} );
25 changes: 18 additions & 7 deletions client/my-sites/checkout/checkout/test/wechat-payment-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,25 @@ describe( 'WechatPaymentBox', () => {
} );

describe( '#componentDidUpdate', () => {
test( 'redirects on mobile', () => {
// https://github.com/facebook/jest/issues/890#issuecomment-295939071
window.location.assign = jest.fn();
let originalLocationProperties;

beforeEach( () => {
// window.location has an empty setter so the only way to mock window.location.asign
// is to do a full replacement of window.location using a property descriptor
originalLocationProperties = Object.getOwnPropertyDescriptors( window ).location;
Object.defineProperty( window, 'location', {
writable: true,
value: {
assign: jest.fn(),
},
} );
} );

afterEach( () => {
Object.defineProperty( global, 'document', originalLocationProperties );
} );

test( 'redirects on mobile', () => {
const redirectUrl = 'https://redirect';

const instance = shallow(
Expand All @@ -180,8 +195,6 @@ describe( 'WechatPaymentBox', () => {
} );

test( 'does not redirect on desktop', () => {
window.location.assign = jest.fn();

const redirectUrl = 'https://redirect';

const instance = shallow(
Expand All @@ -194,8 +207,6 @@ describe( 'WechatPaymentBox', () => {
} );

test( 'displays a qr code on desktop', () => {
window.location.assign = jest.fn();

const redirectUrl = 'https://redirect';

const wrapper = shallow(
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/sidebar/test/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MySitesSidebar } from '..';
import config from 'config';
import { abtest } from 'lib/abtest';

jest.mock( 'lib/user', () => null );
jest.mock( 'lib/user', () => () => null );
jest.mock( 'lib/user/index', () => () => {} );
jest.mock( 'lib/analytics/tracks', () => ( {} ) );
jest.mock( 'lib/analytics/page-view', () => ( {} ) );
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@wordpress/element": "^2.12.0",
"@wordpress/format-library": "^1.15.0",
"@wordpress/i18n": "^3.10.0",
"@wordpress/is-shallow-equal": "^1.8.0",
"@wordpress/is-shallow-equal": "^2.0.0",
"@wordpress/keycodes": "^2.10.0",
"@wordpress/notices": "^2.1.0",
"@wordpress/nux": "^3.13.0",
Expand Down
82 changes: 41 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,48 +205,48 @@
"@types/wordpress__url": "^2.3.0",
"@typescript-eslint/eslint-plugin": "^2.16.0",
"@typescript-eslint/parser": "^2.16.0",
"@wordpress/a11y": "2.8.0",
"@wordpress/api-fetch": "3.12.0",
"@wordpress/babel-plugin-makepot": "3.4.0",
"@wordpress/base-styles": "1.5.0",
"@wordpress/block-directory": "1.6.0",
"@wordpress/block-editor": "3.8.0",
"@wordpress/block-library": "2.15.0",
"@wordpress/blocks": "6.13.0",
"@wordpress/a11y": "2.9.0",
"@wordpress/api-fetch": "3.14.0",
"@wordpress/babel-plugin-makepot": "3.5.0",
"@wordpress/base-styles": "1.7.0",
"@wordpress/block-directory": "1.8.0",
"@wordpress/block-editor": "3.10.0",
"@wordpress/block-library": "2.17.0",
"@wordpress/blocks": "6.15.0",
"@wordpress/browserslist-config": "2.6.0",
"@wordpress/components": "9.3.0",
"@wordpress/compose": "3.12.0",
"@wordpress/core-data": "2.13.0",
"@wordpress/data": "4.15.0",
"@wordpress/data-controls": "1.9.0",
"@wordpress/dependency-extraction-webpack-plugin": "2.4.0",
"@wordpress/dom": "2.8.0",
"@wordpress/dom-ready": "2.8.0",
"@wordpress/e2e-test-utils": "4.4.0",
"@wordpress/edit-post": "3.14.0",
"@wordpress/editor": "9.13.0",
"@wordpress/element": "2.12.0",
"@wordpress/format-library": "1.15.0",
"@wordpress/i18n": "3.10.0",
"@wordpress/icons": "1.2.0",
"@wordpress/is-shallow-equal": "1.8.0",
"@wordpress/jest-preset-default": "5.5.0",
"@wordpress/keyboard-shortcuts": "1.2.0",
"@wordpress/keycodes": "2.10.0",
"@wordpress/media-utils": "1.8.0",
"@wordpress/notices": "2.1.0",
"@wordpress/npm-package-json-lint-config": "2.2.0",
"@wordpress/nux": "3.13.0",
"@wordpress/plugins": "2.13.0",
"@wordpress/primitives": "1.2.0",
"@wordpress/priority-queue": "1.5.1",
"@wordpress/redux-routine": "3.7.0",
"@wordpress/rich-text": "3.13.0",
"@wordpress/scripts": "7.2.0",
"@wordpress/server-side-render": "1.9.0",
"@wordpress/shortcode": "2.6.0",
"@wordpress/url": "2.12.0",
"@wordpress/viewport": "2.14.0",
"@wordpress/components": "9.5.0",
"@wordpress/compose": "3.14.0",
"@wordpress/core-data": "2.15.0",
"@wordpress/data": "4.17.0",
"@wordpress/data-controls": "1.11.0",
"@wordpress/dependency-extraction-webpack-plugin": "2.6.0",
"@wordpress/dom": "2.9.0",
"@wordpress/dom-ready": "2.9.0",
"@wordpress/e2e-test-utils": "4.6.0",
"@wordpress/edit-post": "3.16.0",
"@wordpress/editor": "9.15.0",
"@wordpress/element": "2.13.1",
"@wordpress/format-library": "1.17.0",
"@wordpress/i18n": "3.12.0",
"@wordpress/icons": "1.4.0",
"@wordpress/is-shallow-equal": "2.0.0",
"@wordpress/jest-preset-default": "6.0.0",
"@wordpress/keyboard-shortcuts": "1.4.0",
"@wordpress/keycodes": "2.12.0",
"@wordpress/media-utils": "1.10.0",
"@wordpress/notices": "2.3.0",
"@wordpress/npm-package-json-lint-config": "3.0.0",
"@wordpress/nux": "3.15.0",
"@wordpress/plugins": "2.15.0",
"@wordpress/primitives": "1.4.0",
"@wordpress/priority-queue": "1.6.0",
"@wordpress/redux-routine": "3.8.0",
"@wordpress/rich-text": "3.15.0",
"@wordpress/scripts": "9.0.0",
"@wordpress/server-side-render": "1.11.0",
"@wordpress/shortcode": "2.7.0",
"@wordpress/url": "2.14.0",
"@wordpress/viewport": "2.16.0",
"acorn": "^6.4.1",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.1.0",
Expand Down
Loading

0 comments on commit e816f74

Please sign in to comment.