3.0 Tests primero
pgTAP: 005_tasks_rls.sql (5 — completion CHECK), 006_notes_trash_purge.sql (4 — purge SQL inline + pin/archive CHECK)
Vitest RLS: rls-tasks.test.ts (14), rls-notes.test.ts (15)
Playwright: tasks.test.ts (3), notes.test.ts (4)
3.1 Tareas
Migration 008_tasks.sql: task_lists + tasks + task_list_collective_id() helper
CHECK constraint: is_completed ⇔ completed_by ⇔ completed_at
RLS by role + cross-collective isolation
Store apps/web/src/lib/stores/tasks.ts (optimistic CRUD + reorder)
/tasks overview (grid + sticky create input + 5s polling)
/tasks/[id] detail with svelte-dnd-action reorder, flip animation,
inline edit (dblclick), "Completed by …" attribution via lazy-loaded
collective_members
3.2 Notas
Migration 009_notes.sql: notes + note_color enum (8) + pin/archive CHECK
+ 7d trash window in RLS + fn_notes_touch trigger + pg_cron purge job
Store apps/web/src/lib/stores/notes.ts (CRUD + pin/archive/trash/duplicate)
/notes board (pinned section testid notes-pinned + 30s polling)
/notes/[id] editor (title + textarea, 500ms debounced autosave,
color picker, pin/archive/duplicate/trash actions)
/notes/archive (restore + send to trash)
/notes/trash (restore + permanent delete)
3.Z Verification
just test-all → 148 verdes, 2 skipped:
25 pgTAP (was 16, +9)
88 Vitest integration (was 59, +29; 2 presence skipped)
6 Vitest unit (unchanged)
29 Playwright (was 22, +3 tasks +4 notes)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
109 lines
3.9 KiB
TypeScript
109 lines
3.9 KiB
TypeScript
/**
|
|
* T-series (UI) — Fase 3.1
|
|
*
|
|
* Task lists overview at /tasks; per-list detail at /tasks/[id]. Members can
|
|
* create, complete, edit, delete, and reorder tasks. Guests see them but
|
|
* cannot mutate. Completed tasks sink to the bottom and show "Completed by …".
|
|
*/
|
|
import { test, expect, type Page } from '@playwright/test';
|
|
import { USERS } from '../fixtures/users.js';
|
|
import { loginAs } from '../fixtures/login.js';
|
|
|
|
const NEW_LIST_PLACEHOLDER = /new task list|nueva lista de tareas/i;
|
|
const NEW_TASK_PLACEHOLDER = /add task|añadir tarea/i;
|
|
|
|
async function gotoTasksClean(page: Page) {
|
|
await page.goto('/tasks');
|
|
await expect(page.getByPlaceholder(NEW_LIST_PLACEHOLDER)).toBeVisible({ timeout: 15_000 });
|
|
}
|
|
|
|
async function createTaskList(page: Page, name: string) {
|
|
const input = page.getByPlaceholder(NEW_LIST_PLACEHOLDER);
|
|
await input.fill(name);
|
|
await input.press('Enter');
|
|
const heading = page.getByRole('heading', { name: new RegExp(`^${name}$`) });
|
|
await expect(heading).toBeVisible({ timeout: 5_000 });
|
|
await heading.click();
|
|
await expect(page).toHaveURL(/\/tasks\/[0-9a-f-]+$/, { timeout: 5_000 });
|
|
}
|
|
|
|
test.describe('Tasks — member (Borja)', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAs(page, USERS.borja);
|
|
});
|
|
|
|
test('T-UI-01: create list, add task, complete it, see "Completed by …" tooltip', async ({
|
|
page
|
|
}) => {
|
|
await gotoTasksClean(page);
|
|
const listName = `Tasks ${Date.now()}`;
|
|
await createTaskList(page, listName);
|
|
|
|
const taskInput = page.getByPlaceholder(NEW_TASK_PLACEHOLDER);
|
|
await expect(taskInput).toBeVisible({ timeout: 5_000 });
|
|
const taskTitle = `Buy milk ${Date.now()}`;
|
|
await taskInput.fill(taskTitle);
|
|
await taskInput.press('Enter');
|
|
|
|
const row = page.locator('[role="listitem"]').filter({ hasText: taskTitle });
|
|
await expect(row).toBeVisible({ timeout: 5_000 });
|
|
|
|
// Toggle complete
|
|
await row.getByRole('button', { name: /toggle task|alternar tarea/i }).click();
|
|
|
|
// Title is decorated as completed (line-through). Check via aria.
|
|
await expect(
|
|
page
|
|
.locator('[role="listitem"]')
|
|
.filter({ hasText: taskTitle })
|
|
.getByRole('button', { name: /uncheck task|desmarcar tarea/i })
|
|
).toBeVisible({ timeout: 5_000 });
|
|
|
|
// "Completed by Borja" tooltip / metadata visible somewhere on the row.
|
|
await expect(
|
|
page.locator('[role="listitem"]').filter({ hasText: taskTitle }).getByText(/borja/i)
|
|
).toBeVisible({ timeout: 5_000 });
|
|
});
|
|
|
|
test('T-UI-02: delete a task removes it from the list', async ({ page }) => {
|
|
await gotoTasksClean(page);
|
|
const listName = `Tasks-del ${Date.now()}`;
|
|
await createTaskList(page, listName);
|
|
|
|
const taskInput = page.getByPlaceholder(NEW_TASK_PLACEHOLDER);
|
|
const taskTitle = `Delete me ${Date.now()}`;
|
|
await taskInput.fill(taskTitle);
|
|
await taskInput.press('Enter');
|
|
|
|
const row = page.locator('[role="listitem"]').filter({ hasText: taskTitle });
|
|
await expect(row).toBeVisible({ timeout: 5_000 });
|
|
|
|
await row.getByRole('button', { name: /delete task|eliminar tarea/i }).click();
|
|
await expect(
|
|
page.locator('[role="listitem"]').filter({ hasText: taskTitle })
|
|
).toHaveCount(0, { timeout: 5_000 });
|
|
});
|
|
});
|
|
|
|
test.describe('Tasks — guest (David, read-only)', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAs(page, USERS.david);
|
|
});
|
|
|
|
test('T-UI-03: guest can navigate to /tasks but cannot create lists', async ({ page }) => {
|
|
await page.goto('/tasks');
|
|
// Either the create input is hidden, or it exists but typing into it
|
|
// must NOT produce a committed list (RLS blocks the insert).
|
|
const input = page.getByPlaceholder(NEW_LIST_PLACEHOLDER);
|
|
if (await input.isVisible({ timeout: 2_000 }).catch(() => false)) {
|
|
const name = `David sneaky ${Date.now()}`;
|
|
await input.fill(name);
|
|
await input.press('Enter');
|
|
await page.waitForTimeout(1_500);
|
|
await expect(
|
|
page.getByRole('heading', { name: new RegExp(`^${name}$`) })
|
|
).not.toBeVisible({ timeout: 2_000 });
|
|
}
|
|
});
|
|
});
|