148 lines
6.1 KiB
TypeScript
148 lines
6.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { login, TEST_ORG_SLUG, TEST_EMAIL, waitForHydration, navigateTo } from './helpers';
|
|
|
|
test('should log in and reach org dashboard', async ({ page }) => {
|
|
await login(page);
|
|
await expect(page).toHaveURL(new RegExp(`/${TEST_ORG_SLUG}`));
|
|
});
|
|
|
|
test.describe('Sidebar', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await login(page);
|
|
});
|
|
|
|
test('should display logo in sidebar', async ({ page }) => {
|
|
const logo = page.locator('aside svg');
|
|
await expect(logo.first()).toBeVisible();
|
|
});
|
|
|
|
test('should display user avatar and email in sidebar', async ({ page }) => {
|
|
const userMenuBtn = page.locator('.user-menu-container button').first();
|
|
await expect(userMenuBtn).toBeVisible();
|
|
// Should show user email
|
|
await expect(page.locator('.user-menu-container').getByText(TEST_EMAIL)).toBeVisible();
|
|
});
|
|
|
|
test('should show user dropdown on avatar click with correct items', async ({ page }) => {
|
|
const btn = page.locator('.user-menu-container button[aria-haspopup="true"]');
|
|
await expect(btn).toBeVisible();
|
|
await btn.click();
|
|
await expect(btn).toHaveAttribute('aria-expanded', 'true', { timeout: 3000 });
|
|
await expect(page.getByText('Account Settings').first()).toBeVisible();
|
|
await expect(page.getByText('Switch Organization')).toBeVisible();
|
|
await expect(page.getByText('Log Out')).toBeVisible();
|
|
});
|
|
|
|
test('should close user dropdown on Escape', async ({ page }) => {
|
|
const btn = page.locator('.user-menu-container button[aria-haspopup="true"]');
|
|
await btn.click();
|
|
await expect(btn).toHaveAttribute('aria-expanded', 'true', { timeout: 3000 });
|
|
await page.keyboard.press('Escape');
|
|
await expect(btn).toHaveAttribute('aria-expanded', 'false', { timeout: 3000 });
|
|
});
|
|
|
|
test('should navigate to account settings from dropdown', async ({ page }) => {
|
|
const btn = page.locator('.user-menu-container button[aria-haspopup="true"]');
|
|
await btn.click();
|
|
await expect(btn).toHaveAttribute('aria-expanded', 'true', { timeout: 3000 });
|
|
await page.getByText('Account Settings').first().click();
|
|
await page.waitForURL(new RegExp(`/${TEST_ORG_SLUG}/account`), { timeout: 10000 });
|
|
await expect(page.getByRole('heading', { name: 'Account Settings' })).toBeVisible();
|
|
});
|
|
|
|
test('sidebar nav items should be visible', async ({ page }) => {
|
|
const aside = page.locator('aside');
|
|
await expect(aside).toBeVisible();
|
|
const navLinks = aside.locator('nav a');
|
|
const count = await navLinks.count();
|
|
expect(count).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
test.describe('Account Settings Page', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await navigateTo(page, `/${TEST_ORG_SLUG}/account`);
|
|
});
|
|
|
|
test('should display Profile section with all elements', async ({ page }) => {
|
|
await expect(page.getByRole('heading', { name: 'Profile' })).toBeVisible({ timeout: 10000 });
|
|
await expect(page.getByText('Display Name')).toBeVisible();
|
|
await expect(page.getByText('Email').first()).toBeVisible();
|
|
await expect(page.getByRole('button', { name: 'Upload' })).toBeVisible();
|
|
await expect(page.getByRole('button', { name: 'Sync Google' })).toBeVisible();
|
|
await expect(page.getByRole('button', { name: 'Save Profile' }).first()).toBeVisible();
|
|
});
|
|
|
|
test('should display Appearance section with color picker', async ({ page }) => {
|
|
await expect(page.getByRole('heading', { name: 'Appearance' })).toBeVisible();
|
|
await expect(page.getByText('Accent Color')).toBeVisible();
|
|
// Custom color picker label
|
|
const colorPicker = page.locator('label[title="Custom color"]');
|
|
await expect(colorPicker).toBeVisible();
|
|
// Org theme toggle
|
|
await expect(page.getByText('Use Organization Theme')).toBeVisible();
|
|
await expect(page.getByRole('button', { name: 'Save Preferences' })).toBeVisible();
|
|
});
|
|
|
|
test('should display Security & Sessions section', async ({ page }) => {
|
|
await expect(page.getByRole('heading', { name: 'Security & Sessions' })).toBeVisible();
|
|
await expect(page.getByRole('button', { name: 'Send Reset Email' })).toBeVisible();
|
|
await expect(page.getByRole('button', { name: 'Sign Out Other Sessions' })).toBeVisible();
|
|
});
|
|
|
|
test('accent color swatches should be clickable', async ({ page }) => {
|
|
const swatches = page.locator('.flex.flex-wrap button[type="button"]');
|
|
const count = await swatches.count();
|
|
expect(count).toBeGreaterThanOrEqual(8);
|
|
// Click the third swatch (Red)
|
|
await swatches.nth(2).click();
|
|
await expect(swatches.nth(2)).toHaveClass(/border-white/);
|
|
});
|
|
});
|
|
|
|
test.describe('Kanban Page - ContextMenu', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await navigateTo(page, `/${TEST_ORG_SLUG}/kanban`);
|
|
});
|
|
|
|
test('should load kanban page', async ({ page }) => {
|
|
await expect(page.getByRole('heading', { name: 'Kanban' })).toBeVisible();
|
|
});
|
|
|
|
test('should have context menu button in header', async ({ page }) => {
|
|
const moreBtn = page.getByRole('button', { name: 'More options' });
|
|
await expect(moreBtn).toBeVisible();
|
|
});
|
|
|
|
test('should open context menu on click', async ({ page }) => {
|
|
const moreBtn = page.getByRole('button', { name: 'More options' });
|
|
await moreBtn.click();
|
|
await expect(moreBtn).toHaveAttribute('aria-expanded', 'true', { timeout: 3000 });
|
|
// Menu dropdown should be visible
|
|
const menu = page.locator('.context-menu-container div.absolute');
|
|
await expect(menu).toBeVisible({ timeout: 3000 });
|
|
});
|
|
});
|
|
|
|
test.describe('Calendar Page - ContextMenu', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await navigateTo(page, `/${TEST_ORG_SLUG}/calendar`);
|
|
});
|
|
|
|
test('should load calendar page', async ({ page }) => {
|
|
await expect(page.getByRole('heading', { name: 'Calendar' })).toBeVisible();
|
|
});
|
|
|
|
test('should have context menu button in header', async ({ page }) => {
|
|
const moreBtn = page.getByRole('button', { name: 'More options' });
|
|
await expect(moreBtn).toBeVisible();
|
|
});
|
|
|
|
test('should show Refresh Events in context menu', async ({ page }) => {
|
|
const moreBtn = page.getByRole('button', { name: 'More options' });
|
|
await moreBtn.click();
|
|
await expect(moreBtn).toHaveAttribute('aria-expanded', 'true', { timeout: 3000 });
|
|
await expect(page.getByText('Refresh Events')).toBeVisible({ timeout: 3000 });
|
|
});
|
|
});
|