Skip to content

Commit e866eb9

Browse files
authored
Merge pull request #4659 from dlabrecq/deps2
Dependency updates
2 parents ed308f3 + 4891625 commit e866eb9

File tree

36 files changed

+543
-293
lines changed

36 files changed

+543
-293
lines changed

apps/koku-ui-hccm/jest.config.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ const baseConfig = require('../../jest.config.base');
44
module.exports = {
55
...baseConfig,
66
roots: ['<rootDir>/src'],
7-
setupFiles: ['<rootDir>/test/testEnv.ts'],
7+
setupFiles: ['<rootDir>/test/testEnv.js'],
88
setupFilesAfterEnv: ['<rootDir>/test/jest.setup.js'],
9+
// Ensure no experimental SWC plugins break setup files
10+
transform: {
11+
'^.+\\.svg$': 'jest-transform-stub',
12+
'^.+\\.(ts|js)x?$': [
13+
'@swc/jest',
14+
{
15+
$schema: 'http://json.schemastore.org/swcrc',
16+
jsc: {
17+
parser: { jsx: true, syntax: 'typescript', tsx: true },
18+
transform: { react: { runtime: 'automatic' } },
19+
},
20+
},
21+
],
22+
},
923
};

apps/koku-ui-hccm/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"@patternfly/react-icons": "6.4.0",
5959
"@patternfly/react-table": "6.4.0",
6060
"@patternfly/react-tokens": "6.4.0",
61-
"@redhat-cloud-services/frontend-components": "^7.0.12",
62-
"@redhat-cloud-services/frontend-components-notifications": "^6.1.13",
61+
"@redhat-cloud-services/frontend-components": "^7.0.13",
62+
"@redhat-cloud-services/frontend-components-notifications": "^6.1.14",
6363
"@redhat-cloud-services/frontend-components-translations": "^4.0.16",
6464
"@redhat-cloud-services/frontend-components-utilities": "^7.0.9",
6565
"@redhat-cloud-services/rbac-client": "^4.2.5",

apps/koku-ui-hccm/src/api/export/exportUtils.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
jest.mock('./exportUtils', () => ({
2+
__esModule: true,
3+
runExport: jest.fn(),
4+
}));
15
import { waitFor } from '@testing-library/react';
26
import { ReportPathsType, ReportType } from 'api/reports/report';
37

48
import * as exportUtils from './exportUtils';
59

6-
jest.spyOn(exportUtils, 'runExport');
10+
// runExport is a mocked function via jest.mock above
711

