From 381d625f54c70b6b2f4988f4403e50fc5166a747 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Thu, 24 Oct 2024 15:32:32 +0800 Subject: [PATCH] test: updated test cases --- tests/project/projectList.spec.ts | 38 ++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/tests/project/projectList.spec.ts b/tests/project/projectList.spec.ts index 1f68da1..26fc86f 100644 --- a/tests/project/projectList.spec.ts +++ b/tests/project/projectList.spec.ts @@ -32,18 +32,6 @@ test.describe('Project List Tests', () => { } }); - test('should navigate to project detail', async ({ page }) => { - const projectCount = await projectListPage.getTableRowCount(); - if (projectCount > 0) { - await projectListPage.navigateToDetail(0); - await page.waitForSelector('.detail-layout'); - expect(page.url()).toContain('/projects/'); - } else { - // If no projects, skip this test - test.skip(); - } - }); - test('should verify project form placeholders', async () => { await projectListPage.clickCreate(); @@ -90,19 +78,23 @@ test.describe('Project List Tests', () => { expect(lastProjectData.description).toBe(projectDescription); }); + test('should navigate to project detail', async ({ page }) => { + const projectCount = await projectListPage.getTableRowCount(); + expect(projectCount).toBeGreaterThan(0); + await projectListPage.navigateToDetail(0); + await page.waitForSelector('.detail-layout'); + expect(page.url()).toMatch(/\/projects\/[0-9a-f]{24}/); + }); + test('should delete a project', async ({ page }) => { const projectCount = await projectListPage.getTableRowCount(); - if (projectCount > 0) { - const initialCount = projectCount; - await projectListPage.deleteRow(0); - - await page.waitForTimeout(1000); // Wait for deletion to process - const newCount = await projectListPage.getTableRowCount(); - expect(newCount).toBe(initialCount - 1); - } else { - // If no projects, skip this test - test.skip(); - } + expect(projectCount).toBeGreaterThan(0); + const initialCount = projectCount; + await projectListPage.deleteRow(0); + + await page.waitForTimeout(1000); // Wait for deletion to process + const newCount = await projectListPage.getTableRowCount(); + expect(newCount).toBe(initialCount - 1); }); }); });