Skip to content

Commit

Permalink
Merge pull request #2398 from jpuzz0/RHOAIENG-1124-initial-pipeline-r…
Browse files Browse the repository at this point in the history
…uns-cypress-setup

[RHOAIENG-1124] Initial pipeline runs global page test setup
  • Loading branch information
openshift-merge-bot[bot] authored Jan 25, 2024
2 parents 2a0e69e + eaf3aee commit b156391
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { mockStatus } from '~/__mocks__/mockStatus';
import { mockDashboardConfig } from '~/__mocks__/mockDashboardConfig';
import { mockDataSciencePipelineApplicationK8sResource } from '~/__mocks__/mockDataSciencePipelinesApplicationK8sResource';
import { mockRouteK8sResource } from '~/__mocks__/mockRouteK8sResource';
import { mockK8sResourceList } from '~/__mocks__/mockK8sResourceList';
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource';
import { pipelineRunsGlobal } from '~/__tests__/cypress/cypress/pages/pipelines';

const projectName = 'test-project-name';

describe('Pipeline Runs Global', () => {
beforeEach(() => {
initIntercepts();
pipelineRunsGlobal.visit(projectName);
});

it('renders the page with scheduled and triggered runs table data', () => {
// TODO
});
});

const initIntercepts = () => {
cy.intercept('/api/status', mockStatus());
cy.intercept('/api/config', mockDashboardConfig({}));
cy.intercept(
{
pathname: `/api/k8s/apis/datasciencepipelinesapplications.opendatahub.io/v1alpha1/namespaces/${projectName}/datasciencepipelinesapplications/pipelines-definition`,
},
mockDataSciencePipelineApplicationK8sResource({ namespace: projectName }),
);
cy.intercept(
{
pathname: `/api/k8s/apis/route.openshift.io/v1/namespaces/${projectName}/routes/ds-pipeline-pipelines-definition`,
},
mockRouteK8sResource({
notebookName: 'ds-pipeline-pipelines-definition',
namespace: projectName,
}),
);
cy.intercept(
{
pathname: '/api/k8s/apis/project.openshift.io/v1/projects',
},
mockK8sResourceList([
mockProjectK8sResource({ k8sName: projectName }),
mockProjectK8sResource({ k8sName: `${projectName}-2`, displayName: 'Test Project 2' }),
]),
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ export * from './pipelinesTable';
export * from './pipelinesGlobal';
export * from './pipelineImportModal';
export * from './pipelineVersionImportModal';
export * from './pipelineRunsGlobal';
export * from './pipelineRunTable';
export * from './pipelineRunJobTable';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class PipelineRunJobTable {
private testId = 'pipeline-run-job-table';

find() {
return cy.findByTestId(this.testId);
}
}

export const pipelineRunJobTable = new PipelineRunJobTable();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class PipelineRunTable {
private testId = 'pipeline-run-table';

find() {
return cy.findByTestId(this.testId);
}
}

export const pipelineRunTable = new PipelineRunTable();
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class PipelineRunsGlobal {
private testId = 'pipeline-runs-global-page';

visit(projectName: string) {
cy.visitWithLogin(`/pipelineRuns/${projectName}`);
this.find();
}

find() {
return cy.findByTestId(this.testId);
}

findScheduledTab() {
return cy.findByRole('tab', { name: 'Scheduled runs tab' });
}

findTriggeredTab() {
return cy.findByRole('tab', { name: 'Triggered runs tab' });
}

findProjectSelect() {
return this.find().findByTestId('project-selector-dropdown');
}

selectProjectByName(name: string) {
this.findProjectSelect().findDropdownItem(name).click();
}
}

export const pipelineRunsGlobal = new PipelineRunsGlobal();
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const PipelineRunTable: React.FC<PipelineRunTableProps> = ({
)}
variant={TableVariant.compact}
getColumnSort={getTableColumnSort({ columns: pipelineRunColumns, ...tableProps })}
data-testid="pipeline-run-table"
/>
<DeletePipelineRunsModal
toDeleteResources={deleteResources}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const PipelineRunJobTable: React.FC<PipelineRunTableProps> = ({
)}
variant={TableVariant.compact}
getColumnSort={getTableColumnSort({ columns: pipelineRunJobColumns, ...tableProps })}
data-testid="pipeline-run-job-table"
/>
<DeletePipelineRunsModal
toDeleteResources={deleteResources}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/pages/ApplicationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ApplicationsPageProps = {
headerContent?: React.ReactNode;
provideChildrenPadding?: boolean;
jobReferenceName?: React.ReactNode;
testId?: string;
};

const ApplicationsPage: React.FC<ApplicationsPageProps> = ({
Expand All @@ -51,6 +52,7 @@ const ApplicationsPage: React.FC<ApplicationsPageProps> = ({
headerContent,
provideChildrenPadding,
jobReferenceName,
testId,
}) => {
const renderHeader = () => (
<PageSection variant={PageSectionVariants.light}>
Expand Down Expand Up @@ -136,11 +138,11 @@ const ApplicationsPage: React.FC<ApplicationsPageProps> = ({
};

return (
<>
<div data-testid={testId}>
{breadcrumb && <PageBreadcrumb>{breadcrumb}</PageBreadcrumb>}
{renderHeader()}
{renderContents()}
</>
</div>
);
};

Expand Down
29 changes: 13 additions & 16 deletions frontend/src/pages/pipelines/global/pipelines/GlobalPipelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ const GlobalPipelines: React.FC = () => {
const pipelinesAPi = usePipelinesAPI();

return (
<div data-testid="pipelines-global-page">
<PipelineCoreApplicationPage
title={pipelinesPageTitle}
description={pipelinesPageDescription}
headerAction={
<PipelineServerActions isDisabled={!pipelinesAPi.pipelinesServer.installed} />
}
getRedirectPath={(namespace) => `/pipelines/${namespace}`}
>
<EnsureAPIAvailability>
<PipelineAndVersionContextProvider>
<PipelinesView />
</PipelineAndVersionContextProvider>
</EnsureAPIAvailability>
</PipelineCoreApplicationPage>
</div>
<PipelineCoreApplicationPage
title={pipelinesPageTitle}
description={pipelinesPageDescription}
headerAction={<PipelineServerActions isDisabled={!pipelinesAPi.pipelinesServer.installed} />}
getRedirectPath={(namespace) => `/pipelines/${namespace}`}
testId="pipelines-global-page"
>
<EnsureAPIAvailability>
<PipelineAndVersionContextProvider>
<PipelinesView />
</PipelineAndVersionContextProvider>
</EnsureAPIAvailability>
</PipelineCoreApplicationPage>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const GlobalPipelineRuns: React.FC = () => (
description={pipelineRunsPageDescription}
getRedirectPath={(namespace) => `/pipelineRuns/${namespace}`}
overrideChildPadding
testId="pipeline-runs-global-page"
>
<EnsureAPIAvailability>
<PipelineRunVersionsContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const GlobalPipelineRunsTab: React.FC = () => {
<Tab
eventKey={PipelineRunType.Scheduled}
title={<TabTitleText>Scheduled</TabTitleText>}
aria-label="Scheduled tab"
aria-label="Scheduled runs tab"
className="odh-tabcontent-fix"
>
<PageSection isFilled variant="light">
Expand Down

0 comments on commit b156391

Please sign in to comment.