Skip to content

Commit 2a0af8a

Browse files
committed
Merge Resolved conflicts
1 parent d4ad0ba commit 2a0af8a

File tree

2 files changed

+64
-120
lines changed

2 files changed

+64
-120
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { fromJS } from "immutable";
2+
3+
import { mountedComponent, screen, stub } from "../../../../test-utils";
4+
import { listHeaders, lookups } from "../../../../test";
5+
import { ACTIONS } from "../../../permissions";
6+
7+
import NAMESPACE from "./namespace";
8+
import UserGroupsList from "./container";
9+
10+
describe("<UserGroupsList />", () => {
11+
let stubI18n = null;
12+
const dataLength = 30;
13+
const data = Array.from({ length: dataLength }, (_, i) => ({
14+
id: i + 1,
15+
unique_id: `usergroup-${i + 1}`,
16+
name: `User Group ${i + 1}`,
17+
description: `Test description ${i + 1}`
18+
}));
19+
20+
stubI18n = stub(window.I18n, "t").withArgs("messages.record_list.of").returns("of");
21+
const initialState = fromJS({
22+
records: {
23+
user_groups: {
24+
data,
25+
metadata: { total: dataLength, per: 20, page: 1 },
26+
loading: false,
27+
errors: false
28+
}
29+
},
30+
user: {
31+
permissions: {
32+
users: [ACTIONS.MANAGE]
33+
},
34+
listHeaders: {
35+
user_groups: listHeaders(NAMESPACE)
36+
}
37+
},
38+
forms: {
39+
options: {
40+
lookups: lookups()
41+
}
42+
}
43+
});
44+
45+
it("should render record list table", () => {
46+
mountedComponent(<UserGroupsList />, initialState, [`/admin/${NAMESPACE}`])
47+
expect(screen.getByRole('grid')).toBeInTheDocument();
48+
});
49+
50+
it("should trigger a sort action when a header is clicked", () => {
51+
mountedComponent(<UserGroupsList />, initialState, [`/admin/${NAMESPACE}`])
52+
expect(screen.getByTestId('headcol-0')).toBeInTheDocument();
53+
});
54+
55+
it("should trigger a valid action with next page when clicking next page", () => {
56+
mountedComponent(<UserGroupsList />, initialState, [`/admin/${NAMESPACE}`])
57+
expect(screen.getByText(`1-20 of ${dataLength}`)).toBeInTheDocument();
58+
});
59+
60+
it("should set the filters when apply is clicked", () => {
61+
mountedComponent(<UserGroupsList />, initialState, [`/admin/${NAMESPACE}`])
62+
expect(screen.getAllByRole('button')).toHaveLength(16);
63+
})
64+
});

app/javascript/components/pages/admin/user-groups-list/container.unit.test.js

-120
This file was deleted.

0 commit comments

Comments
 (0)