Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c87ef77
fix: add missing file remove calls from inventory popup
tomrndom Jul 1, 2026
c751cb5
fix: add managed form item image remove
tomrndom Jul 9, 2026
60bc616
fix: add catchs, clean code, new action
tomrndom Jul 9, 2026
56ca2af
fix: clean blank space
tomrndom Jul 9, 2026
95eb033
fix: remove undefined function
tomrndom Aug 1, 2026
1cbbf74
fix: adjust image delete with current popup structure
tomrndom Aug 1, 2026
d14330b
fix: adjust reducer, pass currentItem id on remove image
tomrndom Aug 3, 2026
0345ee9
fix: add unit tests, add case for SPONSOR_FORM_ITEM_FILE_DELETED
tomrndom Aug 4, 2026
28b9ed5
fix: reuse deleteItem code, adjust reducer, fix bug with double image…
tomrndom Aug 4, 2026
0047fd1
fix: add catch for no images on reducer delete
tomrndom Aug 4, 2026
ce8df2d
test: add failing coverage for RECEIVE_SPONSOR_FORM_ITEM dropping fil…
smarcet Aug 6, 2026
d5a4f43
fix: change reducer to fix mapping images, add guard on delete images…
tomrndom Aug 7, 2026
c72289f
fix: change image saving, remove from entity, and save after on .then…
tomrndom Aug 13, 2026
50da82f
fix: adjust action for new items, store on reducer like it comes from…
tomrndom Aug 19, 2026
99e0271
fix: adjust reducers on sponsor form item list and customized items t…
tomrndom Aug 19, 2026
da95302
fix: adjusting test to match the reducer adjustments
tomrndom Aug 20, 2026
aca490b
fix: add cases for image added, save managed item images after save, …
tomrndom Aug 20, 2026
d6da910
fix: adjust inventory remove image reducer, update tests
tomrndom Aug 20, 2026
7ca7b44
fix: adjust expand on images, and inline update, add case for sponsor…
tomrndom Aug 20, 2026
08b0920
fix: add test case for inline edit and images omission
tomrndom Aug 20, 2026
88e23fa
fix: expand images on save, return flag on delete images, reuse saveF…
tomrndom Aug 21, 2026
b49c185
fix: adjust test, add check on removeItem for sponsor form item to re…
tomrndom Aug 21, 2026
206897c
fix: move stopLoading into .finally, add catch on re fetch if image d…
tomrndom Aug 21, 2026
bf30b4c
fix: add tests to check stopLoading on actions
tomrndom Aug 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/actions/__tests__/form-template-item-actions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @jest-environment jsdom
*/
import configureStore from "redux-mock-store";
import thunk from "redux-thunk";
import flushPromises from "flush-promises";
import { getRequest } from "openstack-uicore-foundation/lib/utils/actions";
import { getFormTemplateItem } from "../form-template-item-actions";
import * as methods from "../../utils/methods";

jest.mock("openstack-uicore-foundation/lib/utils/actions", () => ({
__esModule: true,
...jest.requireActual("openstack-uicore-foundation/lib/utils/actions"),
getRequest: jest.fn()
}));

describe("getFormTemplateItem", () => {
const middlewares = [thunk];
const mockStore = configureStore(middlewares);

beforeEach(() => {
jest.spyOn(methods, "getAccessTokenSafely").mockReturnValue("TOKEN");
});

afterEach(() => {
jest.restoreAllMocks();
});

it("still dispatches STOP_LOADING when the request fails", async () => {
getRequest.mockImplementation(
() => () => () => Promise.reject(new Error("API error"))
);

const store = mockStore({});

await store.dispatch(getFormTemplateItem(123, 1)).catch(() => {});
await flushPromises();

const actionTypes = store.getActions().map((a) => a.type);
expect(actionTypes).toContain("STOP_LOADING");
});
});
42 changes: 42 additions & 0 deletions src/actions/__tests__/inventory-item-actions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @jest-environment jsdom
*/
import configureStore from "redux-mock-store";
import thunk from "redux-thunk";
import flushPromises from "flush-promises";
import { getRequest } from "openstack-uicore-foundation/lib/utils/actions";
import { getInventoryItem } from "../inventory-item-actions";
import * as methods from "../../utils/methods";

jest.mock("openstack-uicore-foundation/lib/utils/actions", () => ({
__esModule: true,
...jest.requireActual("openstack-uicore-foundation/lib/utils/actions"),
getRequest: jest.fn()
}));

describe("getInventoryItem", () => {
const middlewares = [thunk];
const mockStore = configureStore(middlewares);

beforeEach(() => {
jest.spyOn(methods, "getAccessTokenSafely").mockReturnValue("TOKEN");
});

afterEach(() => {
jest.restoreAllMocks();
});

it("still dispatches STOP_LOADING when the request fails", async () => {
getRequest.mockImplementation(
() => () => () => Promise.reject(new Error("API error"))
);

const store = mockStore({});

await store.dispatch(getInventoryItem(1)).catch(() => {});
await flushPromises();

const actionTypes = store.getActions().map((a) => a.type);
expect(actionTypes).toContain("STOP_LOADING");
});
});
43 changes: 43 additions & 0 deletions src/actions/__tests__/inventory-shared-actions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { deleteRequest } from "openstack-uicore-foundation/lib/utils/actions";
import { deleteFile } from "../inventory-shared-actions";
import * as methods from "../../utils/methods";

jest.mock("openstack-uicore-foundation/lib/utils/actions", () => ({
__esModule: true,
...jest.requireActual("openstack-uicore-foundation/lib/utils/actions"),
deleteRequest: jest.fn()
}));

describe("deleteFile", () => {
const dispatch = jest.fn();
const settings = {
url: "http://test-api/images",
deletedActionName: "SOME_FILE_DELETED"
};

beforeEach(() => {
jest.spyOn(methods, "getAccessTokenSafely").mockResolvedValue("TOKEN");
});

afterEach(() => {
jest.restoreAllMocks();
});

it("resolves true when the delete request succeeds", async () => {
deleteRequest.mockImplementation(() => () => () => Promise.resolve());

const result = await deleteFile(10, settings)(dispatch);

expect(result).toBe(true);
});

it("resolves false (without rejecting) when the delete request fails", async () => {
deleteRequest.mockImplementation(
() => () => () => Promise.reject(new Error("boom"))
);

const result = await deleteFile(10, settings)(dispatch);

expect(result).toBe(false);
});
});
Loading
Loading