chore: snapshot release workspace

This commit is contained in:
archipelago
2026-06-12 03:00:15 -04:00
parent 6a30ff11bd
commit d6f108d818
76 changed files with 792 additions and 3613 deletions
@@ -1,94 +0,0 @@
import { flushPromises, mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import Web5DWN from '../Web5DWN.vue'
import { rpcClient } from '@/api/rpc-client'
import { useSyncStore } from '@/stores/sync'
import { PackageState } from '@/types/api'
import type { DwnMessageEntry } from '../types'
vi.mock('vue-i18n', () => ({
useI18n: () => ({ t: (key: string) => key }),
}))
vi.mock('@/api/rpc-client', () => ({
rpcClient: {
call: vi.fn(),
},
}))
function makeMessage(recordId: string): DwnMessageEntry {
return {
record_id: recordId,
author: 'did:key:alice',
date_created: '2026-06-10T10:00:00Z',
descriptor: {
interface: 'Records',
method: 'Write',
protocol: 'https://example.com/protocol',
},
data: { title: recordId },
}
}
function deferred<T>() {
let resolve!: (value: T) => void
let reject!: (reason?: unknown) => void
const promise = new Promise<T>((res, rej) => {
resolve = res
reject = rej
})
return { promise, resolve, reject }
}
describe('Web5DWN', () => {
beforeEach(() => {
setActivePinia(createPinia())
vi.clearAllMocks()
useSyncStore().data = {
'package-data': {
dwn: {
state: PackageState.Running,
manifest: { id: 'dwn', title: 'DWN' },
'static-files': {},
},
},
} as never
})
it('keeps stored messages visible while refresh is pending or fails', async () => {
vi.mocked(rpcClient.call).mockResolvedValueOnce({
messages: [makeMessage('record-one')],
count: 1,
})
const wrapper = mount(Web5DWN, {
global: {
stubs: { RouterLink: true },
},
})
;(wrapper.vm as unknown as { showDwnMessages: boolean }).showDwnMessages = true
await (wrapper.vm as unknown as { loadDwnMessages: () => Promise<void> }).loadDwnMessages()
await flushPromises()
expect(wrapper.text()).toContain('record-o')
const pending = deferred<{ messages: DwnMessageEntry[]; count: number }>()
vi.mocked(rpcClient.call).mockReturnValueOnce(pending.promise)
const refresh = (wrapper.vm as unknown as { loadDwnMessages: () => Promise<void> }).loadDwnMessages()
await wrapper.vm.$nextTick()
expect(wrapper.text()).toContain('record-o')
expect(wrapper.text()).toContain('Refreshing messages...')
expect(wrapper.text()).not.toContain('Loading messages...')
pending.reject(new Error('offline'))
await refresh
await flushPromises()
expect(wrapper.text()).toContain('record-o')
expect(wrapper.text()).not.toContain('Refreshing messages...')
})
})