refactor: cloak elements that need alpine loaded

This commit is contained in:
Robert Perce 2026-04-08 09:27:14 -05:00
parent 7b70a10463
commit 231eee3e10
7 changed files with 16 additions and 17 deletions

View file

@ -4,7 +4,6 @@ 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 }) => {
@ -19,19 +18,21 @@ test('last-contact date on display resolves journal mentions and manual-freshen'
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();
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.
@ -39,7 +40,6 @@ test.skip("groups wrap nicely", async ({ page }) => {
test('allow marking as inactive', async ({ page }) => {
await page.getByRole('link', { name: /edit/i }).click();
await expect(page.locator('#alpine-loaded')).not.toHaveAttribute('x-cloak');
await page.getByLabel('status').selectOption('Inactive');
await page.getByRole('button', { name: /save/i }).click();
@ -55,6 +55,7 @@ test('allow exempting from stale', async ({ page }) => {
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');
});

View file

@ -16,9 +16,7 @@ type UserFields = {
};
export const verifyCreateUser = async (page: Page, fields: UserFields) => {
await page.getByRole('button', { name: /add contact/i }).click();
await page.waitForResponse('/contact/new');
await expect(page.locator('#alpine-loaded')).not.toHaveAttribute('x-cloak');
await page.waitForURL(/contact\/\d+\/edit$/);
const { names, ...simple } = fields;
for (const name of (names ?? [])) {
@ -31,6 +29,6 @@ export const verifyCreateUser = async (page: Page, fields: UserFields) => {
}
await page.getByRole('button', { name: /save/i }).click();
await page.waitForResponse(/\/contact\/\d+/);
await page.waitForURL(/contact\/\d+$/);
};