Skip to content

Commit

Permalink
Update integration test for design selector
Browse files Browse the repository at this point in the history
  • Loading branch information
MWedl committed Jan 13, 2025
1 parent 054551f commit 632dae4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
13 changes: 3 additions & 10 deletions packages/frontend/test/e2e/integration/designs.test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test } from '@playwright/test';
import { DemoDataState, DemoDataType } from '../util/demo_data';
import { createProject } from '../util/helpers';

const designName = 'My Test Design';
test('A User can create an Design with a Name', async ({ page }) => {
Expand Down Expand Up @@ -45,16 +46,8 @@ test('A User can create an Design with a Name', async ({ page }) => {

test('Design Settings are reflected in a Project', async ({ page }) => {
const testState = new DemoDataState();
await page.goto('/projects');
await page.waitForSelector('text=Projects');
await page.getByTestId('create-button').click();
await page.getByLabel('Name').fill('My Design Test Project');
await page.getByTestId('project-type').getByRole('textbox').fill(designName);
await page.getByTestId('page-loader').waitFor({ state: 'hidden' });
await page.getByText('No data found').waitFor({ state: 'hidden' });
const designId = testState.designs.at(testState.designs.length - 1);
await page.getByTestId(`design-${designId}`).click();
await page.getByTestId('submit-project').click();
await createProject(page, { projectName: 'My Design Test Project', designId: testState.designs.at(testState.designs.length - 1)!, designName: designName });

await page.getByRole('link', { name: 'Executive Summary' }).click();
await page.getByLabel('Assignee', { exact: true }).waitFor();
expect(await page.getByRole('textbox').getByText('This is a test executive summary').isVisible()).toBeTruthy();
Expand Down
28 changes: 8 additions & 20 deletions packages/frontend/test/e2e/integration/projects.spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
import { expect, test } from '@playwright/test';
import { DemoDataState } from '../util/demo_data';
const projectName = 'My Test Project';
import { createProject } from '../util/helpers';
const projectName = 'Updated Project Name';
test('A User can create an Project with a Name', async ({ page }) => {
await page.goto('/projects');
await page.waitForSelector('text=Projects');

expect(await page.title()).toBe('Projects | SysReptor');
// Create New Design Modal
await page.getByTestId('create-button').click();
// Create New Design Modal
await page.getByLabel('Name').fill(projectName);
const designId = new DemoDataState().designs[0];

await page.getByTestId('project-type').getByRole('textbox').fill('Demo Matrix');
await page.getByTestId('page-loader').waitFor({ state: 'hidden' });
await page.getByText('No data found').waitFor({ state: 'hidden' });
await page.getByTestId('design-' + designId).locator('nth=0').click();
await page.getByTestId('submit-project').click();
const oldProjectName = 'My Test Project'
await createProject(page, { projectName: oldProjectName, designId: new DemoDataState().designs[0]!, designName: 'Demo Matrix' });

// Verify Project Name
await expect(page.getByText(projectName)).toBeVisible();
await expect(page.getByText(oldProjectName)).toBeVisible();

await page.getByTestId('project-settings-tab').click();
await page.getByLabel('Name').waitFor();
await page.getByLabel('Name').fill('Updated Project Name');
await page.getByLabel('Name').fill(projectName);
await page.getByLabel('Tags').fill('Updated Tags');
await page.keyboard.press('Enter');
await page.getByRole('button', { name: 'Badge' }).click();
Expand All @@ -33,11 +21,11 @@ test('A User can create an Project with a Name', async ({ page }) => {
test('A User can delete a Project', async ({ page }) => {
await page.goto('/projects');
await page.waitForSelector('text=Projects');
await page.getByRole('link', { name: 'Updated Project Name' }).click();
await page.getByRole('link', { name: projectName }).click();
await page.getByTestId('project-settings-tab').click();
await page.getByTestId('options-dots').click();
await page.getByText('Delete').click();
await page.getByTestId('confirm-input').getByRole('textbox').fill('Updated Project Name');
await page.getByTestId('confirm-input').getByRole('textbox').fill(projectName);
await page.getByRole('button', { name: 'Delete' }).click();
await page.waitForSelector('text=Projects');

Expand Down
22 changes: 22 additions & 0 deletions packages/frontend/test/e2e/util/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Page } from "@playwright/test";

export async function createProject(page: Page, options: { projectName: string, designId: string, designName: string }) {
// Click create project button
await page.goto('/projects');
await page.waitForSelector('text=Projects');
await page.getByTestId('create-button').click();

// Fill project name
await page.getByLabel('Name').fill(options.projectName);

// Select design
const textbox = await page.getByTestId('project-type').getByRole('textbox');
textbox.clear();
textbox.fill(options.designName);
await page.getByTestId('page-loader').waitFor({ state: 'hidden' });
await page.getByText('No data found').waitFor({ state: 'hidden' });
await page.getByTestId(`design-${options.designId}`).click();

// Create
await page.getByTestId('submit-project').click();
}

0 comments on commit 632dae4

Please sign in to comment.