@uxland/primary-shell 7.46.14 → 7.46.16

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": "@uxland/primary-shell",
3
- "version": "7.46.14",
3
+ "version": "7.46.16",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -47,7 +47,7 @@
47
47
  "tslib": "^2.3.0",
48
48
  "uxl-quill": "^1.0.1",
49
49
  "vite": "^7.0.0",
50
- "@primaria/plugins-core": "1.0.21"
50
+ "@primaria/plugins-core": "1.0.23"
51
51
  },
52
52
  "scripts": {
53
53
  "serve": "vite",
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
3
  import { ActivityMonitorImpl } from "./activity-monitor";
3
4
 
@@ -63,5 +64,4 @@ describe("ActivityMonitor", () => {
63
64
 
64
65
  expect(monitor.getLastActivityTimestamp()).toBe(timestampBeforeStop);
65
66
  });
66
-
67
67
  });
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
3
  import { createEcapEventManager, LAST_WORKED_DIAGNOSTICS_KEY } from "./ecap-event-manager";
3
4
 
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import axios, { AxiosInstance } from "axios";
2
3
  import AxiosMockAdapter from "axios-mock-adapter";
3
4
  import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -14,7 +15,7 @@ const newAccessToken =
14
15
  "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJidFZxNnRMWGpmcXdzbm5MR2FXMXdhdU9McDNiTmY4bWZ3Rm1SZ0lBS2VJIn0.eyJleHAiOjE3NDI5MTAzNzgsImlhdCI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iIsInNlcnZpY2VfY29kZSI6IjVTMDg5IiwiZXBfY29kZSI6IjAyMDgiLCJpZGVudGlmaWVyIjpbeyJ0eXBlIjoiRE5JIiwidmFsdWUiOiI3MzI4ODIxOUEifSx7InR5cGUiOiJOVU1DT0wiLCJ2YWx1ZSI6IjIifV0sImFsdF9pZGVudGlmaWVyIjpbeyJ0eXBlIjoiTVBJIiwidmFsdWUiOiIwNjIxY2Y3ZC03ZDYzLTQ5ZWMtODAwNi04YzA1NjkyZWQzNzcifV19LCJjbGllbnRBZGRyZXNzIjoiMTAuNTMuMjU0LjE1MCIsImNsaWVudF9pZCI6ImV0Yy1jY2YtcHJlIn0.zPxoN5d8_uxdbxeH7ly9sQdlnDxNp8_eWDzNSzjzkUPsRVkLxgjQw_WcjZfns-LNgGr0FToS6uSDIC7uj2hPpKqD7HPWbI6UPa7g-43Jf9rh-KSOXEHJWhlASi2w0n3xQHFSxHDYBwhyXlvWQ_Tr1Vh37MroWmEL84fdwqhcfZHmD9Ek52EuRRrB-XkymCmN1ZvO2GPU04LbBvQxLVzdAaKRzr1cUqHTnsEdgRduyKShPcyth01L_X7m128SIwjJsa1lYxFE_DbSDKz8dPTsxoS1DgwRxeArrkMlIdTHyxmDRezZUGhamyLuWpXLDXJCFfrTUB8-j_JnVlILHeR6O";
15
16
 
