Test fail-closed sharing against older backends

This commit is contained in:
archipelago
2026-10-06 07:56:44 -04:00
parent 19207282f9
commit f3264c8de5
2 changed files with 34 additions and 0 deletions
@@ -23,3 +23,29 @@ it.each([false, true])('publishes one complete policy for an existing share: %s'
expect(writes[0]?.params).toMatchObject(existing ? { id: 'saved-id' } : { filename: 'film.mp4' })
wrapper.unmount()
})
it('keeps a rejected publication open without falling back to unsafe legacy writes', async () => {
vi.mocked(rpcClient.call).mockImplementation(async ({ method }) => {
if (method === 'content.list-mine') return { items: [] }
if (method === 'content.publish') throw new Error('Method not found')
return {}
})
const wrapper = mount(ShareModal, { props: { filename: 'film.mp4', filepath: '/film.mp4', isDir: false } })
await flushPromises()
const vm = (wrapper.vm as any).$.setupState
vm.shared = true
vm.accessType = 'paid'
vm.priceSats = 1
await vm.save()
await vi.runAllTimersAsync()
expect(vm.errorMsg).toBe('Method not found')
expect(vm.successMsg).toBeNull()
expect(vm.saving).toBe(false)
expect(wrapper.emitted('saved')).toBeUndefined()
const methods = vi.mocked(rpcClient.call).mock.calls.map(([call]) => call.method)
expect(methods.filter(method => method === 'content.publish')).toHaveLength(1)
expect(methods).not.toContain('content.add')
expect(methods).not.toContain('content.set-pricing')
expect(methods).not.toContain('content.set-availability')
wrapper.unmount()
})