Skip to content

Commit

Permalink
ADM-988: [frontend] add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandy-Tang committed Jul 23, 2024
1 parent aef24f1 commit aaf0076
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions frontend/e2e/pages/metrics/report-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export enum ProjectCreationType {
export class ReportStep {
readonly page: Page;
readonly pageHeader: Locator;
readonly projectName: Locator;
readonly dateRangeViewerContainer: Locator;
readonly dateRangeViewerExpandTrigger: Locator;
readonly dateRangeViewerOptions: Locator;
Expand Down Expand Up @@ -114,6 +115,7 @@ export class ReportStep {
constructor(page: Page) {
this.page = page;
this.pageHeader = this.page.locator('[data-test-id="Header"]');
this.projectName = this.page.getByLabel('project name');
this.dateRangeViewerContainer = this.page.getByLabel('date range viewer');
this.dateRangeViewerExpandTrigger = this.dateRangeViewerContainer.getByLabel('expandMore');
this.dateRangeViewerOptions = this.dateRangeViewerContainer.getByLabel('date range viewer options');
Expand Down Expand Up @@ -217,6 +219,10 @@ export class ReportStep {
await this.previousButton.click();
}

async checkProjectName(projectName: string) {
await expect(this.projectName).toContainText(projectName);
}

async checkDoraMetricsReportDetails(doraMetricsDetailData: IDoraMetricsResultItem) {
await expect(this.deploymentFrequencyRows.getByRole('cell').nth(0)).toContainText('Heartbeat/ Deploy prod');
await expect(this.deploymentFrequencyRows.getByRole('cell').nth(1)).toContainText(
Expand Down
2 changes: 2 additions & 0 deletions frontend/e2e/specs/major-path/create-a-new-project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ test('Create a new project', async ({ homePage, configStep, metricsStep, reportS
await metricsStep.goToReportPage();

await reportStep.confirmGeneratedReport();
await reportStep.checkProjectName(configStepData.projectName);
await reportStep.checkBoardMetricsForMultipleRanges(BOARD_METRICS_RESULT_MULTIPLE_RANGES);
await reportStep.checkBoardMetricsDetailsForMultipleRanges({
projectCreationType: ProjectCreationType.CREATE_A_NEW_PROJECT,
Expand Down Expand Up @@ -129,5 +130,6 @@ test('Create a new project without block column in boarding mapping', async ({
await metricsStep.goToReportPage();

await reportStep.confirmGeneratedReport();
await reportStep.checkProjectName(configStepData.projectName);
await reportStep.checkBoardDownloadDataWithoutBlockForMultipleRanges(3);
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ test('Import project from file with all ranges API succeed', async ({
await metricsStep.checkPipelineConfigurationAreChanged(importMultipleDoneProjectFromFile.deployment);

await metricsStep.goToReportPage();
await reportStep.checkProjectName(importMultipleDoneProjectFromFile.projectName);
await reportStep.confirmGeneratedReport();
await reportStep.checkShareReport();
await reportStep.checkBoardMetricsForMultipleRanges(BOARD_METRICS_RESULT_MULTIPLE_RANGES);
Expand Down Expand Up @@ -112,6 +113,7 @@ test('Import project from file with partial ranges API failed', async ({
await metricsStep.validateNextButtonClickable();
await metricsStep.goToReportPage();

await reportStep.checkProjectName(partialTimeRangesSuccess.projectName);
await reportStep.confirmGeneratedReport();

await reportStep.checkSelectListTab();
Expand Down Expand Up @@ -163,6 +165,8 @@ test('Import project from file with no all metrics', async ({ homePage, configSt

await reportStep.confirmGeneratedReport();

await reportStep.checkProjectName(partialMetricsShowChart.projectName);

await reportStep.checkSelectListTab();
await reportStep.goToChartBoardTab();
await reportStep.checkChartBoardTabStatus({
Expand Down Expand Up @@ -222,6 +226,7 @@ test('Import project from file with holiday', async ({ homePage, configStep, met
await metricsStep.checkPipelineConfigurationAreChanged(calculateWithHolidayConfigFile.deployment);

await metricsStep.goToReportPage();
await reportStep.checkProjectName(calculateWithHolidayConfigFile.projectName);
await reportStep.confirmGeneratedReport();
await reportStep.checkBoardMetrics({
velocity: BOARD_METRICS_WITH_HOLIDAY_RESULT.Velocity,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/containers/ReportStep/ReportContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ const ReportContent = (props: ReportContentProps) => {

return (
<>
{projectName && <StyledProjectHeader>{projectName}</StyledProjectHeader>}
{projectName && <StyledProjectHeader aria-label='project name'>{projectName}</StyledProjectHeader>}
<HeaderContainer shouldShowTabs={shouldShowTabs}>
{shouldShowTabs && showTabs()}
{shouldShowTabs && displayType === DISPLAY_TYPE.CHART && showChartTabs()}
Expand Down

0 comments on commit aaf0076

Please sign in to comment.