@gopherium/react-auth 0.17.0 → 0.18.0
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/README.md +6 -0
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +20 -3
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -156,6 +156,12 @@ const list = useListView<View>(usersListDefaults({ perPage: settings?.pageSize }
|
|
|
156
156
|
components stylesheets, and `@gopherium/react-auth/wpds/style.css`,
|
|
157
157
|
which clips a long email under the name and sizes `RoleSelect` on a
|
|
158
158
|
phone.
|
|
159
|
+
- `/testing` loads by `import` only. `installTestEnvironment` puts
|
|
160
|
+
Node's `File` and `FormData` on the global, so under jsdom
|
|
161
|
+
`new FormData(form)`, which a React form action calls, and
|
|
162
|
+
`FileReader` on a `File` throw a `TypeError`, `XMLHttpRequest` sends
|
|
163
|
+
a form or a `File` as placeholder text, and a `File` does not mix
|
|
164
|
+
with a `Blob`.
|
|
159
165
|
- The account step loads zxcvbn, about 400 kB gzipped, as its own chunk
|
|
160
166
|
the first time it renders. Vite reports that chunk as larger than
|
|
161
167
|
500 kB.
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { createdAccount, firstAccountClosed, firstAccountCodeRefused, firstAccou
|
|
|
7
7
|
export { disabledOk, disabledRefused, resendDelivered, resendRefused, resendUndelivered, roleRefused, usersFailure, usersOk, } from './users.js';
|
|
8
8
|
export declare const server: import("msw/node").SetupServer;
|
|
9
9
|
/**
|
|
10
|
-
* Installs the msw server lifecycle and DOM cleanup as vitest hooks.
|
|
10
|
+
* Installs Node's file classes, plus the msw server lifecycle and DOM cleanup as vitest hooks.
|
|
11
11
|
*/
|
|
12
12
|
export declare function installTestEnvironment(): void;
|
|
13
13
|
/**
|
package/dist/testing/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { File as NodeFile } from 'node:buffer';
|
|
3
|
+
import { setTimeout as realTimeout } from 'node:timers';
|
|
2
4
|
import '@testing-library/jest-dom/vitest';
|
|
3
5
|
import { cleanup } from '@testing-library/react';
|
|
4
6
|
import { HttpResponse, http } from 'msw';
|
|
@@ -9,13 +11,28 @@ export { http, HttpResponse } from 'msw';
|
|
|
9
11
|
export { createdAccount, firstAccountClosed, firstAccountCodeRefused, firstAccountOk, firstAccountRateLimited, firstAccountStarting, setupCodeClosed, setupCodeOk, setupCodeRateLimited, setupCodeRefused, setupCodeStarting, setupStatus, } from './setup.js';
|
|
10
12
|
export { disabledOk, disabledRefused, resendDelivered, resendRefused, resendUndelivered, roleRefused, usersFailure, usersOk, } from './users.js';
|
|
11
13
|
export const server = setupServer();
|
|
14
|
+
/** NodeFormData is the FormData class Node's fetch sends a file from. */
|
|
15
|
+
const { constructor: NodeFormData } = await new Response(new URLSearchParams()).formData();
|
|
16
|
+
/** isNodeFile reports whether a value is one of Node's files. */
|
|
17
|
+
const isNodeFile = Function.prototype[Symbol.hasInstance].bind(NodeFile);
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
19
|
+
* Waits one event loop turn on the real clock.
|
|
20
|
+
* @returns A promise that settles after the turn.
|
|
21
|
+
*/
|
|
22
|
+
function realTurn() {
|
|
23
|
+
return new Promise((resolve) => realTimeout(resolve));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Installs Node's file classes, plus the msw server lifecycle and DOM cleanup as vitest hooks.
|
|
14
27
|
*/
|
|
15
28
|
export function installTestEnvironment() {
|
|
16
|
-
|
|
17
|
-
|
|
29
|
+
Object.defineProperty(File, Symbol.hasInstance, { value: isNodeFile });
|
|
30
|
+
Object.assign(globalThis, { File: NodeFile, FormData: NodeFormData });
|
|
31
|
+
beforeAll(() => server.listen({ onUnhandledFrame: 'error' }));
|
|
32
|
+
afterEach(async () => {
|
|
18
33
|
cleanup();
|
|
34
|
+
await realTurn();
|
|
35
|
+
await realTurn();
|
|
19
36
|
server.resetHandlers();
|
|
20
37
|
});
|
|
21
38
|
afterAll(() => server.close());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gopherium/react-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Session authentication for React apps backed by gouncer's authkit.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"@wordpress/icons": ">=18.0.0 <19.0.0",
|
|
65
65
|
"@wordpress/theme": ">=2.3.0 <3.0.0",
|
|
66
66
|
"@wordpress/ui": ">=0.24.0 <0.25.0",
|
|
67
|
-
"msw": "^
|
|
67
|
+
"msw": "^3.0.0",
|
|
68
68
|
"react": "^19.2.7",
|
|
69
|
-
"vitest": "^
|
|
69
|
+
"vitest": "^5.0.4"
|
|
70
70
|
},
|
|
71
71
|
"peerDependenciesMeta": {
|
|
72
72
|
"@gopherium/godmin": {
|
|
@@ -115,10 +115,11 @@
|
|
|
115
115
|
"@testing-library/react": "^16.3.2",
|
|
116
116
|
"@testing-library/user-event": "^14.6.1",
|
|
117
117
|
"@types/gettext-parser": "9.0.0",
|
|
118
|
+
"@types/node": "^26.1.1",
|
|
118
119
|
"@types/react": "^19.2.17",
|
|
119
120
|
"@types/zxcvbn": "4.4.5",
|
|
120
121
|
"@vitejs/plugin-react": "^6.0.3",
|
|
121
|
-
"@vitest/coverage-v8": "^5.0.
|
|
122
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
122
123
|
"@wordpress/a11y": "4.57.0",
|
|
123
124
|
"@wordpress/components": "42.0.0",
|
|
124
125
|
"@wordpress/dataviews": "20.0.0",
|
|
@@ -135,13 +136,13 @@
|
|
|
135
136
|
"gettext-extractor": "4.0.6",
|
|
136
137
|
"gettext-parser": "9.1.1",
|
|
137
138
|
"jsdom": "^30.1.2",
|
|
138
|
-
"msw": "^
|
|
139
|
+
"msw": "^3.0.3",
|
|
139
140
|
"oxlint": "^1.71.0",
|
|
140
141
|
"react": "^19.2.7",
|
|
141
142
|
"react-dom": "^19.2.7",
|
|
142
143
|
"typescript": "~6.0.2",
|
|
143
144
|
"typescript-eslint": "^8.46.4",
|
|
144
145
|
"vite": "^8.1.4",
|
|
145
|
-
"vitest": "^5.0.
|
|
146
|
+
"vitest": "^5.0.5"
|
|
146
147
|
}
|
|
147
148
|
}
|