diff --git a/tests/2-TR-4-TC-1.js b/tests/2-TR-4-TC-1.js new file mode 100644 index 0000000..0367717 --- /dev/null +++ b/tests/2-TR-4-TC-1.js @@ -0,0 +1,32 @@ +import { test, expect } from '@playwright/test'; + +test.describe('Admin Client Management', () => { + test('should log in as admin and add a new client', async ({ page }) => { + // Go to the login page + await page.goto('https://darkviolet-tarsier-894132.hostingersite.com/login.php'); + + // Login as admin + await page.getByRole('textbox', { name: /Email Address/i }).fill('admin@example.com'); + await page.getByRole('textbox', { name: /Password/i }).fill('password123'); + await page.getByRole('button', { name: /Login Now/i }).click(); + + // Expect to reach dashboard + await expect(page).toHaveURL(/dashboard/i); + + // Navigate to Clients -> Add Client + await page.getByRole('link', { name: /Clients/i }).click(); + await page.getByRole('link', { name: /Add Client/i }).click(); + + // Fill out client details + await page.getByLabel('Client Name').selectOption('225'); + await page.getByLabel('Assign to Lawyer').selectOption('2'); + await page.getByRole('textbox', { name: /Phone Number/i }).fill('09761144420'); + await page.getByRole('textbox', { name: /Address/i }).fill('Somewhere inside the Calipso'); + + // Save client + await page.getByRole('button', { name: /Save Client/i }).click(); + + // Verify success + await expect(page.locator('text=Client added successfully')).toBeVisible({ timeout: 5000 }); + }); +}); diff --git a/tests/2-TR-5-TC-2.js b/tests/2-TR-5-TC-2.js new file mode 100644 index 0000000..b532a46 --- /dev/null +++ b/tests/2-TR-5-TC-2.js @@ -0,0 +1,27 @@ +import { test, expect } from '@playwright/test'; + +test.describe('Admin Dashboard Navigation', () => { + test('should log in as admin and navigate to Clients page', async ({ page }) => { + // Go to login page + await page.goto('https://darkviolet-tarsier-894132.hostingersite.com/login.php'); + + // Fill in login form + await page.getByRole('textbox', { name: /Email Address/i }).fill('admin@example.com'); + await page.getByRole('textbox', { name: /Password/i }).fill('password123'); + + // Submit the form + await page.getByRole('button', { name: /Login Now/i }).click(); + + // Verify successful login + await expect(page).toHaveURL(/dashboard/i); + + // Navigate to Dashboard + await page.getByRole('link', { name: /Dashboard/i }).click(); + + // Navigate to Clients page + await page.getByRole('link', { name: /Clients/i }).click(); + + // Verify Clients page loaded + await expect(page).toHaveURL(/clients/i); + }); +}); diff --git a/tests/2-TR-5-TC-3.js b/tests/2-TR-5-TC-3.js new file mode 100644 index 0000000..c49eff2 --- /dev/null +++ b/tests/2-TR-5-TC-3.js @@ -0,0 +1,34 @@ +import { test, expect } from '@playwright/test'; + +test.describe('Admin User Editing', () => { + test('should log in and update user information successfully', async ({ page }) => { + // --- LOGIN --- + await page.goto('https://darkviolet-tarsier-894132.hostingersite.com/login.php'); + await page.getByRole('textbox', { name: /Email Address/i }).fill('admin@example.com'); + await page.getByRole('textbox', { name: /Password/i }).fill('password123'); + await page.getByRole('button', { name: /Login Now/i }).click(); + + // Verify successful login + await expect(page).toHaveURL(/dashboard/i); + + // --- NAVIGATE TO USERS PAGE --- + await page.getByRole('link', { name: /Users/i }).click(); + await expect(page).toHaveURL(/users/i); + + // --- EDIT SPECIFIC USER --- + // Click the 3rd edit button (index 2) + await page.getByRole('button', { name: // }).nth(2).click(); + + // Update form fields + await page.locator('input[name="last_name"]').fill('Cheessezeronio'); + await page.locator('input[name="first_name"]').fill('Eddie_cheesecake'); + await page.getByRole('combobox').selectOption('partner'); + + // Save changes + await page.getByRole('button', { name: /Save Changes/i }).click(); + + // --- VERIFY SUCCESS --- + // Optional: update this to match your real success message + await expect(page.locator('text=User updated successfully')).toBeVisible({ timeout: 5000 }); + }); +}); diff --git a/tests/2-TR-5-TC-4.js b/tests/2-TR-5-TC-4.js new file mode 100644 index 0000000..4a86ab6 --- /dev/null +++ b/tests/2-TR-5-TC-4.js @@ -0,0 +1,32 @@ +import { test, expect } from '@playwright/test'; + +test.describe('Admin User Management', () => { + test('should log in and delete a user successfully', async ({ page }) => { + // Go to the login page + await page.goto('https://darkviolet-tarsier-894132.hostingersite.com/login.php'); + + // --- LOGIN --- + await page.getByRole('textbox', { name: /Email Address/i }).fill('admin@example.com'); + await page.getByRole('textbox', { name: /Password/i }).fill('password123'); + await page.getByRole('button', { name: /Login Now/i }).click(); + + // Verify redirect to dashboard + await expect(page).toHaveURL(/dashboard/i); + + // --- NAVIGATE TO USERS --- + await page.getByRole('link', { name: /Users/i }).click(); + await expect(page).toHaveURL(/users/i); + + // --- DELETE A USER --- + // Click the first action button for a user + await page.locator('.action-buttons').first().click(); + + // Confirm deletion + await page.getByRole('button', { name: /Delete User/i }).click(); + await page.getByRole('button', { name: /^OK$/i }).click(); + + // --- VERIFY USER IS DELETED --- + // Example: check for success message or absence of user name + await expect(page.locator('text=User deleted successfully')).toBeVisible({ timeout: 5000 }); + }); +}); diff --git a/tests/2-TR-5-TC-6.js b/tests/2-TR-5-TC-6.js new file mode 100644 index 0000000..068fde3 --- /dev/null +++ b/tests/2-TR-5-TC-6.js @@ -0,0 +1,22 @@ +import { test, expect } from '@playwright/test'; + +test.describe('Lawyer Dashboard Navigation', () => { + test('should log in as lawyer and access the Clients page', async ({ page }) => { + // --- LOGIN --- + await page.goto('https://darkviolet-tarsier-894132.hostingersite.com/login.php'); + + await page.getByRole('textbox', { name: /Email Address/i }).fill('lawyer@example.com'); + await page.getByRole('textbox', { name: /Password/i }).fill('password123'); + await page.getByRole('button', { name: /Login Now/i }).click(); + + // Verify successful login + await expect(page).toHaveURL(/dashboard/i); + await expect(page.locator('span.badge-role')).toHaveText(/Lawyer/i); + + // --- NAVIGATE TO CLIENTS --- + await page.getByRole('link', { name: /Clients/i }).click(); + + // Verify Clients page loaded + await expect(page).toHaveURL(/clients/i); + }); +});