@remit/web-client 0.0.258 → 0.0.259
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/web-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.259",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
|
|
6
6
|
"exports": {
|
|
@@ -19,9 +19,7 @@ import assert from "node:assert/strict";
|
|
|
19
19
|
import { afterEach, describe, it } from "node:test";
|
|
20
20
|
import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";
|
|
21
21
|
import { createElement } from "react";
|
|
22
|
-
import { ApiError } from "../../lib/api";
|
|
23
22
|
import "../../lib/client";
|
|
24
|
-
import { shouldEscalate, softErrorStatuses } from "../../lib/error-classifier";
|
|
25
23
|
import { __resetFatalError, getCurrentFatalError } from "../../lib/fatal-error";
|
|
26
24
|
import {
|
|
27
25
|
handleMutationCacheError,
|
|
@@ -196,28 +194,18 @@ describe("ConfigImportWizard — an instance that is not empty", () => {
|
|
|
196
194
|
|
|
197
195
|
/**
|
|
198
196
|
* The other half of reaching that screen: the refusal must not also take the
|
|
199
|
-
* app to the fatal page over it.
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* and so hold two client instances — the error interceptor registers on one
|
|
204
|
-
* and the request goes through the other, which never happens under Vite,
|
|
205
|
-
* where both specifiers resolve to the same module.
|
|
197
|
+
* app to the fatal page over it. Driven through the wizard, so it holds the
|
|
198
|
+
* whole chain — the error interceptor stamping the status on the thrown
|
|
199
|
+
* `ApiError`, and the mutation's meta telling `shouldEscalate` to leave 409
|
|
200
|
+
* to the caller.
|
|
206
201
|
*/
|
|
207
|
-
it("keeps the 409 off the fatal page,
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
assert.equal(
|
|
214
|
-
shouldEscalate(new ApiError("signed out", 401, {}), meta, "user"),
|
|
215
|
-
true,
|
|
216
|
-
);
|
|
217
|
-
assert.equal(
|
|
218
|
-
shouldEscalate(new ApiError("broken", 500, {}), meta, "user"),
|
|
219
|
-
true,
|
|
220
|
-
);
|
|
202
|
+
it("keeps the 409 off the fatal page", async () => {
|
|
203
|
+
const dom = start({ onImport: conflicted });
|
|
204
|
+
await pickFile(dom, "config.json", CONFIG);
|
|
205
|
+
dom.click(checkButton(dom));
|
|
206
|
+
await dom.flush();
|
|
207
|
+
|
|
208
|
+
assert.equal(getCurrentFatalError(), null);
|
|
221
209
|
});
|
|
222
210
|
|
|
223
211
|
it("does not record an import when the reader aborts the 409", async () => {
|
package/src/lib/client.test.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { afterEach, describe, it } from "node:test";
|
|
3
|
+
import { trashOperationsEmptyTrashMutation } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
3
4
|
import { trashOperationsEmptyTrash } from "@remit/api-http-client/sdk.gen.ts";
|
|
5
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
6
|
+
import { getRuntimeConfig } from "../runtime-config";
|
|
4
7
|
import { type HttpMock, mockFetch } from "../test-support/http";
|
|
5
8
|
import { ApiError } from "./api";
|
|
6
9
|
import "./client";
|
|
@@ -66,3 +69,46 @@ describe("the error interceptor", () => {
|
|
|
66
69
|
assert.equal(error.message, "Request failed with status 503");
|
|
67
70
|
});
|
|
68
71
|
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `client.ts` reaches the generated client as `@remit/api-http-client/client.gen.ts`
|
|
75
|
+
* while the generated code reaches it as `./client.gen.js`. Both must land on
|
|
76
|
+
* one module: two would leave every generated call on the generated default
|
|
77
|
+
* base URL and outside the error interceptor, so a 409 would arrive with no
|
|
78
|
+
* status and the fatal-error classifier would escalate it. Vite dedupes; this
|
|
79
|
+
* pins the node test loader, where the flow tests run.
|
|
80
|
+
*/
|
|
81
|
+
describe("the client the generated code calls through", () => {
|
|
82
|
+
const emptyViaQueryLayer = (): Promise<unknown> => {
|
|
83
|
+
const { mutationFn } = trashOperationsEmptyTrashMutation();
|
|
84
|
+
assert.ok(mutationFn);
|
|
85
|
+
return mutationFn(
|
|
86
|
+
{ path: { accountId: "acc-1" } },
|
|
87
|
+
{ client: new QueryClient(), meta: undefined },
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
it("is the instance client.ts configured, for the SDK and the query layer", async () => {
|
|
92
|
+
answer(200, {});
|
|
93
|
+
|
|
94
|
+
await empty();
|
|
95
|
+
await emptyViaQueryLayer();
|
|
96
|
+
|
|
97
|
+
const sent = http?.calls.map((call) => call.url) ?? [];
|
|
98
|
+
assert.equal(sent.length, 2);
|
|
99
|
+
const base = `${getRuntimeConfig().apiUrl}/accounts/acc-1/trash/empty`;
|
|
100
|
+
assert.deepEqual(sent, [base, base]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("carries the status on a query-layer failure too", async () => {
|
|
104
|
+
answer(409, { code: "config_not_empty", message: "already configured" });
|
|
105
|
+
|
|
106
|
+
const error = await emptyViaQueryLayer().then(
|
|
107
|
+
() => undefined,
|
|
108
|
+
(reason: unknown) => reason,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
assert.ok(error instanceof ApiError);
|
|
112
|
+
assert.equal(error.status, 409);
|
|
113
|
+
});
|
|
114
|
+
});
|