|
|
@@ -1330,24 +1330,43 @@ describe('command launcher chrome and control seats', () => {
|
|
|
}
|
|
|
const { view } = bench({ permissions, command })
|
|
|
const trigger = view.getByLabelText(/^访问模式/) as HTMLButtonElement
|
|
|
- // Title-case display is presentation only; the menu ids stay machine names.
|
|
|
- expect(trigger.textContent).toBe('Read Only')
|
|
|
+ // Product-label display is presentation only; the menu ids stay machine names.
|
|
|
+ expect(trigger.textContent).toBe('仅可查看')
|
|
|
expect([...trigger.querySelectorAll('svg')]
|
|
|
.every(icon => icon.closest('[aria-hidden="true"]') !== null)).toBe(true)
|
|
|
fireEvent.click(trigger)
|
|
|
const items = view.getAllByRole('menuitem')
|
|
|
- expect(items.map(o => o.textContent)).toEqual(['Read Only', 'Workspace Write', 'Full access'])
|
|
|
+ expect(items.map(o => o.textContent)).toEqual(['仅可查看', '可写入工作区', '完全权限'])
|
|
|
fireEvent.click(items[1]!)
|
|
|
// Optimistic pick + disable until admission resolves (command stub resolves true).
|
|
|
const busy = view.getByLabelText(/^访问模式/) as HTMLButtonElement
|
|
|
- expect(busy.textContent).toBe('Workspace Write')
|
|
|
+ expect(busy.textContent).toBe('可写入工作区')
|
|
|
expect(busy.disabled).toBe(true)
|
|
|
expect(command).toHaveBeenCalledWith('/permission workspace-write')
|
|
|
await act(async () => {})
|
|
|
expect((view.getByLabelText(/^访问模式/) as HTMLButtonElement).disabled).toBe(false)
|
|
|
})
|
|
|
|
|
|
- it('requires explicit risk acknowledgement before submitting Full access', async () => {
|
|
|
+ it('the Access chip preserves host labels for built-in preset values', () => {
|
|
|
+ const permissions = {
|
|
|
+ options: [
|
|
|
+ { value: 'read-only', name: 'Review Only' },
|
|
|
+ { value: 'workspace-write', name: 'Project Files' },
|
|
|
+ { value: 'danger-full-access', name: 'Operator Mode' },
|
|
|
+ { value: 'custom-mode', name: 'custom-mode' },
|
|
|
+ { value: '__proto__', name: '__proto__' },
|
|
|
+ ],
|
|
|
+ currentValue: 'workspace-write',
|
|
|
+ }
|
|
|
+ const { view } = bench({ permissions })
|
|
|
+ const trigger = view.getByLabelText(/^访问模式/) as HTMLButtonElement
|
|
|
+ expect(trigger.textContent).toBe('Project Files')
|
|
|
+ fireEvent.click(trigger)
|
|
|
+ expect(view.getAllByRole('menuitem').map(item => item.textContent))
|
|
|
+ .toEqual(['Review Only', 'Project Files', 'Operator Mode', 'Custom Mode', '__proto__'])
|
|
|
+ })
|
|
|
+
|
|
|
+ it('requires explicit risk acknowledgement before submitting full access', async () => {
|
|
|
const command = vi.fn(() => Promise.resolve(true))
|
|
|
const permissions = {
|
|
|
options: [
|
|
|
@@ -1358,11 +1377,11 @@ describe('command launcher chrome and control seats', () => {
|
|
|
}
|
|
|
const { view } = bench({ permissions, command })
|
|
|
fireEvent.click(view.getByLabelText(/^访问模式/))
|
|
|
- fireEvent.click(view.getByRole('menuitem', { name: 'Full access' }))
|
|
|
+ fireEvent.click(view.getByRole('menuitem', { name: '完全权限' }))
|
|
|
|
|
|
expect(command).not.toHaveBeenCalled()
|
|
|
- expect(view.getByRole('dialog', { name: '确认启用 Full access?' })).toBeTruthy()
|
|
|
- const enable = view.getByRole('button', { name: '启用 Full access' }) as HTMLButtonElement
|
|
|
+ expect(view.getByRole('dialog', { name: '确认启用完全权限?' })).toBeTruthy()
|
|
|
+ const enable = view.getByRole('button', { name: '启用完全权限' }) as HTMLButtonElement
|
|
|
expect(enable.disabled).toBe(true)
|
|
|
|
|
|
fireEvent.click(view.getByRole('checkbox', { name: '我已了解风险,并愿意继续' }))
|
|
|
@@ -1372,11 +1391,11 @@ describe('command launcher chrome and control seats', () => {
|
|
|
expect(command).toHaveBeenCalledOnce()
|
|
|
expect(command).toHaveBeenCalledWith('/permission danger-full-access')
|
|
|
expect(view.queryByRole('dialog')).toBeNull()
|
|
|
- expect((view.getByLabelText(/^访问模式/) as HTMLButtonElement).textContent).toBe('Full access')
|
|
|
+ expect((view.getByLabelText(/^访问模式/) as HTMLButtonElement).textContent).toBe('完全权限')
|
|
|
await act(async () => {})
|
|
|
})
|
|
|
|
|
|
- it('cancels a Full access selection without changing permission and resets acknowledgement', () => {
|
|
|
+ it('cancels a full access selection without changing permission and resets acknowledgement', () => {
|
|
|
const command = vi.fn(() => Promise.resolve(true))
|
|
|
const permissions = {
|
|
|
options: [
|
|
|
@@ -1388,21 +1407,21 @@ describe('command launcher chrome and control seats', () => {
|
|
|
const { view } = bench({ permissions, command })
|
|
|
const openConfirmation = () => {
|
|
|
fireEvent.click(view.getByLabelText(/^访问模式/))
|
|
|
- fireEvent.click(view.getByRole('menuitem', { name: 'Full access' }))
|
|
|
+ fireEvent.click(view.getByRole('menuitem', { name: '完全权限' }))
|
|
|
}
|
|
|
|
|
|
openConfirmation()
|
|
|
fireEvent.click(view.getByRole('checkbox'))
|
|
|
fireEvent.click(view.getByRole('button', { name: '取消' }))
|
|
|
expect(command).not.toHaveBeenCalled()
|
|
|
- expect((view.getByLabelText(/^访问模式/) as HTMLButtonElement).textContent).toBe('Workspace Write')
|
|
|
+ expect((view.getByLabelText(/^访问模式/) as HTMLButtonElement).textContent).toBe('可写入工作区')
|
|
|
|
|
|
openConfirmation()
|
|
|
expect((view.getByRole('checkbox') as HTMLInputElement).checked).toBe(false)
|
|
|
- expect((view.getByRole('button', { name: '启用 Full access' }) as HTMLButtonElement).disabled).toBe(true)
|
|
|
+ expect((view.getByRole('button', { name: '启用完全权限' }) as HTMLButtonElement).disabled).toBe(true)
|
|
|
})
|
|
|
|
|
|
- it('revokes an open Full access confirmation when the task locks', () => {
|
|
|
+ it('revokes an open full access confirmation when the task locks', () => {
|
|
|
const command = vi.fn(() => Promise.resolve(true))
|
|
|
const permissions = {
|
|
|
options: [
|
|
|
@@ -1413,14 +1432,14 @@ describe('command launcher chrome and control seats', () => {
|
|
|
}
|
|
|
const { view, session } = bench({ permissions, command })
|
|
|
fireEvent.click(view.getByLabelText(/^访问模式/))
|
|
|
- fireEvent.click(view.getByRole('menuitem', { name: 'Full access' }))
|
|
|
+ fireEvent.click(view.getByRole('menuitem', { name: '完全权限' }))
|
|
|
fireEvent.click(view.getByRole('checkbox'))
|
|
|
act(() => { session.set(snapshotOf({ removed: true })) })
|
|
|
expect(view.queryByRole('dialog')).toBeNull()
|
|
|
expect(command).not.toHaveBeenCalled()
|
|
|
})
|
|
|
|
|
|
- it('resets an open Full access confirmation when switching tasks', () => {
|
|
|
+ it('resets an open full access confirmation when switching tasks', () => {
|
|
|
const command = vi.fn(() => Promise.resolve(true))
|
|
|
const permissions = {
|
|
|
options: [
|
|
|
@@ -1431,7 +1450,7 @@ describe('command launcher chrome and control seats', () => {
|
|
|
}
|
|
|
const { view, props } = bench({ permissions, command })
|
|
|
fireEvent.click(view.getByLabelText(/^访问模式/))
|
|
|
- fireEvent.click(view.getByRole('menuitem', { name: 'Full access' }))
|
|
|
+ fireEvent.click(view.getByRole('menuitem', { name: '完全权限' }))
|
|
|
fireEvent.click(view.getByRole('checkbox'))
|
|
|
view.rerender(<InputBar {...props} sessionId={'s2' as SessionId} />)
|
|
|
expect(view.queryByRole('dialog')).toBeNull()
|