Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated pipelineList tests #2854

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 81 additions & 60 deletions frontend/src/__tests__/cypress/cypress/e2e/pipelines/Pipelines.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
pipelineDeleteModal,
configurePipelineServerModal,
viewPipelineServerModal,
PipelineSort,
} from '~/__tests__/cypress/cypress/pages/pipelines';
import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url';
import { deleteModal } from '~/__tests__/cypress/cypress/pages/components/DeleteModal';
Expand All @@ -28,7 +29,6 @@ import {
import { asProductAdminUser } from '~/__tests__/cypress/cypress/utils/users';
import { mockSecretK8sResource } from '~/__mocks__/mockSecretK8sResource';
import { PipelineKFv2 } from '~/concepts/pipelines/kfTypes';
import { be } from '~/__tests__/cypress/cypress/utils/should';
import { tablePagination } from '~/__tests__/cypress/cypress/pages/components/Pagination';
import { mockSuccessGoogleRpcStatus } from '~/__mocks__/mockGoogleRpcStatusKF';

Expand Down Expand Up @@ -363,32 +363,8 @@ describe('Pipelines', () => {
});

it('View pipeline server', () => {
initIntercepts({});
cy.interceptK8s(
{
model: SecretModel,
ns: projectName,
},
mockSecretK8sResource({
s3Bucket: 'c2RzZA==',
namespace: projectName,
name: 'aws-connection-test',
}),
);

pipelinesGlobal.visit(projectName);

pipelinesGlobal.selectPipelineServerAction('View pipeline server configuration');
viewPipelineServerModal.findCloseButton().click();

pipelinesGlobal.selectPipelineServerAction('View pipeline server configuration');
viewPipelineServerModal.shouldHaveAccessKey('sdsd');
viewPipelineServerModal.findPasswordHiddenButton().click();
viewPipelineServerModal.shouldHaveSecretKey('sdsd');
viewPipelineServerModal.shouldHaveEndPoint('https://s3.amazonaws.com');
viewPipelineServerModal.shouldHaveBucketName('test-pipelines-bucket');

viewPipelineServerModal.findDoneButton().click();
const visitPipelineProjects = () => pipelinesGlobal.visit(projectName);
viewPipelineServerDetailsTest(visitPipelineProjects);
});

it('renders the page with pipelines table data', () => {
Expand Down Expand Up @@ -483,17 +459,22 @@ describe('Pipelines', () => {
initIntercepts({});
pipelinesGlobal.visit(projectName);

// by Pipeline
pipelinesTable.findTableHeaderButton('Pipeline').click();
pipelinesTable.findTableHeaderButton('Pipeline').should(be.sortAscending);
pipelinesTable.findTableHeaderButton('Pipeline').click();
pipelinesTable.findTableHeaderButton('Pipeline').should(be.sortDescending);

// by Created
pipelinesTable.findTableHeaderButton('Created').click();
pipelinesTable.findTableHeaderButton('Created').should(be.sortAscending);
pipelinesTable.findTableHeaderButton('Created').click();
pipelinesTable.findTableHeaderButton('Created').should(be.sortDescending);
pipelinesTable.shouldSortTable({
sortType: PipelineSort.All,
pipelines: [
buildMockPipelineV2({
display_name: 'Test pipeline 1',
pipeline_id: 'test-pipeline-1',
created_at: '2023-01-30T22:55:17Z',
}),
buildMockPipelineV2({
display_name: 'Test pipeline 2',
pipeline_id: 'test-pipeline-2',
created_at: '2024-01-30T22:55:17Z',
}),
],
projectName,
});
});
});

Expand Down Expand Up @@ -945,29 +926,13 @@ describe('Pipelines', () => {
});

it('navigate to create run page from pipeline row', () => {
initIntercepts({});
pipelinesGlobal.visit(projectName);

// Wait for the pipelines table to load
pipelinesTable.find();
pipelinesTable
.getRowById(initialMockPipeline.pipeline_id)
.findKebabAction('Create run')
.click();
verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/create`);
const visitPipelineProjects = () => pipelinesGlobal.visit(projectName);
runCreateRunPageNavTest(visitPipelineProjects);
});

it('navigates to "Schedule run" page from pipeline row', () => {
initIntercepts({});
pipelinesGlobal.visit(projectName);

pipelinesTable.find();
pipelinesTable
.getRowById(initialMockPipeline.pipeline_id)
.findKebabAction('Schedule run')
.click();

verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/create?runType=scheduled`);
const visitPipelineProjects = () => pipelinesGlobal.visit(projectName);
runScheduleRunPageNavTest(visitPipelineProjects);
});

it('navigate to create run page from pipeline version row', () => {
Expand Down Expand Up @@ -1119,12 +1084,12 @@ type HandlersProps = {
nextPageToken?: string | undefined;
};

const initIntercepts = ({
export const initIntercepts = ({
isEmpty = false,
mockPipelines = [initialMockPipeline],
totalSize = mockPipelines.length,
nextPageToken,
}: HandlersProps) => {
}: HandlersProps): void => {
cy.interceptK8sList(
DataSciencePipelineApplicationModel,
mockK8sResourceList(
Expand Down Expand Up @@ -1193,3 +1158,59 @@ const createDeletePipelineIntercept = (pipelineId: string) =>
},
mockSuccessGoogleRpcStatus({}),
);

export const runCreateRunPageNavTest = (visitPipelineProjects: () => void): void => {
initIntercepts({});
visitPipelineProjects();

// Wait for the pipelines table to load
pipelinesTable.find();
pipelinesTable.getRowById(initialMockPipeline.pipeline_id).findKebabAction('Create run').click();
verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/create`);
};

export const runScheduleRunPageNavTest = (visitPipelineProjects: () => void): void => {
initIntercepts({});
visitPipelineProjects();

pipelinesTable.find();
pipelinesTable
.getRowById(initialMockPipeline.pipeline_id)
.findKebabAction('Schedule run')
.click();

verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/create?runType=scheduled`);
};

export const viewPipelineServerDetailsTest = (visitPipelineProjects: () => void): void => {
initIntercepts({});
cy.interceptK8s(
{
model: SecretModel,
ns: projectName,
},
mockSecretK8sResource({
s3Bucket: 'c2RzZA==',
namespace: projectName,
name: 'aws-connection-test',
}),
);
visitPipelineProjects();
viewPipelinelineDetails();
};

const viewPipelinelineDetails = (
accessKey = 'sdsd',
secretKey = 'sdsd',
endpoint = 'https://s3.amazonaws.com',
bucketName = 'test-pipelines-bucket',
) => {
pipelinesGlobal.selectPipelineServerAction('View pipeline server configuration');
viewPipelineServerModal.shouldHaveAccessKey(accessKey);
viewPipelineServerModal.findPasswordHiddenButton().click();
viewPipelineServerModal.shouldHaveSecretKey(secretKey);
viewPipelineServerModal.shouldHaveEndPoint(endpoint);
viewPipelineServerModal.shouldHaveBucketName(bucketName);

viewPipelineServerModal.findDoneButton().click();
};
Loading
Loading