chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.5.0 Latest 5 packages
0
0
// Themes against a real PDS: alice makes one from the editor, refused
// while a text reads too faintly, then published as a place.hud.theme
// record in her own repository and drawn at once; bob finds hers by her
// handle and uses it; alice deletes it, and bob keeps its colours. Each
// goes back to the system's theme after, for the flows that follow.
import { expect, signIn, test, who, world } from './pages.mjs';
test.describe.configure({ mode: 'serial' });
/** Alice's place.hud.theme records, as her PDS lists them. */
const records = async () => {
const res = await fetch(`${world.pds}/xrpc/com.atproto.repo.listRecords?repo=${who.alice.did}&collection=place.hud.theme`);
return (await res.json()).records;
};
/** The colour the root draws main buttons in now. */
const primary = (page) => page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--primary').trim());
test('alice makes a theme: refused while a text is faint, then published and drawn', async ({ browser }) => {
const context = await browser.newContext();
const page = await context.newPage();
await signIn(page, 'alice');
await page.locator('summary[aria-label="Theme"]').click();
await page.getByRole('menuitem', { name: 'New theme' }).click();
const editor = page.getByRole('dialog', { name: 'New theme' });
await editor.getByRole('textbox', { name: /^Name/ }).fill('Harness sand');
// Its label holds it, so its name says what it starts from too.
await editor.getByRole('combobox', { name: /^Start from/ }).selectOption({ label: 'Paper' });
// Faint text as light as the tiles: named, and nothing published.
const faint = editor.getByLabel('Faint text, as #rrggbb', { exact: true });
await faint.fill('#fbf8f1');
await expect(editor.getByRole('alert')).toContainText('Faint text on tiles and the bar');
await expect(editor.getByRole('button', { name: 'Publish and use' })).toBeDisabled();
await faint.fill('#6a5f51');
await expect(editor.getByRole('alert')).toHaveCount(0);
await editor.getByLabel('Main buttons, as #rrggbb', { exact: true }).fill('#7a3412');
await editor.getByRole('button', { name: 'Publish and use' }).click();
await expect(editor).toHaveCount(0);
// Published in her repository, chosen, and drawn.
await expect.poll(async () => (await records()).map((r) => r.value.name)).toEqual(['Harness sand']);
const [record] = await records();
expect(record.value.palette.primary).toBe('#7a3412');
expect(record.value.colorScheme).toBe('light');
await expect.poll(() => primary(page)).toBe('#7a3412');
// Hers in the menu, chosen; and so after a reload.
await page.reload();
await expect.poll(() => primary(page)).toBe('#7a3412');
await page.locator('summary[aria-label="Theme"]').click();
await expect(page.getByRole('menuitemradio', { name: /Harness sand/, checked: true })).toBeVisible();
await context.close();
});
test('bob finds hers by her handle and uses it; deleted, his stays', async ({ browser }) => {
const bobs = await browser.newContext();
const bob = await bobs.newPage();
await signIn(bob, 'bob');
await bob.locator('summary[aria-label="Theme"]').click();
await bob.getByRole('menuitem', { name: 'Browse everyone’s themes' }).click();
const browse = bob.getByRole('dialog', { name: /themes/i });
await browse.getByLabel('Handle whose themes to show').fill(who.alice.handle);
await browse.getByRole('button', { name: 'Show' }).click();
const card = browse.getByRole('listitem').filter({ hasText: 'Harness sand' });
await expect(card).toContainText(who.alice.handle);
await card.getByRole('button', { name: 'Use' }).click();
await expect.poll(() => primary(bob)).toBe('#7a3412');
await browse.getByRole('button', { name: 'Done' }).click();
// Alice deletes it from her menu.
const alices = await browser.newContext();
const alice = await alices.newPage();
await signIn(alice, 'alice');
alice.on('dialog', (d) => d.accept());
await alice.locator('summary[aria-label="Theme"]').click();
await alice.getByRole('button', { name: 'Delete Harness sand' }).click();
await expect.poll(async () => (await records()).length).toBe(0);
// Bob's workspace keeps its colours, as copied when he chose it.
await bob.reload();
await expect.poll(() => primary(bob)).toBe('#7a3412');
// Both back to the system's.
for (const page of [alice, bob]) {
await page.locator('summary[aria-label="Theme"]').click();
await page.getByRole('menuitemradio', { name: /^System/ }).click();
await expect.poll(() => page.evaluate(() => document.documentElement.getAttribute('style'))).toBeNull();
}
await alices.close();
await bobs.close();
});