fix,feat: mention behavior and page titles
This commit is contained in:
parent
7e2f5d0a18
commit
79a054ab40
22 changed files with 314 additions and 140 deletions
37
e2e/custom-expects.ts
Normal file
37
e2e/custom-expects.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { expect, type Locator } from '@playwright/test';
|
||||
expect.extend({
|
||||
async toBeAbove(self: Locator, other: Locator) {
|
||||
const name = 'toBeAbove';
|
||||
let pass: boolean;
|
||||
let matcherResult: any;
|
||||
let selfY: number | null = null;
|
||||
let otherY: number | null = null;
|
||||
try {
|
||||
selfY = (await self.boundingBox())?.y ?? null;
|
||||
otherY = (await self.boundingBox())?.y ?? null;
|
||||
pass = selfY !== null && otherY !== null && (selfY < otherY);
|
||||
} catch (e: any) {
|
||||
matcherResult = e.matcherResult;
|
||||
pass = false;
|
||||
}
|
||||
|
||||
if (this.isNot) {
|
||||
pass =!pass;
|
||||
}
|
||||
|
||||
const message = () => this.utils.matcherHint(name, undefined, undefined, { isNot: this.isNot }) +
|
||||
'\n\n' +
|
||||
`Locator: ${self}\n` +
|
||||
`Expected: above ${other} (y=${this.utils.printExpected(otherY)})\n` +
|
||||
(matcherResult ? `Received: y=${this.utils.printReceived(selfY)}` : '');
|
||||
|
||||
return {
|
||||
message,
|
||||
pass,
|
||||
name,
|
||||
expected: (this.isNot ? '>=' : '<') + otherY,
|
||||
actual: selfY,
|
||||
};
|
||||
|
||||
}
|
||||
});
|
||||
62
e2e/pages/contact.spec.ts
Normal file
62
e2e/pages/contact.spec.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
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'] });
|
||||
await expect(page.locator('#alpine-loaded')).not.toHaveAttribute('x-cloak');
|
||||
});
|
||||
|
||||
test('manual-freshen date is editable', async ({ page }) => {
|
||||
await page.getByRole('link', { name: /edit/i }).click();
|
||||
await expect(page.getByRole('textbox', { name: /freshened/i })).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]]");
|
||||
await page.getByRole('button', { name: /add entry/i }).click();
|
||||
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();
|
||||
await expect(page.locator('#alpine-loaded')).not.toHaveAttribute('x-cloak');
|
||||
|
||||
const groupBox = page.getByPlaceholder(/group name/i);
|
||||
await groupBox.fill('this is a long group name');
|
||||
await page.getByRole('button', { name: /save/i }).click();
|
||||
await expect(page.locator('#alpine-loaded')).not.toHaveAttribute('x-cloak');
|
||||
|
||||
// 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.
|
||||
});
|
||||
|
||||
test('allow marking as hidden', async ({ page }) => {
|
||||
|
||||
});
|
||||
|
||||
test('allow exempting from stale', async ({ page }) => {
|
||||
|
||||
});
|
||||
|
||||
test('bullet points in free text display well', async ({ page }) => {
|
||||
|
||||
});
|
||||
|
||||
twst('page title has contact primary name', async ({ page }) => {
|
||||
await expect(page.title()).toContain("Test Testerson");
|
||||
});
|
||||
|
||||
/*
|
||||
home: contact list scrolls in screen, not off screen
|
||||
home: clicking off contact list closes it
|
||||
home: contact list is sorted ignoring case
|
||||
home: contact list should scroll to current contact in center of view
|
||||
journal: bullet points don't display
|
||||
*/
|
||||
|
|
@ -1,28 +1,26 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { login, verifyCreateUser, todate } from './util';
|
||||
|
||||
test('can log out', async ({ page }) => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('can log out', async ({ page }) => {
|
||||
await page.getByText("Logout").click();
|
||||
await expect(page.getByLabel("Username")).toBeVisible();
|
||||
});
|
||||
|
||||
test('has no contacts', async ({ page }) => {
|
||||
await login(page);
|
||||
|
||||
await expect(page.getByRole("navigation").getByRole("link")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('can add contacts', async ({ page }) => {
|
||||
await login(page);
|
||||
await verifyCreateUser(page, { names: ['John Contact'] });
|
||||
await verifyCreateUser(page, { names: ['Jack Contact'] });
|
||||
await expect(page.getByRole("navigation").getByRole("link")).toHaveCount(2);
|
||||
});
|
||||
|
||||
test('shows "never" for unfreshened contacts', async ({ page }) => {
|
||||
await login(page);
|
||||
await verifyCreateUser(page, { names: ['John Contact'] });
|
||||
await page.getByRole('link', { name: 'Mascarpone' }).click();
|
||||
|
||||
|
|
@ -30,7 +28,6 @@ test('shows "never" for unfreshened contacts', async ({ page }) => {
|
|||
});
|
||||
|
||||
test('shows the date for fresh contacts', async ({ page }) => {
|
||||
await login(page);
|
||||
await verifyCreateUser(page, { names: ['John Contact'] });
|
||||
await page.getByRole('link', { name: /edit/i }).click();
|
||||
await page.getByRole('button', { name: /fresh/i }).click();
|
||||
|
|
@ -40,7 +37,6 @@ test('shows the date for fresh contacts', async ({ page }) => {
|
|||
});
|
||||
|
||||
test('sidebar is sorted alphabetically', async ({ page }) => {
|
||||
await login(page);
|
||||
await verifyCreateUser(page, { names: ['Zulu'] });
|
||||
await verifyCreateUser(page, { names: ['Alfa'] });
|
||||
await verifyCreateUser(page, { names: ['Golf'] });
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { defineConfig, devices } from '@playwright/test';
|
||||
import 'custom-expects';
|
||||
|
||||
// purposefully not using ??: we want to replace empty empty string with default
|
||||
const BASE_URL = process.env.BASE_URL || 'http://localhost:3000';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue