feat: sites and authors integration into existing screens (& formated all frontend files kinda accidentally)
This commit is contained in:
1 parent
3d81d2c717
commit
6b8990c55e
239 files changed
+9194
-1354
No files matched your search
@@ -108,7 +108,11 @@ function setViewport(desktop: boolean) {
|
||||
}
|
||||
|
||||
async function mountPage(
|
||||
options: { desktop?: boolean; role?: string | null; routes?: Record<string, Handler> } = {},
|
||||
options: {
|
||||
desktop?: boolean
|
||||
role?: string | null
|
||||
routes?: Record<string, Handler>
|
||||
} = {},
|
||||
) {
|
||||
const { desktop = true, role = 'owner', routes = {} } = options
|
||||
setViewport(desktop)
|
||||
@@ -134,14 +138,22 @@ async function mountPage(
|
||||
)
|
||||
})
|
||||
vi.mocked(useApi).mockReturnValue({
|
||||
getMe: vi
|
||||
.fn()
|
||||
.mockResolvedValue({ verified: true, username: 'marta', id: 1, role: sessionRole }),
|
||||
getMe: vi.fn().mockResolvedValue({
|
||||
verified: true,
|
||||
username: 'marta',
|
||||
id: 1,
|
||||
role: sessionRole,
|
||||
}),
|
||||
request: requestMock,
|
||||
})
|
||||
await router.push('/settings/media/cache')
|
||||
const Host = defineComponent({ render: () => h(UApp, null, () => h(CachePage)) })
|
||||
wrapper = mount(Host, { attachTo: document.body, global: { plugins: [router, uiPlugin] } })
|
||||
const Host = defineComponent({
|
||||
render: () => h(UApp, null, () => h(CachePage)),
|
||||
})
|
||||
wrapper = mount(Host, {
|
||||
attachTo: document.body,
|
||||
global: { plugins: [router, uiPlugin] },
|
||||
})
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
}
|
||||
@@ -361,7 +373,14 @@ describe('Rule: Cache screen, loaded', () => {
|
||||
[STATS]: () =>
|
||||
Promise.resolve(
|
||||
stats({
|
||||
by_variant: [{ name: 'hero', enabled: true, files: 1, bytes: MB }],
|
||||
by_variant: [
|
||||
{
|
||||
name: 'hero',
|
||||
enabled: true,
|
||||
files: 1,
|
||||
bytes: MB,
|
||||
},
|
||||
],
|
||||
top_images: [
|
||||
{
|
||||
id: 1,
|
||||
@@ -417,7 +436,9 @@ describe('Rule: Cache screen, loading, empty and error', () => {
|
||||
})
|
||||
|
||||
it('Empty cache', async () => {
|
||||
await mountPage({ routes: { [STATS]: () => Promise.resolve(emptyStats()) } })
|
||||
await mountPage({
|
||||
routes: { [STATS]: () => Promise.resolve(emptyStats()) },
|
||||
})
|
||||
|
||||
expect(tiles()).toEqual([
|
||||
'Generated files 0 Nothing cached',
|
||||
@@ -441,7 +462,9 @@ describe('Rule: Cache screen, loading, empty and error', () => {
|
||||
])('Error loading: %s', async (_, failure) => {
|
||||
let attempt = 0
|
||||
await mountPage({
|
||||
routes: { [STATS]: () => (attempt++ === 0 ? failure() : Promise.resolve(stats())) },
|
||||
routes: {
|
||||
[STATS]: () => (attempt++ === 0 ? failure() : Promise.resolve(stats())),
|
||||
},
|
||||
})
|
||||
|
||||
const alert = document.body.querySelector<HTMLElement>('[role="alert"]')!
|
||||
@@ -624,7 +647,9 @@ describe('Rule: Cache screen, purging, done and failed', () => {
|
||||
await click(buttonIn(alertDialog()!, 'Purge 312 files'))
|
||||
|
||||
await vi.waitFor(() => expect(toastCalls()).toHaveLength(1))
|
||||
expect(toastCalls()[0]).toMatchObject({ title: 'Purged 312 files, freed 41 MB' })
|
||||
expect(toastCalls()[0]).toMatchObject({
|
||||
title: 'Purged 312 files, freed 41 MB',
|
||||
})
|
||||
await vi.waitFor(() => expect(calls(STATS)).toHaveLength(2))
|
||||
})
|
||||
|
||||
@@ -647,7 +672,10 @@ describe('Rule: Cache screen, purging, done and failed', () => {
|
||||
description: '640 of 1,284 files were removed. Try again.',
|
||||
})
|
||||
await vi.waitFor(() => expect(calls(STATS)).toHaveLength(2))
|
||||
const [action] = toast.actions as { label: string; onClick: () => void }[]
|
||||
const [action] = toast.actions as {
|
||||
label: string
|
||||
onClick: () => void
|
||||
}[]
|
||||
expect(action!.label).toBe('Try again')
|
||||
|
||||
action!.onClick()
|
||||
@@ -687,14 +715,20 @@ describe('Rule: Cache screen, purging, done and failed', () => {
|
||||
await startPurgeAll({ [PURGE]: () => Promise.reject(failure) })
|
||||
|
||||
await vi.waitFor(() => expect(toastCalls()).toHaveLength(1))
|
||||
expect(toastCalls()[0]).toMatchObject({ color: 'error', title, description })
|
||||
expect(toastCalls()[0]).toMatchObject({
|
||||
color: 'error',
|
||||
title,
|
||||
description,
|
||||
})
|
||||
expect(document.body.querySelector('[data-testid="cache-purge-banner"]')).toBeNull()
|
||||
expect(tiles()).toHaveLength(4)
|
||||
expect(calls(STATS)).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('A 401 is left to the API client', async () => {
|
||||
await startPurgeAll({ [PURGE]: () => Promise.reject(new ApiError(401)) })
|
||||
await startPurgeAll({
|
||||
[PURGE]: () => Promise.reject(new ApiError(401)),
|
||||
})
|
||||
|
||||
expect(toastCalls()).toHaveLength(0)
|
||||
expect(document.body.querySelector('[data-testid="cache-purge-banner"]')).toBeNull()
|
||||
@@ -738,7 +772,9 @@ describe('Rule: Cache screen, purging the variants of one image', () => {
|
||||
})
|
||||
|
||||
it('The image no longer exists', async () => {
|
||||
await mountPage({ routes: { [PURGE]: () => Promise.reject(new ApiError(404)) } })
|
||||
await mountPage({
|
||||
routes: { [PURGE]: () => Promise.reject(new ApiError(404)) },
|
||||
})
|
||||
|
||||
await click(buttonByLabel('Purge north-wall.jpg'))
|
||||
|
||||
|
||||
Reference in new issue
Block a user