mascarpone/e2e/pages/contact.spec.ts

102 lines
3.8 KiB
TypeScript
Raw Normal View History

import { test, expect } from '@playwright/test';
import { login, verifyCreateUser, todate } from './util';
test.beforeEach(async ({ page }) => {
await login(page);
await verifyCreateUser(page, { names: ['Test Testerson'] });
});
test('manual-freshen date is editable', async ({ page }) => {
await page.getByRole('link', { name: /edit/i }).click();
await expect(page.locator('input[name="manually_freshened_on"]')).toBeVisible();
});
test('last-contact date on display resolves journal mentions and manual-freshen', async ({ page }) => {
const today = new Date().toISOString().split("T")[0];
const todayRe = new RegExp(today.substring(0, today.length - 1) + ".");
const entryDate = page.getByPlaceholder(todayRe);
const entryBox = page.getByPlaceholder(/new entry/i);
await entryDate.fill("2025-05-05");
await entryBox.fill("[[Test Testerson]]");
let load = page.waitForResponse('/journal_entry');
await page.getByRole('button', { name: /add entry/i }).click();
await load;
await page.reload();
await expect(page.locator('#fields')).toContainText("freshened2025-05-05");
});
test.skip("groups wrap nicely", async ({ page }) => {
await page.getByRole('link', { name: /edit/i }).click();
const groupBox = page.getByPlaceholder(/group name/i);
await groupBox.fill('this is a long group name');
2026-04-03 11:54:36 -05:00
await page.getByRole('button', { name: /save/i }).click();
2026-04-03 11:54:36 -05:00
// TODO: this drives to the right location but i can't figure out how to assert
// that the text is all on one line. Manual inspection looks good at time of writing.
});
2026-04-03 11:54:36 -05:00
test('allow marking as inactive', async ({ page }) => {
await page.getByRole('link', { name: /edit/i }).click();
await page.getByLabel('status').selectOption('Inactive');
await page.getByRole('button', { name: /save/i }).click();
await expect(page.locator('#contacts-sidebar').getByText("Test Testerson")).not.toBeVisible();
});
test('allow exempting from stale', async ({ page }) => {
await page.goto('/');
await expect(page.locator('#freshness')).toContainText('Test Testersonnever');
await page.locator('#freshness').getByRole('link', { name: /testerson/i }).click();
await page.getByRole('link', { name: /edit/i }).click();
await page.getByLabel('status').selectOption('Cannot go stale');
await page.getByRole('button', { name: /save/i }).click();
await page.waitForURL(/contact\/\d+$/);
await page.goto('/');
await expect(page.locator('#freshness')).not.toContainText('Test Testersonnever');
});
2026-04-03 11:54:36 -05:00
test('stale list considers periodicity', async ({ page }) => {
await page.getByRole('link', { name: /edit/i }).click();
const last_week = (() => {
let last_week = new Date();
last_week.setDate(last_week.getDate() - 7);
return last_week.toISOString().split("T")[0];
})();
await page.getByLabel('freshened').fill(last_week);
await page.getByRole('button', { name: /save/i }).click();
await expect(page.locator('#journal')).toBeVisible();
await expect(page.locator('#fields')).toContainText(`freshened${last_week}`);
await page.goto('/');
await expect(page.locator('#freshness')).toContainText(`Test Testerson${last_week}7d`);
await page.locator('#freshness').getByRole('link', { name: /testerson/i }).click();
await page.getByRole('link', { name: /edit/i }).click();
await page.getByLabel('minimum stale time').fill('2 weeks');
await page.getByRole('button', { name: /save/i }).click();
await expect(page.locator('#journal')).toBeVisible();
await page.goto('/');
await expect(page.locator('#freshness')).not.toContainText(`Test Testerson`);
});
2026-04-03 11:54:36 -05:00
test('page title has contact primary name', async ({ page }) => {
// wait for page load to finish
await expect(page.locator('#journal')).toBeVisible();
expect(await page.title()).toContain("Test Testerson");
});
2026-04-03 11:54:36 -05:00
/*
2026-04-03 11:54:36 -05:00
test('bullet points in free text display well', async ({ page }) => {
});
journal: bullet points don't display
*/