Skip to content

matthewwong525/WongStack / .agents/plugins/access

access

Verified

See who can sign in and what each person may use; add, change or remove a person.

FileKindSize
README.mdmarkdown3.4 KB
SKILL.mdskill md2.3 KB
VERSIONother6 B
hooks/claude.jsonconfig251 B
hooks/codex.jsonconfig232 B
references/setup.mdmarkdown9.7 KB
screen/access.cssother10.5 KB
screen/address.mjsscript2.1 KB
screen/api.mjsscript11.6 KB
screen/api.test.mjsscript13.4 KB
screen/app.mjsscript1.2 KB
screen/app.test.mjsscript40.3 KB
screen/confirm.mjsscript1.1 KB
screen/context.mjsscript248 B
screen/copy-text.mjsscript1.3 KB
screen/fields.mjsscript1001 B
screen/hidden.test.mjsscript6.8 KB
screen/labels.mjsscript1.4 KB
screen/leaving.test.mjsscript14.6 KB
screen/level-choice.mjsscript1.3 KB
screen/levels.mjsscript3.7 KB
screen/levels.test.mjsscript7.9 KB
screen/loading.mjsscript457 B
screen/main.d.mtsother1.0 KB
screen/main.mjsscript1.3 KB
screen/note.mjsscript2.1 KB
screen/note.test.mjsscript4.1 KB
screen/notices.mjsscript4.3 KB
screen/notices.test.mjsscript2.2 KB
screen/own.mjsscript889 B
screen/owner.mjsscript2.7 KB
screen/page.mjsscript4.2 KB
screen/people.mjsscript4.5 KB
screen/person-page.mjsscript3.5 KB
screen/person-page.test.mjsscript37.2 KB
screen/project-step.mjsscript1.7 KB
screen/project-step.test.mjsscript5.4 KB
screen/pushers.mjsscript3.5 KB
screen/pushers.test.mjsscript5.2 KB
screen/role-page.mjsscript2.5 KB
screen/role-select.mjsscript1.6 KB
screen/roles.mjsscript1.5 KB
screen/roles.test.mjsscript22.2 KB
screen/router.mjsscript3.3 KB
screen/seal.d.mtsother470 B
screen/seal.mjsscript2.6 KB
screen/seal.test.mjsscript1.1 KB
screen/services.mjsscript4.3 KB
screen/services.test.mjsscript12.5 KB
screen/set-fields.mjsscript3.5 KB
screen/status.mjsscript2.4 KB
screen/status.test.mjsscript2.7 KB
screen/style.test.mjsscript11.5 KB
screen/subjects.mjsscript487 B
screen/subjects.test.mjsscript2.4 KB
screen/table.mjsscript4.5 KB
screen/test-dom.mjsscript9.4 KB
screen/ui.mjsscript14.2 KB
screen/view.mjsscript2.1 KB
screen/welcome.mjsscript2.3 KB
screen/welcome.test.mjsscript11.2 KB
scripts/check-definitions.mjsexecutablescript1.1 KB
scripts/lib/check-definitions.mjsscript1.2 KB
scripts/lib/client.mjsscript4.6 KB
scripts/lib/openapi.mjsscript20.6 KB
scripts/lib/scrub.mjsscript7.0 KB
scripts/lib/seal-keys.mjsscript1.1 KB
scripts/lib/services.mjsscript17.6 KB
scripts/services.mjsexecutablescript8.6 KB
scripts/session-start.mjsscript1.7 KB
server/errors.d.mtsother572 B
server/errors.mjsscript1.8 KB
server/errors.test.mjsscript1.3 KB
server/forward.d.mtsother1.6 KB
server/forward.mjsscript11.0 KB
server/forward.test.mjsscript9.4 KB
server/index.d.mtsother3.3 KB
server/index.mjsscript11.3 KB
server/index.test.mjsscript11.8 KB
server/key-rules.d.mtsother643 B
server/key-rules.mjsscript4.0 KB
server/key-rules.test.mjsscript5.2 KB
server/levels.d.mtsother2.3 KB
server/levels.mjsscript4.3 KB
server/levels.test.mjsscript2.4 KB
server/management.mjsscript2.8 KB
server/page.mjsscript1.3 KB
server/pass.d.mtsother213 B
server/pass.mjsscript3.5 KB
server/people.mjsscript5.3 KB
server/policy.d.mtsother1.5 KB
server/policy.mjsscript8.1 KB
server/roles.mjsscript2.4 KB
server/sealed.d.mtsother377 B
server/sealed.mjsscript3.2 KB
server/sealed.test.mjsscript4.9 KB
server/services.d.mtsother487 B
server/services.mjsscript3.1 KB
server/services.test.mjsscript4.5 KB
server/sets.mjsscript4.5 KB
server/start.mjsscript1.8 KB
server/tools.d.mtsother1.2 KB
server/tools.mjsscript8.7 KB
server/tools.test.mjsscript10.4 KB
signin/cloudflare-list.d.mtsother969 B
signin/cloudflare-list.mjsscript11.6 KB
signin/cloudflare-list.test.mjsscript1.4 KB
signin/cloudflare.d.mtsother1.5 KB
signin/cloudflare.mjsscript7.2 KB
signin/cloudflare.test.mjsscript1.4 KB
signin/computer.d.mtsother557 B
signin/computer.mjsscript2.4 KB
signin/computer.test.mjsscript1.0 KB
store/contract.d.mtsother293 B
store/contract.mjsscript14.3 KB
store/interface.d.mtsother4.2 KB
store/interface.mjsscript1.2 KB
store/stand-in.d.mtsother93 B
store/stand-in.mjsscript10.4 KB
store/stand-in.test.mjsscript202 B

