@automattic/jetpack-shared-extension-utils 0.11.3 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.11.5] - 2023-09-13
9
+ ### Changed
10
+ - Updated package dependencies. [#33001]
11
+
12
+ ## [0.11.4] - 2023-09-04
13
+ ### Changed
14
+ - Updated package dependencies. [#32803]
15
+ - Updated package dependencies. [#32804]
16
+
17
+ ### Removed
18
+ - Remove unnecessary files from mirror repo and published package. [#32674]
19
+
8
20
  ## [0.11.3] - 2023-08-23
9
21
  ### Changed
10
22
  - Updated package dependencies. [#32605]
@@ -240,6 +252,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
240
252
  ### Changed
241
253
  - Core: prepare utility for release
242
254
 
255
+ [0.11.5]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.11.4...0.11.5
256
+ [0.11.4]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.11.3...0.11.4
243
257
  [0.11.3]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.11.2...0.11.3
244
258
  [0.11.2]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.11.1...0.11.2
245
259
  [0.11.1]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.11.0...0.11.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-shared-extension-utils",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "description": "Utility functions used by the block editor extensions",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/shared-extension-utils/#readme",
6
6
  "bugs": {
@@ -18,19 +18,19 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@automattic/jetpack-analytics": "^0.1.27",
21
- "@automattic/jetpack-components": "^0.41.1",
22
- "@automattic/jetpack-connection": "^0.29.8",
23
- "@wordpress/api-fetch": "6.35.0",
24
- "@wordpress/compose": "6.15.0",
25
- "@wordpress/element": "5.15.0",
26
- "@wordpress/i18n": "4.38.0",
27
- "@wordpress/plugins": "6.6.0",
28
- "@wordpress/url": "3.39.0",
21
+ "@automattic/jetpack-components": "^0.42.3",
22
+ "@automattic/jetpack-connection": "^0.29.10",
23
+ "@wordpress/api-fetch": "6.38.0",
24
+ "@wordpress/compose": "6.18.0",
25
+ "@wordpress/element": "5.18.0",
26
+ "@wordpress/i18n": "4.41.0",
27
+ "@wordpress/plugins": "6.9.0",
28
+ "@wordpress/url": "3.42.0",
29
29
  "lodash": "4.17.21"
30
30
  },
31
31
  "devDependencies": {
32
- "@babel/core": "7.22.9",
33
- "@babel/preset-react": "7.22.5",
32
+ "@babel/core": "7.22.17",
33
+ "@babel/preset-react": "7.22.15",
34
34
  "babel-jest": "29.3.1",
35
35
  "jest": "29.3.1",
36
36
  "jest-environment-jsdom": "29.3.1",
@@ -38,11 +38,11 @@
38
38
  "react-dom": "18.2.0",
39
39
  "jetpack-js-tools": "workspace:*",
40
40
  "@automattic/jetpack-webpack-config": "workspace:*",
41
- "@wordpress/babel-plugin-import-jsx-pragma": "4.21.0",
41
+ "@wordpress/babel-plugin-import-jsx-pragma": "4.24.0",
42
42
  "@testing-library/dom": "8.19.1",
43
43
  "@testing-library/react": "13.4.0",
44
44
  "@testing-library/user-event": "14.4.3",
45
- "@babel/plugin-transform-react-jsx": "7.22.5"
45
+ "@babel/plugin-transform-react-jsx": "7.22.15"
46
46
  },
47
47
  "exports": {
48
48
  ".": "./index.js"
package/.gitattributes DELETED
@@ -1,7 +0,0 @@
1
- # Files not needed to be distributed in the package.
2
- .gitattributes export-ignore
3
- node_modules export-ignore
4
-
5
- # Files to exclude from the mirror repo
6
- /changelog/** production-exclude
7
- /.eslintrc.cjs production-exclude
package/jest-globals.js DELETED
@@ -1,12 +0,0 @@
1
- if ( ! window.matchMedia ) {
2
- window.matchMedia = query => ( {
3
- matches: false,
4
- media: query,
5
- onchange: null,
6
- addListener: jest.fn(), // deprecated
7
- removeListener: jest.fn(), // deprecated
8
- addEventListener: jest.fn(),
9
- removeEventListener: jest.fn(),
10
- dispatchEvent: jest.fn(),
11
- } );
12
- }
package/jest.config.js DELETED
@@ -1,13 +0,0 @@
1
- const baseConfig = require( 'jetpack-js-tools/jest/config.base.js' );
2
-
3
- module.exports = {
4
- ...baseConfig,
5
- roots: [ '<rootDir>/src' ],
6
- setupFiles: [ ...baseConfig.setupFiles, '<rootDir>/jest-globals.js' ],
7
- transform: {
8
- ...baseConfig.transform,
9
- '\\.[jt]sx?$': require( 'jetpack-js-tools/jest/babel-jest-config-factory.js' )(
10
- require.resolve
11
- ),
12
- },
13
- };
@@ -1,153 +0,0 @@
1
- import { renderHook, waitFor, act } from '@testing-library/react';
2
- import { isSimpleSite } from '../../../site-type-utils';
3
- import useModuleStatus from '../index';
4
-
5
- jest.mock( '../../../site-type-utils' );
6
-
7
- describe( 'useModuleStatus hook', () => {
8
- const originalFetch = window.fetch;
9
-
10
- beforeEach( () => {
11
- isSimpleSite.mockReset();
12
- // eslint-disable-next-line jest/prefer-spy-on -- Nothing to spy on.
13
- window.fetch = jest.fn();
14
- } );
15
-
16
- afterEach( () => {
17
- window.fetch = originalFetch;
18
- } );
19
- test( 'should not try to fetch modules if no name is provided', () => {
20
- const { result } = renderHook( name => useModuleStatus( name ), {
21
- initialProps: '',
22
- } );
23
- const { changeStatus, ...otherProps } = result.current;
24
-
25
- expect( otherProps ).toStrictEqual( {
26
- isLoadingModules: false,
27
- isChangingStatus: false,
28
- isModuleActive: false,
29
- } );
30
- } );
31
-
32
- test( 'jetpack module is active on not simple sites.', async () => {
33
- isSimpleSite.mockReturnValueOnce( false );
34
-
35
- window.fetch.mockReturnValueOnce(
36
- Promise.resolve( {
37
- status: 200,
38
- json: () =>
39
- Promise.resolve( {
40
- subscriptions: {
41
- activated: true,
42
- },
43
- } ),
44
- } )
45
- );
46
-
47
- const { result } = renderHook( name => useModuleStatus( name ), {
48
- initialProps: 'subscriptions',
49
- } );
50
-
51
- expect( result.current.isModuleActive ).toBe( false );
52
- await waitFor( async () => expect( result.current.isModuleActive ).toBe( true ) );
53
-
54
- expect( window.fetch ).toHaveBeenCalledWith(
55
- '/jetpack/v4/module/all?_locale=user',
56
- expect.anything()
57
- );
58
-
59
- const { changeStatus, ...otherProps } = result.current;
60
-
61
- expect( otherProps ).toStrictEqual( {
62
- isLoadingModules: false,
63
- isChangingStatus: false,
64
- isModuleActive: true,
65
- } );
66
- } );
67
-
68
- test( 'jetpack module is active on simple sites.', async () => {
69
- isSimpleSite.mockReturnValueOnce( true );
70
-
71
- window.fetch.mockReturnValueOnce(
72
- Promise.resolve( {
73
- status: 200,
74
- json: () =>
75
- Promise.resolve( {
76
- subscriptions: {
77
- activated: false,
78
- },
79
- } ),
80
- } )
81
- );
82
-
83
- const { result } = renderHook( name => useModuleStatus( name ), {
84
- initialProps: 'subscriptions',
85
- } );
86
-
87
- expect( result.current.isModuleActive ).toBe( false );
88
- await waitFor( async () => expect( result.current.isModuleActive ).toBe( true ) );
89
- expect( window.fetch ).not.toHaveBeenCalled();
90
-
91
- const { changeStatus, ...otherProps } = result.current;
92
-
93
- expect( otherProps ).toStrictEqual( {
94
- isLoadingModules: false,
95
- isChangingStatus: false,
96
- isModuleActive: true,
97
- } );
98
- } );
99
-
100
- test( 'change jetpack module status', async () => {
101
- isSimpleSite.mockReturnValueOnce( false );
102
-
103
- window.fetch.mockReturnValueOnce(
104
- Promise.resolve( {
105
- status: 200,
106
- json: () =>
107
- Promise.resolve( {
108
- subscriptions: {
109
- activated: true,
110
- },
111
- } ),
112
- } )
113
- );
114
-
115
- const { result } = renderHook( name => useModuleStatus( name ), {
116
- initialProps: 'subscriptions',
117
- } );
118
-
119
- await waitFor( async () => expect( result.current.isModuleActive ).toBe( true ) );
120
- expect( window.fetch ).toHaveBeenCalledWith(
121
- '/jetpack/v4/module/all?_locale=user',
122
- expect.anything()
123
- );
124
- window.fetch.mockReset();
125
-
126
- window.fetch.mockReturnValueOnce(
127
- Promise.resolve( {
128
- status: 200,
129
- json: () => Promise.resolve( {} ),
130
- } )
131
- );
132
-
133
- act( () => {
134
- result.current.changeStatus( false );
135
- } );
136
-
137
- expect( result.current.isChangingStatus ).toBe( true );
138
- expect( result.current.isModuleActive ).toBe( true );
139
-
140
- await waitFor( async () => expect( result.current.isChangingStatus ).toBe( false ) );
141
- expect( result.current.isModuleActive ).toBe( false );
142
-
143
- Promise.resolve( {
144
- status: 200,
145
- json: () => Promise.resolve( {} ),
146
- } );
147
-
148
- expect( window.fetch ).toHaveBeenCalledWith(
149
- '/jetpack/v4/module/subscriptions/active?_locale=user',
150
- expect.anything()
151
- );
152
- } );
153
- } );