Sales (24 tests): - Dashboard metrics and navigation - Leads CRUD and filtering - Opportunities list and kanban - Activities calendar and management MLM (24 tests): - Dashboard and network overview - Structures management - Ranks and progression - My Network tree visualization - My Earnings history Goals (24 tests): - Dashboard and metrics - Goal definitions CRUD - My Goals and progress tracking - Reports and filtering Total: 72 new Playwright E2E tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
213 lines
8.1 KiB
TypeScript
213 lines
8.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { test as authTest } from '../fixtures/auth.fixture';
|
|
import { waitForPageLoad, fillForm, expectToast, getTableRowCount } from '../utils/helpers';
|
|
|
|
test.describe('Sales Dashboard', () => {
|
|
authTest('should display sales dashboard', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show sales dashboard
|
|
await expect(page.locator('[data-testid="sales-dashboard"], .sales-dashboard, h1:has-text("Sales")')).toBeVisible();
|
|
});
|
|
|
|
authTest('should show sales metrics cards', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show key metrics
|
|
const metricsContainer = page.locator('[data-testid="sales-metrics"], .sales-metrics, .stats-grid');
|
|
if (await metricsContainer.isVisible()) {
|
|
// Check for metric cards
|
|
const metricCards = page.locator('[data-testid="metric-card"], .metric-card, .stat-card');
|
|
expect(await metricCards.count()).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
authTest('should have navigation to leads', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales');
|
|
|
|
// Click on leads link
|
|
await page.click('a[href*="leads"]');
|
|
await expect(page).toHaveURL(/\/sales\/leads/);
|
|
});
|
|
|
|
authTest('should have navigation to opportunities', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales');
|
|
|
|
// Click on opportunities link
|
|
await page.click('a[href*="opportunities"]');
|
|
await expect(page).toHaveURL(/\/sales\/opportunities/);
|
|
});
|
|
});
|
|
|
|
test.describe('Sales Leads', () => {
|
|
authTest('should display leads list', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show leads page
|
|
await expect(page.locator('h1:has-text("Leads"), [data-testid="leads-page"]')).toBeVisible();
|
|
});
|
|
|
|
authTest('should show leads table or list', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show table or list
|
|
const table = page.locator('table, [data-testid="leads-table"], [data-testid="leads-list"]');
|
|
await expect(table).toBeVisible();
|
|
});
|
|
|
|
authTest('should have create lead button', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
|
|
// Should show create button
|
|
const createButton = page.locator('button:has-text("New Lead"), button:has-text("Create"), [data-testid="create-lead"]');
|
|
await expect(createButton).toBeVisible();
|
|
});
|
|
|
|
authTest('should open create lead modal/form', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
|
|
// Click create button
|
|
await page.click('button:has-text("New Lead"), button:has-text("Create"), [data-testid="create-lead"]');
|
|
|
|
// Should show form/modal
|
|
const form = page.locator('form, [data-testid="lead-form"], [role="dialog"]');
|
|
await expect(form).toBeVisible();
|
|
});
|
|
|
|
authTest('should filter leads by status', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
await waitForPageLoad(page);
|
|
|
|
// Look for status filter
|
|
const statusFilter = page.locator('[data-testid="status-filter"], select[name="status"], [data-testid="filter-dropdown"]');
|
|
if (await statusFilter.isVisible()) {
|
|
await statusFilter.click();
|
|
// Select a status option
|
|
await page.click('[data-testid="status-new"], [data-value="new"], option:has-text("New")');
|
|
}
|
|
});
|
|
|
|
authTest('should search leads', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
await waitForPageLoad(page);
|
|
|
|
// Look for search input
|
|
const searchInput = page.locator('input[type="search"], input[placeholder*="search" i], [data-testid="search-input"]');
|
|
if (await searchInput.isVisible()) {
|
|
await searchInput.fill('test');
|
|
// Wait for results to update
|
|
await page.waitForTimeout(500);
|
|
}
|
|
});
|
|
|
|
authTest('should show lead detail on row click', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
await waitForPageLoad(page);
|
|
|
|
// Click first row if table has data
|
|
const firstRow = page.locator('table tbody tr, [data-testid="lead-row"]').first();
|
|
if (await firstRow.isVisible()) {
|
|
await firstRow.click();
|
|
// Should navigate to detail page
|
|
await expect(page).toHaveURL(/\/sales\/leads\/.+/);
|
|
}
|
|
});
|
|
});
|
|
|
|
test.describe('Sales Opportunities', () => {
|
|
authTest('should display opportunities list', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/opportunities');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show opportunities page
|
|
await expect(page.locator('h1:has-text("Opportunities"), [data-testid="opportunities-page"]')).toBeVisible();
|
|
});
|
|
|
|
authTest('should show opportunities table or kanban', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/opportunities');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show table or kanban board
|
|
const view = page.locator('table, [data-testid="opportunities-table"], [data-testid="kanban-board"], .kanban');
|
|
await expect(view).toBeVisible();
|
|
});
|
|
|
|
authTest('should have create opportunity button', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/opportunities');
|
|
|
|
// Should show create button
|
|
const createButton = page.locator('button:has-text("New Opportunity"), button:has-text("Create"), [data-testid="create-opportunity"]');
|
|
await expect(createButton).toBeVisible();
|
|
});
|
|
|
|
authTest('should filter opportunities by stage', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/opportunities');
|
|
await waitForPageLoad(page);
|
|
|
|
// Look for stage filter
|
|
const stageFilter = page.locator('[data-testid="stage-filter"], select[name="stage"]');
|
|
if (await stageFilter.isVisible()) {
|
|
await stageFilter.click();
|
|
}
|
|
});
|
|
});
|
|
|
|
test.describe('Sales Activities', () => {
|
|
authTest('should display activities list', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/activities');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show activities page
|
|
await expect(page.locator('h1:has-text("Activities"), [data-testid="activities-page"]')).toBeVisible();
|
|
});
|
|
|
|
authTest('should show activities calendar or list', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/activities');
|
|
await waitForPageLoad(page);
|
|
|
|
// Should show calendar or list view
|
|
const view = page.locator('table, [data-testid="activities-list"], [data-testid="activities-calendar"], .calendar');
|
|
await expect(view).toBeVisible();
|
|
});
|
|
|
|
authTest('should have create activity button', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/activities');
|
|
|
|
// Should show create button
|
|
const createButton = page.locator('button:has-text("New Activity"), button:has-text("Schedule"), [data-testid="create-activity"]');
|
|
await expect(createButton).toBeVisible();
|
|
});
|
|
|
|
authTest('should filter activities by type', async ({ authenticatedPage: page }) => {
|
|
await page.goto('/dashboard/sales/activities');
|
|
await waitForPageLoad(page);
|
|
|
|
// Look for type filter
|
|
const typeFilter = page.locator('[data-testid="type-filter"], select[name="type"]');
|
|
if (await typeFilter.isVisible()) {
|
|
await typeFilter.click();
|
|
}
|
|
});
|
|
});
|
|
|
|
test.describe('Sales - Unauthenticated', () => {
|
|
test('should redirect to login if not authenticated', async ({ page }) => {
|
|
await page.goto('/dashboard/sales');
|
|
await expect(page).toHaveURL(/\/auth\/login/);
|
|
});
|
|
|
|
test('should redirect leads page to login', async ({ page }) => {
|
|
await page.goto('/dashboard/sales/leads');
|
|
await expect(page).toHaveURL(/\/auth\/login/);
|
|
});
|
|
|
|
test('should redirect opportunities page to login', async ({ page }) => {
|
|
await page.goto('/dashboard/sales/opportunities');
|
|
await expect(page).toHaveURL(/\/auth\/login/);
|
|
});
|
|
});
|