screen/leaving.test.mjs

View on GitHub
// @vitest-environment jsdom
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { back, cleanup, fireEvent, moment, render, screen, waitFor, within } from './test-dom.mjs'

// Closing an opened person, role, app or key with changes not saved asks first, in a popup over its panel.
// A shop where Hello changes things with Stripe, and the tip calculator uses no key.
const key = (id, title, changes = {}) => ({ id, title, levels: ['read', 'write'], saved: true, setup: false, alone: false, ...changes })
const built = (id, title) => ({ id, title, description: `${title} for the shop` })
const person = (email, changes = {}) => ({ email, status: 'active', settled: true, role: null, apps: [], keys: {}, ...changes })
const hello = () => ({ apps: ['hello'], keys: { stripe: 'read' } })
const status = () => ({ ownerEmail: 'owner@shop.com', viewer: { email: 'owner@shop.com', owner: true }, environment: 'live', key: 'ready', started: true, imported: 0,
  keysStarted: true, unticked: { people: [], roles: [] },
  apps: [built('hello', 'Hello'), built('tips', 'Tip calculator')],
  // Bank is set up to be used directly.
  keys: [key('stripe', 'Stripe'), key('bank', 'Bank', { direct: true })],
  roles: [{ id: 'sales', name: 'Sales', ...hello() }],
  people: [person('kim@shop.com', hello()), person('lee@shop.com', { role: 'sales', ...hello() })],
  work: [], project: 'ready' })
