Skip to content

Commit

Permalink
Update PipelineRuns Cypress test to account for sorting and filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-o0o committed Mar 27, 2024
1 parent 35eef97 commit 4cc7ba2
Show file tree
Hide file tree
Showing 2 changed files with 213 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
bulkArchiveRunModal,
} from '~/__tests__/cypress/cypress/pages/pipelines';
import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url.cy';
import { be } from '~/__tests__/cypress/cypress/utils/should';

const projectName = 'test-project-filters';
const pipelineId = 'test-pipeline';
Expand Down Expand Up @@ -136,10 +137,10 @@ const mockArchivedRuns = [
run_id: 'archived-run-2',
pipeline_version_reference: {
pipeline_id: pipelineId,
pipeline_version_id: 'test-version-1',
pipeline_version_id: 'test-version-2',
},
experiment_id: 'test-experiment-1',
created_at: '2024-02-05T00:00:00Z',
created_at: '2024-02-20T00:00:00Z',
state: RuntimeStateKF.SUCCEEDED,
}),
];
Expand Down Expand Up @@ -438,6 +439,13 @@ describe('Pipeline runs', () => {
activeRunsTable.findRows().should('have.length', 1);
activeRunsTable.getRowByName('Test active run 3');
});

it('Sort by Name', () => {
pipelineRunFilterBar.findSortButtonForActive('Run').click();
pipelineRunFilterBar.findSortButtonForActive('Run').should(be.sortAscending);
pipelineRunFilterBar.findSortButtonForActive('Run').click();
pipelineRunFilterBar.findSortButtonForActive('Run').should(be.sortDescending);
});
});
});
});
Expand Down Expand Up @@ -493,6 +501,178 @@ describe('Pipeline runs', () => {
activeRunsTable.getRowByName(run.display_name).find().should('exist'),
);
});

describe('Table filter', () => {
it('filter by run name', () => {
// Verify initial run rows exist
archivedRunsTable.findRows().should('have.length', 2);

// Select the "Name" filter, enter a value to filter by
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() => pipelineRunsGlobal.selectFilterByName('Run'));
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() => pipelineRunFilterBar.findNameInput().type('run 1'));

// Mock runs (filtered by typed run name)
archivedRunsTable.mockGetArchivedRuns(
mockActiveRuns.filter((mockRun) => mockRun.display_name.includes('run 1')),
1,
);

// Verify only rows with the typed run name exist
archivedRunsTable.findRows().should('have.length', 1);
archivedRunsTable.getRowByName('Test active run 1').find;

Check failure on line 526 in frontend/src/__tests__/cypress/cypress/e2e/pipelines/PipelineRuns.cy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Expected an assignment or function call and instead saw an expression
});

it('filter by experiment', () => {
// Mock initial list of experiments
pipelineRunFilterBar.mockExperiments(mockExperiments);

// Verify initial run rows exist
archivedRunsTable.findRows().should('have.length', 2);

// Select the "Experiment" filter, enter a value to filter by
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() => pipelineRunsGlobal.selectFilterByName('Experiment'));
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() => pipelineRunFilterBar.findExperimentInput().type('Test Experiment 1'));

// Mock runs (filtered by selected experiment)
archivedRunsTable.mockGetArchivedRuns(
mockArchivedRuns.filter((mockRun) => mockRun.experiment_id === 'test-experiment-1'),
1,
);

// Select an experiment to filter by
pipelineRunFilterBar.selectExperimentByName('Test Experiment 1');

// Verify only rows with selected experiment exist
archivedRunsTable.findRows().should('have.length', 2);
archivedRunsTable.getRowByName('Test archived run 1').find;

Check failure on line 555 in frontend/src/__tests__/cypress/cypress/e2e/pipelines/PipelineRuns.cy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Expected an assignment or function call and instead saw an expression
archivedRunsTable.getRowByName('Test archived run 2').find;

Check failure on line 556 in frontend/src/__tests__/cypress/cypress/e2e/pipelines/PipelineRuns.cy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Expected an assignment or function call and instead saw an expression
});

it('filter by pipeline version', () => {
// Verify initial run rows exist
archivedRunsTable.findRows().should('have.length', 2);

// Select the "Pipeline version" filter, select a value to filter by
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() => pipelineRunsGlobal.selectFilterByName('Pipeline version'));

// Mock runs (filtered by selected version)
archivedRunsTable.mockGetArchivedRuns(
mockArchivedRuns.filter(
(mockRun) =>
mockRun.pipeline_version_reference.pipeline_version_id === 'test-version-1',
),
1,
);

// Select version to filter by
pipelineRunFilterBar.selectPipelineVersionByName('Test Version 1');

// Verify only rows with selected experiment exist
archivedRunsTable.findRows().should('have.length', 1);
archivedRunsTable.getRowByName('Test archived run 1').find;

Check failure on line 582 in frontend/src/__tests__/cypress/cypress/e2e/pipelines/PipelineRuns.cy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Expected an assignment or function call and instead saw an expression
});

