Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

1.3 KB
Raw Blame
import { expect, it } from 'vitest'
import { machineShareGrant, nextMachineShareGrants } from './machineSharePolicy.js'

it('keeps continuing grants while rotating a removed and restored email or domain', () => {
  const first = { id: 'share', emails: ['[email protected]', '[email protected]'], domain: 'team.test', grantVersions: null }
  const a = machineShareGrant(first, '[email protected]'), b = machineShareGrant(first, '[email protected]')
  const domain = machineShareGrant(first, '[email protected]')
  const same = { ...first, grantVersions: nextMachineShareGrants(first, first.emails, first.domain) }
  expect(machineShareGrant(same, '[email protected]')).toBe(a)
  expect(machineShareGrant(same, '[email protected]')).toBe(domain)
  const removed = { ...same, emails: ['[email protected]'], domain: null, grantVersions: nextMachineShareGrants(same, ['[email protected]'], null) }
  expect(machineShareGrant(removed, '[email protected]')).toBeNull()
  const restored = { ...first, grantVersions: nextMachineShareGrants(removed, first.emails, first.domain) }
  expect(machineShareGrant(restored, '[email protected]')).not.toBe(a)
  expect(machineShareGrant(restored, '[email protected]')).toBe(b)
  expect(machineShareGrant(restored, '[email protected]')).not.toBe(domain)
  expect(nextMachineShareGrants(null, ['[email protected]'], null)).toHaveProperty('email:[email protected]')
})