let roster
let fetchMock
// The apps a person can open.
const screens = () => roster.apps.map(item => item.id)
beforeEach(() => {
  roster = status()
  fetchMock = vi.fn(async (url) => {
    const path = url.replace('/api/access/', '')
    if (path === 'apps') return Response.json({ state: 'current', role: 'owner', apps: ['access', ...screens()], revision: 1 })
    if (path === 'setup') return Response.json({ role: 'owner', api: 'authenticated', identity: { email: 'owner@shop.com', subject: 'owner' }, apps: screens(),
      repository: 'manual_provider_setup', memory: 'independent_operator_setup', prompt: { state: 'unavailable', message: 'Not on this preview' } })
    return Response.json(roster)
  })
  vi.stubGlobal('fetch', fetchMock)
})
afterEach(() => { cleanup(); vi.unstubAllGlobals() })
const open = (path = '') => render(`/apps/access/${path}`)
const where = () => decodeURIComponent(window.location.pathname)
const click = (name) => fireEvent.click(screen.getByRole('button', { name }))
const posts = () => fetchMock.mock.calls.filter(([, init]) => init?.method === 'POST')
const question = () => screen.queryByRole('alertdialog', { name: 'Leave without saving?' })
// The panel an opened item sits in, and that none is open any more.
const panel = (name) => screen.getByRole('dialog', { name })
const closed = () => waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
// The parts start listening for a press outside them, and hand the keyboard back, a moment after they open or close.
// One of the views in the switch, by its title: its count follows.
const tab = (title) => within(screen.getByRole('navigation', { name: 'Access views' })).getByRole('link', { name: new RegExp(`^${title} \\d+$`) })
const radio = (group, name) => within(screen.getByRole('group', { name: new RegExp(`^${group} · `) })).getByRole('radio', { name })
// An app's tick in an opened person or role: one press gives the app or takes it away, and saves nothing.
const app = (name) => within(screen.getByRole('group', { name: 'Apps' })).getByRole('checkbox', { name })
// What the browser is told when the tab closes or reloads: true when it should ask.
const unloadAsks = () => { const event = new Event('beforeunload', { cancelable: true }); window.dispatchEvent(event); return event.defaultPrevented }
// A press with the pointer: the panel answers one beside it once the click lands.
const press = async (on) => { await fireEvent.pointerDown(on); await fireEvent.click(on) }
const KIM = '/apps/access/people/kim@shop.com'

