Skip to content

Commit

Permalink
[RHOAIENG-1124] Initial pipeline runs global page test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuzz0 committed Jan 25, 2024
1 parent 2a0e69e commit 991141e
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 31 deletions.
30 changes: 25 additions & 5 deletions frontend/src/__mocks__/mockPipelinesJobProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ import {
} from '~/concepts/pipelines/kfTypes';

type MockResourceConfigType = {
name?: string;
id?: string;
name: string;
id: string;
};

const defaultMockRunJob = {
name: 'test-pipeline-run-job',
id: 'test-pipeline-run-job',
};

export const mockPipelinesJobProxy = ({
name = 'test-pipeline-run-job',
id = 'test-pipeline-run-job',
}: MockResourceConfigType): PipelineRunJobKF => ({
name,
id,
}: MockResourceConfigType = defaultMockRunJob): PipelineRunJobKF => ({
id,
name,
mode: JobModeKF.ENABLED,
Expand Down Expand Up @@ -60,3 +65,18 @@ export const mockPipelinesJobProxy = ({
error: '',
no_catchup: false,
});

export const buildMockPipelineRunJob = (job?: Partial<PipelineRunJobKF>): PipelineRunJobKF => {
const defaultMockJob = mockPipelinesJobProxy();
return { defaultMockJob, ...job };
};

export const buildMockPipelines = (

Check failure on line 74 in frontend/src/__mocks__/mockPipelinesJobProxy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Missing return type on function
pipelines: PipelineKF[] = mockPipelinesProxy.pipelines,
totalSize?: number,
nextPageToken?: string,
) => ({
pipelines,
total_size: totalSize || pipelines.length,
next_page_token: nextPageToken,
});
8 changes: 1 addition & 7 deletions frontend/src/__mocks__/mockPipelinesProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,11 @@ export const buildMockPipeline = (pipeline?: Partial<PipelineKF>): PipelineKF =>
};
};

type APIResult = {
total_size?: number | undefined;
next_page_token?: string | undefined;
pipelines: PipelineKF[];
};

export const buildMockPipelines = (

Check failure on line 258 in frontend/src/__mocks__/mockPipelinesProxy.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Missing return type on function
pipelines: PipelineKF[] = mockPipelinesProxy.pipelines,
totalSize?: number,
nextPageToken?: string,
): APIResult => ({
) => ({
pipelines,
total_size: totalSize || pipelines.length,
next_page_token: nextPageToken,
Expand Down
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 991141e

Please sign in to comment.