Skip to content

Commit

Permalink
test: added project list test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Oct 23, 2024
1 parent 416a7fd commit fb12afe
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
Empty file removed tests/project/.gitkeep
Empty file.
83 changes: 83 additions & 0 deletions tests/project/projectList.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { test, expect } from '@playwright/test';
import { ProjectListPage } from '@/page-objects/project/projectListPage';

test.describe('Project List Tests', () => {
let projectListPage: ProjectListPage;

test.beforeEach(async ({ page }) => {
projectListPage = new ProjectListPage(page);
await projectListPage.navigate();
});

test('should display the project list', async () => {
const projectCount = await projectListPage.getProjectCount();
expect(projectCount).toBeGreaterThan(0);
});

test('should create a new project', async ({ page }) => {
const initialCount = await projectListPage.getProjectCount();
await projectListPage.clickCreateProject();

// Here you would interact with the create project dialog
// For this example, we'll assume the dialog is handled elsewhere
// and just check that the button click worked

await page.waitForSelector('.el-dialog');
const dialogVisible = await page.isVisible('.el-dialog');
expect(dialogVisible).toBe(true);

// Close the dialog
await page.click('.el-dialog__close');

// In a real scenario, you'd fill out the form and submit it
// Then you'd verify the new project appears in the list
// const newCount = await projectListPage.getProjectCount();
// expect(newCount).toBe(initialCount + 1);
});

test('should search for a project', async ({ page }) => {
const searchTerm = 'Test Project';
await projectListPage.searchProject(searchTerm);
await page.waitForTimeout(1000); // Wait for search results

const projectCount = await projectListPage.getProjectCount();
if (projectCount > 0) {
const firstProjectData = await projectListPage.getProjectData(0);
expect(firstProjectData.name).toContain(searchTerm);
} else {
// If no projects found, that's okay too
expect(projectCount).toBe(0);
}
});

test('should navigate to project detail', async ({ page }) => {
const projectCount = await projectListPage.getProjectCount();
if (projectCount > 0) {
await projectListPage.viewProject(0);
await page.waitForNavigation();
expect(page.url()).toContain('/projects/');
} else {
// If no projects, skip this test
test.skip();
}
});

test('should delete a project', async ({ page }) => {
const projectCount = await projectListPage.getProjectCount();
if (projectCount > 0) {
const initialCount = projectCount;
await projectListPage.deleteProject(0);

// Assume there's a confirmation dialog
await page.click('.el-message-box__btns .el-button--primary');

await page.waitForTimeout(1000); // Wait for deletion to process
const newCount = await projectListPage.getProjectCount();
expect(newCount).toBe(initialCount - 1);
} else {
// If no projects, skip this test
test.skip();
}
});
});

0 comments on commit fb12afe

Please sign in to comment.