// TODO: .clear() command causing full table to clear, not just date field
// it('filter by started', () => {
// // Verify initial run rows exist
// archivedRunsTable.findRows().should('have.length', 2);

// // Select the "Started" filter, select a value to filter by
// pipelineRunsGlobal
// .findArchivedRunsToolbar()
// .within(() => pipelineRunsGlobal.selectFilterByName('Started'));

// // Mock runs (filtered by start date), type a start date
// archivedRunsTable.mockGetArchivedRuns(
// mockArchivedRuns.filter((mockRun) => mockRun.created_at.includes('2024-02-05')),
// 1,
// );
// pipelineRunsGlobal
// .findArchivedRunsToolbar()
// .within(() => pipelineRunFilterBar.findStartDateInput().type('2024-02-05'));

// // Verify only rows with selected start date exist
// archivedRunsTable.findRows().should('have.length', 1);
// archivedRunsTable.getRowByName('Test archived run 1').find;

// // Mock runs with a cleared filter before updating again
// archivedRunsTable.mockGetRuns(mockArchivedRuns, [], 1);
// pipelineRunsGlobal
// .findArchivedRunsToolbar()
// .within(() => pipelineRunFilterBar.findStartDateInput().clear());

// // Mock runs with a start date not associated with those runs
// archivedRunsTable.mockGetArchivedRuns(
// mockArchivedRuns.filter((mockRun) => mockRun.created_at.includes('2024-02-15')),
// 1,
// );
// pipelineRunsGlobal
// .findArchivedRunsToolbar()
// .within(() => pipelineRunFilterBar.findStartDateInput().type('2024-02-15'));

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

it('filter by status', () => {
// Verify initial run rows exist
archivedRunsTable.findRows().should('have.length', 2);

// Select the "Status" filter
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() => pipelineRunsGlobal.selectFilterByName('Status'));

// Mock runs (filtered by a status of 'SUCCEEDED')
archivedRunsTable.mockGetArchivedRuns(
mockArchivedRuns.filter((mockRun) => mockRun.state === RuntimeStateKF.SUCCEEDED),
1,
);
// Select a filter value of 'SUCCEEDED'
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() =>
pipelineRunFilterBar.selectStatusByName(runtimeStateLabels[RuntimeStateKF.SUCCEEDED]),
);

// Verify only rows with the selected status exist
archivedRunsTable.findRows().should('have.length', 2);
archivedRunsTable.getRowByName('Test archived run 1').find;

Check failure on line 650 in frontend/src/__tests__/cypress/cypress/e2e/pipelines/PipelineRuns.cy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Expected an assignment or function call and instead saw an expression
archivedRunsTable.getRowByName('Test archived run 2').find;

Check failure on line 651 in frontend/src/__tests__/cypress/cypress/e2e/pipelines/PipelineRuns.cy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Expected an assignment or function call and instead saw an expression

// Mock runs (filtered by a status of 'RUNNING')
archivedRunsTable.mockGetArchivedRuns(
mockArchivedRuns.filter((mockRun) => mockRun.state === RuntimeStateKF.RUNNING),
1,
);
// Select a filter value of 'RUNNING'
pipelineRunsGlobal
.findArchivedRunsToolbar()
.within(() =>
pipelineRunFilterBar.selectStatusByName(runtimeStateLabels[RuntimeStateKF.RUNNING]),
);

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

it('Sort by Name', () => {
pipelineRunFilterBar.findSortButtonForArchive('Run').click();
pipelineRunFilterBar.findSortButtonForArchive('Run').should(be.sortAscending);
pipelineRunFilterBar.findSortButtonForArchive('Run').click();
pipelineRunFilterBar.findSortButtonForArchive('Run').should(be.sortDescending);
});
});
});
});

Expand Down Expand Up @@ -584,6 +764,13 @@ describe('Pipeline runs', () => {
pipelineRunJobTable.findRows().should('have.length', 1);
pipelineRunJobTable.getRowByName('test-pipeline');
});

it('Sort by Name', () => {
pipelineRunFilterBar.findSortButtonforSchedules('Schedule').click();
pipelineRunFilterBar.findSortButtonforSchedules('Schedule').should(be.sortAscending);
pipelineRunFilterBar.findSortButtonforSchedules('Schedule').click();
pipelineRunFilterBar.findSortButtonforSchedules('Schedule').should(be.sortDescending);
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ class PipelineRunFilterBar extends PipelineFilterBar {
return cy.findByTestId('runtime-status-dropdown');
}

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

private findActiveRunsTable() {
return cy.findByTestId('active-runs-table');
}

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

private findArchiveRunsTable() {
return cy.findByTestId('archived-runs-table');
}

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

private findSchedulesTable() {
return cy.findByTestId('schedules-table');
}

selectStatusByName(name: string) {
this.findStatusSelect().findDropdownItem(name).click();
}
Expand Down

0 comments on commit 4cc7ba2

Please sign in to comment.