Skip to content

Commit

Permalink
Update ModelServingGlobal Cypress test to account for sorting and fil…
Browse files Browse the repository at this point in the history
…tering
  • Loading branch information
ashley-o0o committed Apr 10, 2024
1 parent 42c0f11 commit 169b2dd
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
} from '~/__tests__/cypress/cypress/pages/modelServing';
import { InferenceServiceKind, ServingRuntimeKind } from '~/k8sTypes';
import { ServingRuntimePlatform } from '~/types';
import { be } from '~/__tests__/cypress/cypress/utils/should';
import { TableToolbar } from '~/__tests__/cypress/cypress/pages/components/TableToolbar';

type HandlersProps = {
disableKServeConfig?: boolean;
Expand Down Expand Up @@ -572,4 +574,58 @@ describe('Model Serving Global', () => {
modelServingGlobal.findDeployModelButton().click();
cy.findByText('Error creating model server').should('not.exist');
});

describe('Table filter', () => {
it('filter by name', () => {
initIntercepts({});
modelServingGlobal.visit('test-project');

// Verify initial run rows exist
modelServingGlobal.getModelRow('Test Inference Service').should('have.length', 1);

// Select the "Name" filter
TableToolbar.prototype.findFilterMenuOption('filter-dropdown-select', 'Name').click();
TableToolbar.prototype.findSearchInput().type('Test Inference Service');
// Verify only rows with the typed run name exist
modelServingGlobal.getModelRow('Test Inference Service').should('exist');
// Verify sort button works
modelServingGlobal.findSortButton('Model name').click();
modelServingGlobal.findSortButton('Model name').should(be.sortDescending);
modelServingGlobal.findSortButton('Model name').click();
modelServingGlobal.findSortButton('Model name').should(be.sortAscending);

// Search for non-existent run name
TableToolbar.prototype.findSearchInput().clear().type('Test Service');

// Verify no results were found
modelServingGlobal.findEmptyResults().should('exist');
});

it('filter by project', () => {
initIntercepts({
projectEnableModelMesh: true,
});
modelServingGlobal.visit('test-project');

// Verify initial run rows exist
modelServingGlobal.getModelRow('Test Inference Service').should('have.length', 1);

// Select the "Project" filter
TableToolbar.prototype.findFilterMenuOption('filter-dropdown-select', 'Project').click();
TableToolbar.prototype.findSearchInput().type('test project');
// Verify only rows with the typed run name exist
modelServingGlobal.getModelRow('Test Inference Service').should('exist');
// Verify sort button works
modelServingGlobal.findSortButton('Project').click();
modelServingGlobal.findSortButton('Project').should(be.sortAscending);
modelServingGlobal.findSortButton('Project').click();
modelServingGlobal.findSortButton('Project').should(be.sortDescending);

// Search for non-existent run name
TableToolbar.prototype.findSearchInput().clear().type('Test Service');

// Verify no results were found
modelServingGlobal.findEmptyResults().should('exist');
});
});
});
8 changes: 8 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/modelServing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ class ModelServingGlobal {
getModelRow(name: string) {
return this.findModelsTable().find(`[data-label=Name]`).contains(name).parents('tr');
}

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

findSortButton(name: string) {
return this.findModelsTable().find('thead').findByRole('button', { name });
}
}

class InferenceServiceModal extends Modal {
Expand Down

0 comments on commit 169b2dd

Please sign in to comment.