16
17
  describe("HTTP Client", () => {
17
- let broker = createBroker();
18
+ const broker = createBroker();
18
19
  let tokenManager: TokenManager;
19
20
  let axiosInstance: AxiosInstance;
20
21
  let axiosMockInstance: AxiosMockAdapter;
@@ -43,9 +44,7 @@ describe("HTTP Client", () => {
43
44
  expect(response.data).toBe("success");
44
45
  expect(axiosMockInstance.history.get?.length).toBe(1);
45
46
  // @ts-ignore
46
- expect(axiosMockInstance.history.get?.[0]?.headers.Authorization).toBe(
47
- `Bearer ${access_token}`,
48
- );
47
+ expect(axiosMockInstance.history.get?.[0]?.headers.Authorization).toBe(`Bearer ${access_token}`);
49
48
  });
50
49
 
51
50
  it("should retry request with new token if failed with 401 after token refresh, and requests after that have new token", async () => {
@@ -71,12 +70,8 @@ describe("HTTP Client", () => {
71
70
  expect(response.status).toBe(200);
72
71
  expect(response.data).toBe("success");
73
72
  expect(axiosMockInstance.history.get?.length).toBe(3); // 3 Calls 2 for the first request (request and retry), 1 for the second request
74
- expect(axiosMockInstance.history.get?.[1]?.headers?.Authorization).toBe(
75
- "Bearer " + newAccessToken,
76
- );
77
- expect(axiosMockInstance.history.get?.[2]?.headers?.Authorization).toBe(
78
- "Bearer " + newAccessToken,
79
- );
73
+ expect(axiosMockInstance.history.get?.[1]?.headers?.Authorization).toBe(`Bearer ${newAccessToken}`);
74
+ expect(axiosMockInstance.history.get?.[2]?.headers?.Authorization).toBe(`Bearer ${newAccessToken}`);
80
75
  });
81
76
 
82
77
  it("should fail request if token refresh fails and publish an event", async () => {
@@ -86,9 +81,7 @@ describe("HTTP Client", () => {
86
81
  const brokerSpy = vi.spyOn(broker, "publish");
87
82
  axiosMockInstance.onGet("/api/clinical-course").replyOnce(401, "Unauthorized");
88
83
 
89
- await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow(
90
- "Request failed with status code 401",
91
- );
84
+ await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow("Request failed with status code 401");
92
85
 
93
86
  expect(axiosMockInstance.history.get?.length).toBe(1); // No retry happened
94
87
  expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.refreshTokenFailed, {});
@@ -121,9 +114,7 @@ describe("HTTP Client", () => {
121
114
  const brokerSpy = vi.spyOn(broker, "publish");
122
115
 
123
116
  // Perform the request
124
- await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow(
125
- "Mpid header is missing",
126
- );
117
+ await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow("Mpid header is missing");
127
118
  expect(brokerSpy).not.toHaveBeenCalled();
128
119
  });
129
120
 
@@ -133,9 +124,7 @@ describe("HTTP Client", () => {
133
124
  });
134
125
  const brokerSpy = vi.spyOn(broker, "publish");
135
126
  // Perform the request
136
- await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow(
137
- "Mpid header value is invalid",
138
- );
127
+ await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow("Mpid header value is invalid");
139
128
  expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.mpidHeaderInvalid, expect.any(Object));
140
129
  });
141
130
 
@@ -148,9 +137,7 @@ describe("HTTP Client", () => {
148
137
  expect(response.data).toBe("success");
149
138
  expect(axiosMockInstance.history.get?.length).toBe(1);
150
139
  // @ts-ignore
151
- expect(axiosMockInstance.history.get?.[0]?.headers.Authorization).toBe(
152
- `Bearer ${access_token}`,
153
- );
140
+ expect(axiosMockInstance.history.get?.[0]?.headers.Authorization).toBe(`Bearer ${access_token}`);
154
141
  });
155
142
 
156
143
  it("should retry request with new token if failed with 401 after token refresh, and requests after that have new token", async () => {
@@ -177,12 +164,8 @@ describe("HTTP Client", () => {
177
164
  expect(response.status).toBe(200);
178
165
  expect(response.data).toBe("success");
179
166
  expect(axiosMockInstance.history.get?.length).toBe(3); // 3 Calls 2 for the first request (request and retry), 1 for the second request
180
- expect(axiosMockInstance.history.get?.[1]?.headers?.Authorization).toBe(
181
- "Bearer " + newAccessToken,
182
- );
183
- expect(axiosMockInstance.history.get?.[2]?.headers?.Authorization).toBe(
184
- "Bearer " + newAccessToken,
185
- );
167
+ expect(axiosMockInstance.history.get?.[1]?.headers?.Authorization).toBe(`Bearer ${newAccessToken}`);
168
+ expect(axiosMockInstance.history.get?.[2]?.headers?.Authorization).toBe(`Bearer ${newAccessToken}`);
186
169
  });
187
170
 
188
171
  it("should fail request if token refresh fails and publish an event", async () => {
@@ -192,9 +175,7 @@ describe("HTTP Client", () => {
192
175
  const brokerSpy = vi.spyOn(broker, "publish");
193
176
  axiosMockInstance.onGet("/api/clinical-course").replyOnce(401, "Unauthorized");
194
177
 
195
- await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow(
196
- "Request failed with status code 401",
197
- );
178
+ await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow("Request failed with status code 401");
198
179
 
199
180
  expect(axiosMockInstance.history.get?.length).toBe(1); // No retry happened
200
181
  expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.refreshTokenFailed, {});
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
3
  import { PrimariaNotificationServiceImpl } from "./notification.service-impl";
3
4
 
@@ -15,7 +16,7 @@ describe("PrimariaNotificationServiceImpl", () => {
15
16
  vi.useRealTimers();
16
17
  });
17
18
 
18
- const assertToast = (expectedState: string, message: string, duration: number = 5000) => {
19
+ const assertToast = (expectedState: string, message: string, duration = 5000) => {
19
20
  const toast = document.querySelector("dss-toast") as HTMLElement;
20
21
  expect(toast).not.toBeNull();
21
22
  expect(toast.getAttribute("isshow")).toBe("true");
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
3
  import { createRegionManagerProxy } from "./region-manager";
3
4
  import { BROKER_EVENTS } from "../broker/broker-events";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
3
  import axios from "axios";
3
4
  import { BROKER_EVENTS } from "../broker/broker-events";
@@ -68,17 +69,13 @@ describe("TokenManager", () => {
68
69
  it("should throw error if tokens are already initialized", () => {
69
70
  const tokenManager = new TokenManagerImpl(mockBroker);
70
71
  tokenManager.setInitialTokens("manual_access", "manual_refresh");
71
- expect(() => tokenManager.setInitialTokens("another_access", "another_refresh")).toThrow(
72
- "Token already initialized",
73
- );
72
+ expect(() => tokenManager.setInitialTokens("another_access", "another_refresh")).toThrow("Token already initialized");
74
73
  });
75
74
 
76
75
  it("should throw error if tokens were already initialized from URL", () => {
77
76
  const tokenManager = new TokenManagerImpl(mockBroker);
78
77
  tokenManager.getToken();
79
- expect(() => tokenManager.setInitialTokens("manual_access", "manual_refresh")).toThrow(
80
- "Token already initialized",
81
- );
78
+ expect(() => tokenManager.setInitialTokens("manual_access", "manual_refresh")).toThrow("Token already initialized");
82
79
  });
83
80
  });
84
81