812
test('runExport API request for AWS', async () => {
913
exportUtils.runExport(ReportPathsType.aws, ReportType.cost, '');

apps/koku-ui-hccm/src/api/forecasts/forecastUtils.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
jest.mock('./forecastUtils', () => ({
2+
__esModule: true,
3+
runForecast: jest.fn(),
4+
}));
15
import { waitFor } from '@testing-library/react';
26

37
import { ForecastPathsType, ForecastType } from './forecast';
48
import * as forecastUtils from './forecastUtils';
59

6-
jest.spyOn(forecastUtils, 'runForecast');
10+
// runForecast is a mocked function via jest.mock above
711

812
test('runForecast API request for AWS', async () => {
913
forecastUtils.runForecast(ForecastPathsType.aws, ForecastType.cost, '');

apps/koku-ui-hccm/src/api/reports/reportUtils.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
jest.mock('./reportUtils', () => ({
2+
__esModule: true,
3+
runReport: jest.fn(),
4+
}));
15
import { waitFor } from '@testing-library/react';
26

37
import { ReportPathsType, ReportType } from './report';
48
import * as reportUtils from './reportUtils';
59

6-
jest.spyOn(reportUtils, 'runReport');
10+
// runReport is a mocked function via jest.mock above
711

812
test('runReport API request for AWS', async () => {
913
reportUtils.runReport(ReportPathsType.aws, ReportType.cost, '');

apps/koku-ui-hccm/src/api/resources/resourceUtils.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
jest.mock('./resourceUtils', () => ({
2+
__esModule: true,
3+
isResourceTypeValid: jest.fn(() => true),
4+
runResource: jest.fn(),
5+
}));
16
import { waitFor } from '@testing-library/react';
27

38
import { ResourcePathsType, ResourceType } from './resource';
49
import * as resourceUtils from './resourceUtils';
510

6-
jest.spyOn(resourceUtils, 'isResourceTypeValid');
7-
jest.spyOn(resourceUtils, 'runResource');
11+
// isResourceTypeValid and runResource are mocked via jest.mock above
812

913
test('runResource API request for AWS', async () => {
1014
resourceUtils.runResource(ResourcePathsType.aws, ResourceType.account, '');

apps/koku-ui-hccm/src/api/tags/tagUtils.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
jest.mock('./tagUtils', () => ({
2+
__esModule: true,
3+
runTag: jest.fn(),
4+
}));
15
import { waitFor } from '@testing-library/react';
26

37
import { TagPathsType, TagType } from './tag';
48
import * as tagUtils from './tagUtils';
59

6-
jest.spyOn(tagUtils, 'runTag');
10+
// runTag is a mocked function via jest.mock above
711

812
test('runTag API request for AWS', async () => {
913
tagUtils.runTag(TagPathsType.aws, TagType.tag, '');

apps/koku-ui-hccm/src/store/accountSettings/accountSettings.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ const accountSettingsMock: AccountSettings = {
3030

3131
fetchAccountSettingsMock.mockReturnValue(Promise.resolve({ data: accountSettingsMock }));
3232

33-
jest.spyOn(selectors, 'selectAccountSettingsStatus');
34-
3533
test('default state', async () => {
3634
const store = createProdvidersStore();
3735
expect(selectors.selectAccountSettingsState(store.getState())).toMatchSnapshot();
@@ -44,7 +42,11 @@ test('fetch account settings success', async () => {
4442
expect(selectors.selectAccountSettingsStatus(store.getState(), AccountSettingsType.settings)).toBe(
4543
FetchStatus.inProgress
4644
);
47-
await waitFor(() => expect(selectors.selectAccountSettingsStatus).toHaveBeenCalled());
45+
await waitFor(() =>
46+
expect(selectors.selectAccountSettingsStatus(store.getState(), AccountSettingsType.settings)).toBe(
47+
FetchStatus.complete
48+
)
49+
);
4850
const finishedState = store.getState();
4951
expect(selectors.selectAccountSettingsStatus(finishedState, AccountSettingsType.settings)).toBe(FetchStatus.complete);
5052
});
@@ -58,7 +60,11 @@ test('fetch account settings failure', async () => {
5860
expect(selectors.selectAccountSettingsStatus(store.getState(), AccountSettingsType.settings)).toBe(
5961
FetchStatus.inProgress
6062
);
61-
await waitFor(() => expect(selectors.selectAccountSettingsStatus).toHaveBeenCalled());
63+
await waitFor(() =>
64+
expect(selectors.selectAccountSettingsStatus(store.getState(), AccountSettingsType.settings)).toBe(
65+
FetchStatus.complete
66+
)
67+
);
6268
const finishedState = store.getState();
6369
expect(selectors.selectAccountSettingsStatus(finishedState, AccountSettingsType.settings)).toBe(FetchStatus.complete);
6470
});

apps/koku-ui-hccm/src/store/costModels/store.test.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ const createCostModelsStore = createMockStoreCreator({
5050
[stateKey]: costModelsReducer,
5151
});
5252

53-
jest.spyOn(actions, 'deleteCostModel');
54-
jest.spyOn(actions, 'updateCostModel');
55-
jest.spyOn(selectors, 'status');
53+
// Avoid spying on ESM exports; assert via selectors and state
5654

5755
test('default state', async () => {
5856
const store = createCostModelsStore();
@@ -97,7 +95,7 @@ test('fetching cost models succeeded', async () => {
9795
expect(selectors.error(store.getState())).toEqual(null);
9896
store.dispatch(actions.fetchCostModels());
9997
expect(selectors.status(store.getState())).toBe(FetchStatus.inProgress);
100-
await waitFor(() => expect(selectors.status).toHaveBeenCalled());
98+
await waitFor(() => expect(selectors.status(store.getState())).toBe(FetchStatus.complete));
10199
expect(selectors.costModels(store.getState())).toEqual([costmodel1]);
102100
expect(selectors.error(store.getState())).toEqual(null);
103101
expect(selectors.status(store.getState())).toBe(FetchStatus.complete);
@@ -115,7 +113,7 @@ test('fetching cost models failed', async () => {
115113
expect(selectors.error(store.getState())).toEqual(null);
116114
store.dispatch(actions.fetchCostModels());
117115
expect(selectors.status(store.getState())).toBe(FetchStatus.inProgress);
118-
await waitFor(() => expect(selectors.status).toHaveBeenCalled());
116+
await waitFor(() => expect(selectors.status(store.getState())).toBe(FetchStatus.complete));
119117
expect(selectors.costModels(store.getState())).toEqual([]);
120118
expect(selectors.error(store.getState())).toEqual(error);
121119
expect(selectors.status(store.getState())).toBe(FetchStatus.complete);
@@ -149,7 +147,7 @@ test('updating a cost model succeeded', async () => {
149147
expect(selectors.updateError(store.getState())).toBe('');
150148
store.dispatch(actions.updateCostModel());
151149
expect(selectors.updateProcessing(store.getState())).toBe(true);
152-
await waitFor(() => expect(actions.updateCostModel).toHaveBeenCalled());
150+
await waitFor(() => expect(selectors.updateProcessing(store.getState())).toBe(false));
153151
expect(selectors.selected(store.getState())).toEqual(updated_costmodel1);
154152
expect(selectors.updateError(store.getState())).toEqual('');
155153
expect(selectors.updateProcessing(store.getState())).toBe(false);
@@ -164,7 +162,7 @@ test('updating a cost model failed', async () => {
164162
expect(selectors.updateProcessing(store.getState())).toBe(false);
165163
store.dispatch(actions.updateCostModel());
166164
expect(selectors.updateProcessing(store.getState())).toBe(true);
167-
await waitFor(() => expect(actions.updateCostModel).toHaveBeenCalled());
165+
await waitFor(() => expect(selectors.updateProcessing(store.getState())).toBe(false));
168166
expect(selectors.selected(store.getState())).toEqual(costmodel1);
169167
expect(selectors.updateError(store.getState())).toEqual('oops');
170168
expect(selectors.updateProcessing(store.getState())).toBe(false);
@@ -179,7 +177,7 @@ test('deleting a cost model succeeded', async () => {
179177
store.dispatch(actions.deleteCostModel('11123', 'deleteCostModel'));
180178
expect(selectors.deleteProcessing(store.getState())).toBe(true);
181179
expect(selectors.isDialogOpen(store.getState())('costmodel').deleteCostModel).toBe(true);
182-
await waitFor(() => expect(actions.deleteCostModel).toHaveBeenCalled());
180+
await waitFor(() => expect(selectors.deleteProcessing(store.getState())).toBe(false));
183181
expect(selectors.deleteError(store.getState())).toEqual('');
184182
expect(selectors.deleteProcessing(store.getState())).toBe(false);
185183
expect(selectors.isDialogOpen(store.getState())('costmodel').deleteCostModel).toBe(false);
@@ -194,7 +192,7 @@ test('deleting a cost model failed', async () => {
194192
expect(selectors.deleteProcessing(store.getState())).toBe(false);
195193
store.dispatch(actions.deleteCostModel('111', 'deleteCostModel'));
196194
expect(selectors.deleteProcessing(store.getState())).toBe(true);
197-
await waitFor(() => expect(actions.deleteCostModel).toHaveBeenCalled());
195+
await waitFor(() => expect(selectors.deleteProcessing(store.getState())).toBe(false));
198196
expect(selectors.deleteError(store.getState())).toEqual('oops');
199197
expect(selectors.deleteProcessing(store.getState())).toBe(false);
200198
expect(selectors.isDialogOpen(store.getState())('costmodel').deleteCostModel).toBe(true);

apps/koku-ui-hccm/src/store/export/export.test.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ const reportQueryString = 'reportQueryString';
3333
runExportMock.mockResolvedValue({ data: mockExport });
3434
global.Date.now = jest.fn(() => 12345);
3535

36-
jest.spyOn(actions, 'fetchExport');
37-
jest.spyOn(selectors, 'selectExportFetchStatus');
38-
3936
test('default state', () => {
4037
const store = createExportsStore();
4138
expect(selectors.selectExportState(store.getState())).toMatchSnapshot();
@@ -48,7 +45,11 @@ test('fetch export success', async () => {
4845
expect(selectors.selectExportFetchStatus(store.getState(), reportPathsType, reportType, reportQueryString)).toBe(
4946
FetchStatus.inProgress
5047
);
51-
await waitFor(() => expect(selectors.selectExportFetchStatus).toHaveBeenCalled());
48+
await waitFor(() =>
49+
expect(selectors.selectExportFetchStatus(store.getState(), reportPathsType, reportType, reportQueryString)).toBe(
50+
FetchStatus.complete
51+
)
52+
);
5253
const finishedState = store.getState();
5354
expect(selectors.selectExportFetchStatus(finishedState, reportPathsType, reportType, reportQueryString)).toBe(
5455
FetchStatus.complete
@@ -65,7 +66,11 @@ test('fetch export failure', async () => {
6566
expect(selectors.selectExportFetchStatus(store.getState(), reportPathsType, reportType, reportQueryString)).toBe(
6667
FetchStatus.inProgress
6768
);
68-
await waitFor(() => expect(selectors.selectExportFetchStatus).toHaveBeenCalled());
69+
await waitFor(() =>
70+
expect(selectors.selectExportFetchStatus(store.getState(), reportPathsType, reportType, reportQueryString)).toBe(
71+
FetchStatus.complete
72+
)
73+
);
6974
const finishedState = store.getState();
7075
expect(selectors.selectExportFetchStatus(finishedState, reportPathsType, reportType, reportQueryString)).toBe(
7176
FetchStatus.complete
@@ -83,7 +88,11 @@ test('does not export if the request is in progress', () => {
8388
test('export is not re-exported if it has not expired', async () => {
8489
const store = createExportsStore();
8590
store.dispatch(actions.fetchExport(reportPathsType, reportType, reportQueryString));
86-
await waitFor(() => expect(actions.fetchExport).toHaveBeenCalled());
91+
await waitFor(() =>
92+
expect(selectors.selectExportFetchStatus(store.getState(), reportPathsType, reportType, reportQueryString)).toBe(
93+
FetchStatus.complete
94+
)
95+
);
8796
store.dispatch(actions.fetchExport(reportPathsType, reportType, reportQueryString));
8897
expect(runExport).toHaveBeenCalledTimes(1);
8998
});

0 commit comments

Comments
 (0)