Skip to content

Commit

Permalink
e2e test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed Nov 22, 2024
1 parent 990dbb5 commit 41cc819
Show file tree
Hide file tree
Showing 102 changed files with 370 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class ClusterStorageModal extends Modal {
.findByRole('button', { name: 'Typeahead menu toggle', hidden: true });
}

findWorkbenchConnectionOption(name: string) {
return cy.get('#connected-notebook-select').findByText(name);
}

findMountField() {
return this.find().findByTestId('mount-path-folder-value');
}
Expand Down Expand Up @@ -127,6 +131,10 @@ class ClusterStorageModal extends Modal {
return this.find().findByTestId('storage-classes-selector');
}

findStorageClassOption(name: string) {
return cy.get('#storage-classes-selector').findByText(name);
}

findStorageClassDeprecatedWarning() {
return this.find().findByTestId('deprecated-storage-warning');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Pagination {
}

selectToggleOption(name: string) {
return this.findMenuToggleButton().parents().findByRole('menuitem', { name }).click();
return this.findMenuToggleButton().parents().parents().findByRole('menuitem', { name }).click();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export class TableRow extends Contextual<HTMLTableRowElement> {
return this.find().findKebabAction(name);
}

findKebabActionByMenuId(name: string, menuId: string): Cypress.Chainable<JQuery<HTMLElement>> {
return this.find().findKebabActionByMenuId(name, menuId);
}

findKebab(): Cypress.Chainable<JQuery<HTMLElement>> {
return this.find().findKebab();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class ConnectionTypesPage {
}

findEmptyFilterResults() {
return cy.findByTestId('no-result-found-title');
return cy.findByTestId('dashboard-empty-table-state');
}

findSortButton(name: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ModelServingGlobal {
}

findEmptyResults() {
return cy.findByTestId('no-result-found-title');
return cy.findByTestId('dashboard-empty-table-state');
}

findSortButton(name: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NotebookImageSettings {
}

findEmptyResults() {
return cy.findByTestId('no-result-found-title');
return cy.findByTestId('dashboard-empty-table-state');
}

private findTable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CompareRunsRocCurve extends Contextual<HTMLElement> {
}

findRocCurveTableEmptyState() {
return this.find().findByTestId('no-result-found-title');
return this.find().findByTestId('dashboard-empty-table-state');
}

getRocCurveRowByName(name: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PipelineRunsTable {
}

findEmptyResults() {
return cy.findByTestId('no-result-found-title');
return cy.findByTestId('dashboard-empty-table-state');
}

mockRestoreRun(runId: string, namespace: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class PipelinesTable {
}

findEmptyResults() {
return cy.findByTestId('no-result-found-title');
return cy.findByTestId('dashboard-empty-table-state');
}

mockDeletePipeline(pipeline: PipelineKF, namespace: string) {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/__tests__/cypress/cypress/pages/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NotebookRow extends TableRow {
}

shouldHaveNotebookImageName(name: string) {
return cy.findByTestId('image-display-name').should('have.text', name);
return cy.findByTestId('image-display-name').should('contain.text', name);
}

findOutdatedElyraInfo() {
Expand Down Expand Up @@ -66,7 +66,7 @@ class ProjectRow extends TableRow {
}

findNotebookColumnExpander() {
return this.find().findByTestId('notebook-column-count');
return this.find().get('#expand-table-row-1-1');
}

findNotebookTable() {
Expand Down Expand Up @@ -134,7 +134,7 @@ class ProjectListPage {
}

findEmptyResults() {
return cy.findByTestId('no-result-found-title');
return cy.findByTestId('dashboard-empty-table-state');
}

findSortButton(name: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GroupSettingSection extends Contextual<HTMLElement> {
removeChipItem(name: string) {
this.findChipGroup()
.find('li')
.findByRole('button', { name: `close ${name}` })
.findByRole('button', { name: `Close ${name}` })
.click();
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/__tests__/cypress/cypress/pages/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class AttachConnectionModal extends Modal {

selectConnectionOption(name: string) {
this.find().findByRole('button', { name: 'Connections' }).click();
this.find().findByRole('option', { name }).click();
cy.get('#select-connection').findByRole('option', { name }).click();
this.find().findByRole('button', { name: 'Connections' }).click();
}

Expand Down Expand Up @@ -332,7 +332,7 @@ class CreateSpawnerPage {
cy.findByTestId('data-connection-group')
.findByRole('button', { name: 'Typeahead menu toggle' })
.click();
cy.get('[id="dashboard-page-main"]').findByRole('option', { name }).click();
cy.get('#select-connection').findByRole('option', { name }).click();
}

findAwsNameInput() {
Expand Down Expand Up @@ -423,7 +423,7 @@ class NotFoundSpawnerPage {
}

shouldHaveErrorMessageTitle(name: string) {
cy.findByTestId('error-message-title').should('have.text', name);
cy.findByTestId('error-message-title').should('contain.text', name);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ declare global {
isDropdownToggle?: boolean,
) => Cypress.Chainable<JQuery>;

/**
* Finds a patternfly kebab toggle button, opens the menu, and finds the action.
*
* @param name the name of the action in the kebeb menu
* @param isDropdownToggle - True to indicate that it is a dropdown toggle instead of table kebab actions
*/
findKebabActionByMenuId: (
name: string | RegExp,
menuId: string,
isDropdownToggle?: boolean,
) => Cypress.Chainable<JQuery>;

/**
* Finds a patternfly dropdown item by first opening the dropdown if not already opened.
*
Expand Down Expand Up @@ -202,6 +214,23 @@ Cypress.Commands.add(
},
);

Cypress.Commands.add(
'findKebabActionByMenuId',
{ prevSubject: 'element' },
(subject, name, menuId, isDropdownToggle) => {
Cypress.log({ displayName: 'findKebabByMenuId', message: name });
return cy
.wrap(subject)
.findKebab(isDropdownToggle)
.then(($el) => {
if ($el.attr('aria-expanded') === 'false') {
cy.wrap($el).click();
}
return cy.get(`#${menuId}`).findByRole('menuitem', { name });
});
},
);

Cypress.Commands.add('findDropdownItem', { prevSubject: 'element' }, (subject, name) => {
Cypress.log({ displayName: 'findDropdownItem', message: name });
return cy.wrap(subject).then(($el) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ describe('Accelerator Profile', () => {
{ success: true },
).as('delete');
acceleratorProfile.visit();
acceleratorProfile.getRow('TensorRT').findKebabAction('Delete').click();
acceleratorProfile
.getRow('TensorRT')
.findKebabActionByMenuId('Delete', 'accelerator-profile-actions')
.click();
deleteModal.findSubmitButton().should('be.disabled');
deleteModal.findInput().fill('TensorRT');
deleteModal.findSubmitButton().should('be.enabled').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,29 @@ describe('Manage Accelerator Profile', () => {

// test edit toleration
let tableRow = createAcceleratorProfile.getRow('test-key');
tableRow.findKebabAction('Edit').click();
tableRow.findKebabActionByMenuId('Edit', 'toleration-actions').click();
editTolerationModal.findTolerationKeyInput().fill('test-update');
editTolerationModal.findCancelButton().click();
createAcceleratorProfile.getRow('test-key');
tableRow.findKebabAction('Edit').click();
tableRow.findKebabActionByMenuId('Edit', 'toleration-actions').click();
editTolerationModal.findTolerationKeyInput().fill('updated-test');
editTolerationModal.findTolerationSubmitButton().click();
tableRow = createAcceleratorProfile.getRow('updated-test');
tableRow.shouldHaveOperator('Equal');

// test cancel clears fields
tableRow.findKebabAction('Edit').click();
tableRow.findKebabActionByMenuId('Edit', 'toleration-actions').click();
editTolerationModal.findCancelButton().click();
createAcceleratorProfile.findTolerationsButton().click();
createTolerationModal.findTolerationSubmitButton().should('be.disabled');
createTolerationModal.findCancelButton().click();

// test delete
tableRow.findKebabAction('Delete').click();
createAcceleratorProfile.getRow('toleration-key').findKebabAction('Delete').click();
tableRow.findKebabActionByMenuId('Delete', 'toleration-actions').click();
createAcceleratorProfile
.getRow('toleration-key')
.findKebabActionByMenuId('Delete', 'toleration-actions')
.click();
createAcceleratorProfile.shouldHaveModalEmptyState();
cy.interceptOdh('POST /api/accelerator-profiles', { success: true }).as('createAccelerator');
createAcceleratorProfile.findSubmitButton().click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('Administration Tab', () => {
userRow.shouldHavePrivilege('User');
userRow.shouldHaveLastActivity('Just now');
userRow.findServerStatusButton().should('have.text', 'View server');
userRow.findKebabAction('Stop server').click();
userRow.findKebabActionByMenuId('Stop server', 'notebook-actions').click();

stopNotebookModal.findStopNotebookServerButton().should('be.enabled');
stopNotebookModal.findStopNotebookServerButton().click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Connection types', () => {
row2.shouldBeDisabled();
row2.findConnectionTypeCompatibility().should('have.text', 'S3 compatible object storage');

row2.findKebabAction('Preview').click();
row2.findKebabActionByMenuId('Preview', 'connection-type-actions').click();
connectionTypePreviewModal.shouldBeOpen();
connectionTypePreviewModal.findCloseButton().click();
connectionTypePreviewModal.shouldBeOpen(false);
Expand Down Expand Up @@ -124,7 +124,10 @@ describe('Connection types', () => {
}),
]);

connectionTypesPage.getConnectionTypeRow('Test display name').findKebabAction('Delete').click();
connectionTypesPage
.getConnectionTypeRow('Test display name')
.findKebabActionByMenuId('Delete', 'connection-type-actions')
.click();
deleteModal.findSubmitButton().should('be.disabled');
deleteModal.findInput().fill('Test display name');
deleteModal.findSubmitButton().should('be.enabled').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ describe('edit', () => {

createConnectionTypePage
.getFieldsTableRow(4)
.findKebabAction('Move to section heading')
.findKebabActionByMenuId('Move to section heading', 'connection-type-field-actions')
.click();
// move to default which is the first section
cy.findByTestId('section-heading-select').should('be.disabled');
Expand All @@ -304,7 +304,7 @@ describe('edit', () => {

createConnectionTypePage
.getFieldsTableRow(0)
.findKebabAction('Move to section heading')
.findKebabActionByMenuId('Move to section heading', 'connection-type-field-actions')
.click();
cy.findByTestId('section-heading-select').click();
cy.findByTestId('section-heading-select').findSelectOption('header2').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ describe('Custom serving runtimes', () => {
'duplicateTemplate',
);

servingRuntimes.getRowById('template-1').find().findKebabAction('Duplicate').click();
servingRuntimes
.getRowById('template-1')
.find()
.findKebabActionByMenuId('Duplicate', 'custom-serving-runtime-actions')
.click();
servingRuntimes.findAppTitle().should('have.text', 'Duplicate serving runtime');
cy.url().should('include', '/addServingRuntime');

Expand Down Expand Up @@ -276,7 +280,11 @@ describe('Custom serving runtimes', () => {
mockServingRuntimeTemplateK8sResource({}),
).as('editTemplate');

servingRuntimes.getRowById('template-1').find().findKebabAction('Edit').click();
servingRuntimes
.getRowById('template-1')
.find()
.findKebabActionByMenuId('Edit', 'custom-serving-runtime-actions')
.click();
servingRuntimes.findAppTitle().should('contain', 'Edit Multi Platform');
cy.url().should('include', '/editServingRuntime/template-1');
servingRuntimes.findSubmitButton().should('be.disabled');
Expand Down Expand Up @@ -323,7 +331,11 @@ describe('Custom serving runtimes', () => {
mockServingRuntimeTemplateK8sResource({}),
).as('deleteServingRuntime');

servingRuntimes.getRowById('template-1').find().findKebabAction('Delete').click();
servingRuntimes
.getRowById('template-1')
.find()
.findKebabActionByMenuId('Delete', 'custom-serving-runtime-actions')
.click();
deleteModal.findSubmitButton().should('be.disabled');

// test delete form is enabled after filling out required fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ describe('Restoring archive version', () => {
modelVersionArchive.visit();

const archiveVersionRow = modelVersionArchive.getRow('model version 2');
archiveVersionRow.findKebabAction('Restore model version').click();
archiveVersionRow
.findKebabActionByMenuId('Restore model version', 'model-version-actions')
.click();

restoreVersionModal.findRestoreButton().click();

Expand Down Expand Up @@ -295,7 +297,9 @@ describe('Archiving version', () => {
modelVersionArchive.visitModelVersionList();

const modelVersionRow = modelRegistry.getModelVersionRow('model version 3');
modelVersionRow.findKebabAction('Archive model version').click();
modelVersionRow
.findKebabActionByMenuId('Archive model version', 'model-version-actions')
.click();
archiveVersionModal.findArchiveButton().should('be.disabled');
archiveVersionModal.findModalTextInput().fill('model version 3');
archiveVersionModal.findArchiveButton().should('be.enabled').click();
Expand Down Expand Up @@ -338,7 +342,9 @@ describe('Archiving version', () => {
modelVersionArchive.visitModelVersionList();

const modelVersionRow = modelRegistry.getModelVersionRow('model version 3');
modelVersionRow.findKebabAction('Archive model version').should('have.attr', 'aria-disabled');
modelVersionRow
.findKebabActionByMenuId('Archive model version', 'model-version-actions')
.should('have.attr', 'aria-disabled');
});

it('Cannot archive model that has versions with a deployment', () => {
Expand Down
Loading

0 comments on commit 41cc819

Please sign in to comment.