Test fail-closed sharing against older backends
This commit is contained in:
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user