Skip to content

Commit 1473ef9

Browse files
committed
Integration test fix
1 parent 6b2912b commit 1473ef9

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

frontend/packages/integration-tests-cypress/tests/crud/resource-crud.cy.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ describe('Kubernetes resource CRUD operations', () => {
106106
'BuildConfig',
107107
]);
108108

109+
const dataViewResources = new Set(['HorizontalPodAutoscaler']);
110+
109111
testObjs.forEach((testObj, resource) => {
110112
const {
111113
kind,
@@ -120,6 +122,7 @@ describe('Kubernetes resource CRUD operations', () => {
120122
}
121123
describe(kind, () => {
122124
const name = `${testName}-${_.kebabCase(kind)}`;
125+
const isDataViewResource = dataViewResources.has(kind);
123126

124127
it(`creates the resource instance`, () => {
125128
cy.visit(
@@ -215,7 +218,11 @@ describe('Kubernetes resource CRUD operations', () => {
215218
// should not have a namespace dropdown for non-namespaced objects');
216219
projectDropdown.shouldNotExist();
217220
}
218-
listPage.rows.shouldBeLoaded();
221+
if (isDataViewResource) {
222+
listPage.dvRows.shouldBeLoaded();
223+
} else {
224+
listPage.rows.shouldBeLoaded();
225+
}
219226
cy.testA11y(`List page for ${kind}: ${name}`);
220227
cy.testI18n([ListPageSelector.tableColumnHeaders], ['item-create']);
221228
});
@@ -227,7 +234,11 @@ describe('Kubernetes resource CRUD operations', () => {
227234
}?kind=${kind}&q=${testLabel}%3d${testName}&name=${name}`,
228235
);
229236

230-
listPage.rows.shouldExist(name);
237+
if (isDataViewResource) {
238+
listPage.dvRows.shouldExist(name);
239+
} else {
240+
listPage.rows.shouldExist(name);
241+
}
231242
cy.testA11y(`Search page for ${kind}: ${name}`);
232243

233244
// link to to details page
@@ -242,7 +253,11 @@ describe('Kubernetes resource CRUD operations', () => {
242253
namespaced ? `ns/${testName}` : 'all-namespaces'
243254
}?kind=${kind}&q=${testLabel}%3d${testName}&name=${name}`,
244255
);
245-
listPage.rows.clickKebabAction(name, editKind(kind, humanizeKind));
256+
if (isDataViewResource) {
257+
listPage.dvRows.clickKebabAction(name, editKind(kind, humanizeKind));
258+
} else {
259+
listPage.rows.clickKebabAction(name, editKind(kind, humanizeKind));
260+
}
246261
if (!skipYamlReloadTest) {
247262
yamlEditor.isLoaded();
248263
yamlEditor.clickReloadButton();
@@ -254,9 +269,15 @@ describe('Kubernetes resource CRUD operations', () => {
254269

255270
it(`deletes the resource instance`, () => {
256271
cy.visit(`${namespaced ? `/k8s/ns/${testName}` : '/k8s/cluster'}/${resource}`);
257-
listPage.filter.byName(name);
258-
listPage.rows.countShouldBe(1);
259-
listPage.rows.clickKebabAction(name, deleteKind(kind, humanizeKind));
272+
if (isDataViewResource) {
273+
listPage.dvFilter.byName(name);
274+
listPage.dvRows.countShouldBe(name, 1);
275+
listPage.dvRows.clickKebabAction(name, deleteKind(kind, humanizeKind));
276+
} else {
277+
listPage.filter.byName(name);
278+
listPage.rows.countShouldBe(1);
279+
listPage.rows.clickKebabAction(name, deleteKind(kind, humanizeKind));
280+
}
260281
modal.shouldBeOpened();
261282
modal.submit();
262283
modal.shouldBeClosed();

frontend/packages/integration-tests-cypress/views/list-page.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export const listPage = {
5656
cy.get('@filterDropdownToggleButton').click();
5757
},
5858
},
59+
dvFilter: {
60+
byName: (name: string) => {
61+
cy.get('[aria-label="Name filter"]').clear().type(name); // this is not a great selector, but we're limited by data view
62+
},
63+
},
5964
rows: {
6065
getFirstElementName: () => cy.get('[data-test-rows="resource-row"] a').first(),
6166
shouldBeLoaded: () => {
@@ -113,6 +118,14 @@ export const listPage = {
113118
});
114119
cy.byTestActionID(actionName).click();
115120
},
121+
shouldExist: (resourceName: string) => {
122+
cy.get(`[data-test="data-view-cell-${resourceName}-name"]`)
123+
.contains(resourceName)
124+
.should('exist');
125+
},
126+
countShouldBe: (resourceName: string, count: number) => {
127+
cy.get(`[data-test="data-view-cell-${resourceName}-name"]`).should('have.length', count);
128+
},
116129
},
117130
};
118131

0 commit comments

Comments
 (0)