Skip to content

Commit b0cfa55

Browse files
authored
"Setup Deployment" clusters listing page size issue fix (#67)
1 parent 1635399 commit b0cfa55

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

apps/cluster-orch/src/components/organism/ClusterList/ClusterList.cy.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,23 @@ describe("<ClusterList/>", () => {
3535
cy.get(".spark-pagination-list").contains(2).click();
3636
pom.waitForApis();
3737
});
38+
39+
it("changes page size when onChangePageSize is called", () => {
40+
// Intercept API call with different page size
41+
pom.interceptApis([pom.api.clusterMockedWithPageSize]);
42+
pom.table.root
43+
.find("[data-testid='pagination-control-pagesize']")
44+
.find(".spark-icon-chevron-down")
45+
.click();
46+
cy.get(".spark-popover .spark-list-item").contains("100").click();
47+
pom.waitForApis();
48+
49+
// Check api response
50+
cy.get(`@${pom.api.clusterMockedWithPageSize}`)
51+
.its("request.url")
52+
.then((url: string) => {
53+
const match = url.match(/pageSize=100/);
54+
return expect(match && match.length > 0).to.be.true;
55+
});
56+
});
3857
});

apps/cluster-orch/src/components/organism/ClusterList/ClusterList.pom.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ type ApiAliases =
1616
| "clusterMocked"
1717
| "cluster500"
1818
| "clusterMockedWithFilter"
19-
| "clusterMockedWithOffset";
19+
| "clusterMockedWithOffset"
20+
| "clusterMockedWithPageSize";
2021

2122
const route = "**/v2/**/clusters**";
2223

@@ -51,6 +52,14 @@ const endpoints: CyApiDetails<
5152
totalElements: 20,
5253
},
5354
},
55+
clusterMockedWithPageSize: {
56+
route: `${route}pageSize=100&offset=0*`,
57+
statusCode: 200,
58+
response: {
59+
clusters: [clusterInfo1, clusterInfo2],
60+
totalElements: 100,
61+
},
62+
},
5463
cluster500: {
5564
route,
5665
statusCode: 500,

apps/cluster-orch/src/components/organism/ClusterList/ClusterList.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ const ClusterList = ({
155155
return prev;
156156
});
157157
}}
158+
onChangePageSize={(pageSize: number) => {
159+
setSearchParams((prev) => {
160+
prev.set("pageSize", pageSize.toString());
161+
return prev;
162+
});
163+
}}
158164
// Selection feature
159165
canSelectRows={isForm}
160166
getRowId={(cluster) => cluster.name!}

0 commit comments

Comments
 (0)