Skip to content

Commit ec8e8de

Browse files
✨ feat(deepsource): fix async issues
1 parent 14f6cb6 commit ec8e8de

File tree

15 files changed

+174
-25
lines changed

15 files changed

+174
-25
lines changed

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
// stories: ['../**/*.stories.@(ts|tsx|js|jsx)'],
55
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
66
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration,
7-
webpackFinal: async (config, { configType }) => {
7+
webpackFinal: async (config) => {
88
const assetRule = config.module.rules.find(({ test }) => test.test(".svg"));
99
// exclude svg from the default storybook file-loader
1010
assetRule.exclude = /\.svg$/;

scripts/ci/check-file-segments.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ for (const fileName of files) {
3838
}
3939

4040
if (errors.length > 0) {
41-
console.error(`${errors.length} files not placed in the correct folders`);
42-
4341
console.error(errors.join(","));
4442

45-
process.exit(1);
43+
throw new Error(`${errors.length} files not placed in the correct folders`);
4644
}

src/__tests__/_/api/setups/_all.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const setupAllTestData = async (domains: DomainTypes[]) => {
3535
...portalTestData,
3636
];
3737

38-
createCacheService().purge();
38+
await createCacheService().purge();
3939

4040
await Promise.all(
4141
allTestData

src/__tests__/account/password.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ describe("pages/account/password", () => {
6969
"New Password"
7070
);
7171

72+
await closeAllToasts();
73+
7274
await userEvent.click(
7375
screen.getByRole("button", { name: "Update Password" })
7476
);

src/__tests__/admin/settings/data.spec.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ describe("pages/admin/settings/data", () => {
4646
expect(await getToastMessage()).toBe(
4747
"Metadata Columns Saved Successfully"
4848
);
49-
50-
await closeAllToasts();
5149
});
5250

53-
it("should display updated date values", async () => {
51+
it("should display updated metatacolumns values", async () => {
5452
render(
5553
<TestProviders>
5654
<GeneralDataSettings />
@@ -86,6 +84,8 @@ describe("pages/admin/settings/data", () => {
8684
</TestProviders>
8785
);
8886

87+
await closeAllToasts();
88+
8989
await userEvent.clear(screen.getByLabelText("Format"));
9090

9191
await userEvent.type(screen.getByLabelText("Format"), "yyyy MMM do");
@@ -127,6 +127,8 @@ describe("pages/admin/settings/data", () => {
127127
expect(await getToastMessage()).toBe(
128128
`Invalid Date FormatPlease go to https://date-fns.org/docs/format to see valid formats`
129129
);
130+
131+
await closeAllToasts();
130132
});
131133

132134
it("should show date format", async () => {

src/__tests__/api/integrations/storage/active.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("/api/integrations/actions/[key]/index", () => {
88
const currentStorageKeyValueStoreApiService =
99
createKeyValueDomainPersistenceService<string>("current-storage");
1010

11-
currentStorageKeyValueStoreApiService.clearItem();
11+
await currentStorageKeyValueStoreApiService.clearItem();
1212

1313
await setupAllTestData(["users", "credentials"]);
1414
});

src/__tests__/api/integrations/storage/credentials.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("/api/integrations/storage/[key]/credentials", () => {
1111
const currentStorageKeyValueStoreApiService =
1212
createKeyValueDomainPersistenceService<string>("current-storage");
1313

14-
currentStorageKeyValueStoreApiService.persistItem("s3");
14+
await currentStorageKeyValueStoreApiService.persistItem("s3");
1515

1616
await setupAllTestData(["users"]);
1717
await setupCredentialsTestData({

src/__tests__/api/integrations/storage/list.spec.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,60 @@ describe("/api/integrations/storage/list", () => {
5353
"key": "s3",
5454
"title": "AWS S3",
5555
},
56+
{
57+
"configurationSchema": {
58+
"accessKey": {
59+
"label": {
60+
"id": "5k6ZTK",
61+
"message": "Access Key",
62+
},
63+
"type": "text",
64+
"validations": [
65+
{
66+
"validationType": "required",
67+
},
68+
],
69+
},
70+
"endpoint": {
71+
"label": {
72+
"id": "FCKppt",
73+
"message": "Endpoint",
74+
},
75+
"type": "text",
76+
"validations": [
77+
{
78+
"validationType": "required",
79+
},
80+
],
81+
},
82+
"port": {
83+
"label": {
84+
"id": "hZ6znB",
85+
"message": "Port",
86+
},
87+
"type": "text",
88+
"validations": [
89+
{
90+
"validationType": "required",
91+
},
92+
],
93+
},
94+
"secretKey": {
95+
"label": {
96+
"id": "E7bgrN",
97+
"message": "Secret Key",
98+
},
99+
"type": "text",
100+
"validations": [
101+
{
102+
"validationType": "required",
103+
},
104+
],
105+
},
106+
},
107+
"key": "minio",
108+
"title": "Minio",
109+
},
56110
{
57111
"configurationSchema": {
58112
"apiKey": {

src/__tests__/integrations/variables__credentials.spec.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* eslint-disable prettier/prettier */
22

33
import { render, screen, waitFor, within } from "@testing-library/react";
4-
import userEvent from "@testing-library/user-event";
4+
import userEvent, {
5+
PointerEventsCheckLevel,
6+
} from "@testing-library/user-event";
57

68
import { AuthActions } from "@/frontend/hooks/auth/auth.actions";
79
import ManageVariables from "@/pages/admin/settings/variables";
@@ -301,18 +303,32 @@ describe("pages/integrations/variables => credentials", () => {
301303
)
302304
);
303305

304-
const dialog = await screen.findByRole("dialog");
306+
const dialog = await screen.findByRole(
307+
"dialog",
308+
{},
309+
{
310+
timeout: 10000,
311+
}
312+
);
305313

306314
expect(within(dialog).getByText("Create Secret")).toBeInTheDocument();
307315

308-
await userEvent.type(within(dialog).getByLabelText("Key"), "NEW_SECRET");
316+
await userEvent.type(within(dialog).getByLabelText("Key"), "NEW_SECRET", {
317+
pointerEventsCheck: PointerEventsCheckLevel.Never,
318+
});
309319
await userEvent.type(
310320
within(dialog).getByLabelText("Value"),
311-
"new secret"
321+
"new secret",
322+
{
323+
pointerEventsCheck: PointerEventsCheckLevel.Never,
324+
}
312325
);
313326

314327
await userEvent.click(
315-
within(dialog).getByRole("button", { name: "Create Secret" })
328+
within(dialog).getByRole("button", { name: "Create Secret" }),
329+
{
330+
pointerEventsCheck: PointerEventsCheckLevel.Never,
331+
}
316332
);
317333

318334
expect(await getToastMessage()).toBe("Secret Saved Successfully");
@@ -376,10 +392,17 @@ describe("pages/integrations/variables => credentials", () => {
376392

377393
expect(within(dialog).getByLabelText("Key")).toBeDisabled();
378394

379-
await userEvent.type(within(dialog).getByLabelText("Value"), "__updated");
395+
await userEvent.type(
396+
within(dialog).getByLabelText("Value"),
397+
"__updated",
398+
{
399+
pointerEventsCheck: PointerEventsCheckLevel.Never,
400+
}
401+
);
380402

381403
await userEvent.click(
382-
within(dialog).getByRole("button", { name: "Update Secret" })
404+
within(dialog).getByRole("button", { name: "Update Secret" }),
405+
{ pointerEventsCheck: PointerEventsCheckLevel.Never }
383406
);
384407

385408
expect(await getToastMessage()).toBe("Secret Saved Successfully");

src/backend/lib/request/validations/implementations/__tests__/authenticated-user.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const handler = requestHandler({
1010
});
1111

1212
describe("Request Validations => authenticatedUserValidationImpl", () => {
13-
beforeAll(() => {
14-
setupAllTestData(["users"]);
13+
beforeAll(async () => {
14+
await setupAllTestData(["users"]);
1515
});
1616

1717
it("should return authenticated user", async () => {

0 commit comments

Comments
 (0)