it('closes an untouched panel at once by its ✕, Escape, Cancel or a press on the page beside it, back to its view, with its row marked while it is open', async () => {
  const ways = [() => click('Close'), () => fireEvent.keyDown(panel('Sales'), { key: 'Escape' }), () => click('Cancel'), () => press(screen.getByRole('heading', { name: 'Access' }))]
  for (const [at, close] of ways.entries()) {
    await open('roles/sales'); await screen.findByRole('button', { name: 'Save role' }); await moment()
    // The list stays in place beside the panel, with the open role's row marked.
    const marked = screen.getByRole('table', { name: 'Roles' }).querySelector ('tr[aria-current="true"]')
    expect(within(marked).getByRole('link', { name: 'Sales' }), `${at}`).toBeTruthy()
    // A press inside the panel leaves it open, and so does the keyboard moving to the page beside it.
    // A press on a row beside it is the row's own to answer: the panel does not also go back to its view.
    await press(panel('Sales')); await fireEvent.focusIn(tab('People')); await press(within(marked).getByText('1 person')); await moment()
    expect([!!panel('Sales'), where()], `${at}`).toEqual([true, '/apps/access/roles/sales'])
    await close(); await closed()
    expect([where(), !!question(), document.querySelector('tr[aria-current]')], `${at}`).toEqual(['/apps/access/roles', false, null]); cleanup()
  }
  expect(posts()).toHaveLength(0)
})
it('asks in a popup before a panel changed only by a tick is closed by its ✕, Escape or Cancel, keeps the tick on staying, and saves nothing on leaving', async () => {
  await open('people/kim@shop.com'); await screen.findByRole('button', { name: 'Save access' })
  expect(unloadAsks()).toBe(false); expect(screen.queryByText('Not saved yet')).toBeNull()
  // One tick is a change that waits to be saved: the panel says so above its buttons, and nothing is sent.
  await fireEvent.click(app('Tip calculator')); expect(unloadAsks()).toBe(true)
  expect(screen.getByText('Not saved yet').compareDocumentPosition(screen.getByRole('button', { name: 'Save access' })) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); expect(posts()).toHaveLength(0)
  // Cancel asks over the panel: the way out is focused first, and the action is the one solid button.
  const cancel = screen.getByRole('button', { name: 'Cancel' }); cancel.focus(); await fireEvent.click(cancel)
  const ask = within(question()); expect(ask.getByText('Your changes here are not saved yet.')).toBeTruthy()
  const [stay, leave] = [ask.getByRole('button', { name: 'Keep editing' }), ask.getByRole('button', { name: 'Leave' })]
  await moment(); expect([document.activeElement, stay.getAttribute('data-variant'), leave.getAttribute('data-variant')]).toEqual([stay, 'outline', 'default'])
  // Both keep the button's mark, so access.css draws them as buttons where the page is served alone.
  expect([stay, leave].map(button => button.getAttribute('data-slot'))).toEqual(['button', 'button'])
  // A click on the dimmed page round the question does not answer it.
  const dimmed = document.querySelector('[data-slot="alert-dialog-overlay"]'); await fireEvent.pointerDown(dimmed); await fireEvent.click(dimmed)
  expect([!!question(), where()]).toEqual([true, KIM])
  // Staying keeps the change in the panel, and the keyboard goes back to where it was in it.
  await click('Keep editing'); expect(question()).toBeNull(); await moment()
  expect([document.activeElement, panel('kim@shop.com').contains(cancel)]).toEqual([cancel, true])
  expect([app('Tip calculator').checked, screen.getByRole('button', { name: 'Save access' }).closest('fieldset') .disabled]).toEqual([true, false])
  // The ✕ asks too, and Escape answers the question the same way as Keep editing: the panel stays.
  await click('Close'); expect(question()).toBeTruthy(); await fireEvent.keyDown(question(), { key: 'Escape' })
  expect([question(), where(), app('Tip calculator').checked]).toEqual([null, KIM, true]); await moment()
  // Escape on the panel asks as well; leaving goes to the list and sends nothing.
  await fireEvent.keyDown(panel('kim@shop.com'), { key: 'Escape' }); expect(question()).toBeTruthy(); await click('Leave')
  await closed(); expect(where()).toBe('/apps/access/'); expect(posts()).toHaveLength(0)
  expect(unloadAsks()).toBe(false); expect(screen.queryByText('Saved.')).toBeNull()
})
it("a view's link asks before a changed panel is left, goes where it led on leaving, and leaves at once from an untouched one", async () => {
  await open('people/kim@shop.com'); await screen.findByRole('button', { name: 'Save access' })
  // The views show beside the panel, each with its count.
  expect(within(screen.getByRole('navigation', { name: 'Access views' })).getAllByRole('link').map(link => link.textContent)).toEqual(['People 3', 'Roles 1', 'Services 2'])
  // A key's level raised is a change to lose, and it ticks no app.
  await fireEvent.click(radio('Stripe', 'Read & write')); await fireEvent.click(tab('Roles'))
  expect(question()).toBeTruthy(); expect(where()).toBe(KIM)
  // Staying keeps the change; leaving goes to the view the link named, and sends nothing.
  await click('Keep editing'); expect([radio('Stripe', 'Read & write').checked, app('Hello').checked, app('Tip calculator').checked]).toEqual([true, true, false])
  await fireEvent.click(tab('Roles')); await click('Leave')
  await screen.findByRole('table', { name: 'Roles' }); expect(where()).toBe('/apps/access/roles'); expect(posts()).toHaveLength(0)
  cleanup(); await open('people/kim@shop.com'); await screen.findByRole('button', { name: 'Save access' })
  await fireEvent.click(tab('Roles')); await screen.findByRole('table', { name: 'Roles' }); expect(question()).toBeNull(); expect(where()).toBe('/apps/access/roles')
})
it('closes at once a panel put back the way it was', async () => {
  await open('people/kim@shop.com'); await screen.findByRole('button', { name: 'Save access' })
  // A level raised and lowered, a key picked and set back to None, an app ticked and unticked or back: no change.
  await fireEvent.click(radio('Stripe', 'Read & write')); expect(screen.getByText('Not saved yet')).toBeTruthy(); await fireEvent.click(radio('Stripe', 'Read'))
  await fireEvent.click(radio('Bank', 'Read')); await fireEvent.click(radio('Bank', 'None'))
  for (const name of ['Tip calculator', 'Hello']) { await fireEvent.click(app(name)); expect([name, unloadAsks()]).toEqual([name, true]); await fireEvent.click(app(name)) }
  expect([app('Hello').checked, app('Tip calculator').checked, unloadAsks()]).toEqual([true, false, false]); expect(screen.queryByText('Not saved yet')).toBeNull()
  await click('Cancel'); await closed(); expect([question(), where()]).toEqual([null, '/apps/access/'])
})
// Every kind of opened item: a person, a new person, a role, a new role, an app and a key. One test each, so no one
// test opens the panel twenty times.
const pages = [
  ['people/lee@shop.com', () => fireEvent.change(screen.getByLabelText('Role'), { target: { value: '' } })],
  ['people/new', () => fireEvent.change(screen.getByLabelText('Email'), { target: { value: 'new@shop.com' } })],
  ['roles/sales', () => fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'Field sales' } })],
  ['people/kim@shop.com', () => fireEvent.click(app('Hello'))],
  ['people/kim@shop.com', () => fireEvent.click(radio('Bank', 'Read'))],
  ['roles/sales', () => fireEvent.click(app('Tip calculator'))],
  ['roles/new', () => fireEvent.click(app('Tip calculator'))],
  ['roles/new', () => fireEvent.change(screen.getByLabelText('Copy from a person'), { target: { value: 'kim@shop.com' } })],
]
it.each(pages)('asks on an opened item with a change: %s', async (path, change) => {
  const home = `/apps/access/${path.split('/')[0].replace('people', '')}`
  // Untouched, Cancel closes at once, and the list was there all along.
  await open(path); await screen.findByRole('button', { name: /^Save/ }); expect(screen.getByRole('table'), path).toBeTruthy(); await click('Cancel')
  await closed(); expect([path, where(), !!question()]).toEqual([path, home, false]); cleanup()
  // Changed, it asks; staying keeps the panel, leaving goes to its list.
  await open(path); await screen.findByRole('button', { name: /^Save/ }); await change(); await click('Cancel')
  expect([path, where(), !!question()]).toEqual([path, `/apps/access/${path}`, true])
  await click('Keep editing'); expect(question()).toBeNull(); await click('Cancel'); await click('Leave')
  await closed(); expect([path, where()]).toEqual([path, home]); cleanup()
  expect(posts()).toHaveLength(0)
})
it('the browser Back button and the host moving ask too, and a save passes without asking', async () => {
  window.history.replaceState(null, '', '/apps/access/')
  window.history.pushState({ usr: null, key: 'kim', idx: 1 }, '', KIM)
  const handle = await render(KIM)
  const at = () => decodeURIComponent(window.location.pathname)
  // The host moves the page, as the app's own links do, and tells it to read the address again.
  const move = async (to) => { window.history.pushState(null, '', to); handle.update(); await moment() }
  await screen.findByRole('button', { name: 'Save access' })
  // A tick is the only change.
  await fireEvent.click(app('Tip calculator')); expect(unloadAsks()).toBe(true)
  // Back is held: the panel stays, with its change, until the owner answers.
  await back()
  expect(question()).toBeTruthy(); expect(at()).toBe(KIM)
  await click('Keep editing'); expect(question()).toBeNull(); expect(app('Tip calculator').checked).toBe(true)
  // The panel's own ways out and the views' links are held the same way, by one question. The host asks it too.
  await click('Cancel'); expect(screen.getAllByRole('alertdialog')).toHaveLength(1); await click('Keep editing')
  await fireEvent.click(tab('Roles')); expect(screen.getAllByRole('alertdialog')).toHaveLength(1); expect(at()).toBe(KIM); await click('Keep editing')
  expect(handle.hold('/')).toBe(true); await moment(); expect(question()).toBeTruthy(); await click('Keep editing')
  await click('Close'); expect(question()).toBeTruthy(); expect(at()).toBe(KIM)
  await click('Leave'); await closed(); expect(at()).toBe('/apps/access/'); expect(posts()).toHaveLength(0)
  // An untouched panel is never held.
  await move('/apps/access/people/kim@shop.com'); await screen.findByRole('button', { name: 'Save access' }); expect(handle.hold('/')).toBe(false)
  await move('/apps/access/roles'); await screen.findByRole('region', { name: 'Roles' }); expect(question()).toBeNull()
  // A save is the owner's answer already: it lands on the list with its box, and no question.
  await move('/apps/access/people/kim@shop.com'); await screen.findByRole('button', { name: 'Save access' })
  await fireEvent.click(radio('Stripe', 'Read & write')); await click('Save access')
  await screen.findByText('Saved.'); expect(at()).toBe('/apps/access/'); expect(question()).toBeNull(); expect(posts()).toHaveLength(1)
})
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall