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
@@ -8,6 +8,7 @@ import { useSessionStore } from '@/stores/session'
|
||||
import type { Article, ArticlePage } from '@/composables/useArticles'
|
||||
import { DESKTOP_WIDTH, MOBILE_WIDTH, setViewportWidth } from '@/components/__tests__/viewport'
|
||||
import ArticleView from '../ArticleView.vue'
|
||||
import { oneSite } from './editorMetaKit'
|
||||
import { articleEnvelope, parseListUrl, type EnvelopeParams } from './articleEnvelope'
|
||||
|
||||
const TOTAL = 312
|
||||
@@ -81,6 +82,9 @@ function respondFromFixture(params: EnvelopeParams) {
|
||||
function installFetch() {
|
||||
global.fetch = vi.fn((url: string, init?: RequestInit) => {
|
||||
const method = init?.method ?? 'GET'
|
||||
if (method === 'GET' && url === '/v1/site/') {
|
||||
return Promise.resolve(mockResponse(200, oneSite))
|
||||
}
|
||||
if (method === 'GET' && url.startsWith('/v1/article/?')) {
|
||||
const params = parseListUrl(url)
|
||||
listCalls.push(params)
|
||||
@@ -252,7 +256,10 @@ describe('3 Last page', () => {
|
||||
|
||||
describe('4 Single page', () => {
|
||||
it('keeps the summary and the page-size select, hides the paginator and reads the tab counts', async () => {
|
||||
articles = buildArticles(6).map((article, index) => ({ ...article, is_online: index < 4 }))
|
||||
articles = buildArticles(6).map((article, index) => ({
|
||||
...article,
|
||||
is_online: index < 4,
|
||||
}))
|
||||
const wrapper = await mountAt('/article')
|
||||
|
||||
expect(summary()).toBe('Showing 1–6 of 6')
|
||||
@@ -463,14 +470,22 @@ describe('Keyboard, the page-size list', () => {
|
||||
trigger.focus()
|
||||
|
||||
trigger.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true, cancelable: true }),
|
||||
new KeyboardEvent('keydown', {
|
||||
key: 'ArrowDown',
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
)
|
||||
await flushPromises()
|
||||
expect(document.body.querySelector('[role="listbox"]')).not.toBeNull()
|
||||
|
||||
const focused = document.activeElement ?? document.body
|
||||
focused.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true }),
|
||||
new KeyboardEvent('keydown', {
|
||||
key: 'Escape',
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
)
|
||||
await flushPromises()
|
||||
expect(document.body.querySelector('[role="listbox"]')).toBeNull()
|
||||
@@ -487,7 +502,11 @@ describe('Tabs filter on the server', () => {
|
||||
)
|
||||
tab?.focus()
|
||||
tab?.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true }),
|
||||
new KeyboardEvent('keydown', {
|
||||
key: 'Enter',
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
)
|
||||
await flushPromises()
|
||||
|
||||
@@ -623,13 +642,23 @@ describe('8c Sort is kept across paging, page size and search', () => {
|
||||
|
||||
await click(control('Next page'))
|
||||
expect(listCalls.at(-1)).toMatchObject({ page: 2, sort: 'title:asc' })
|
||||
expect(router.currentRoute.value.query).toMatchObject({ page: '2', sort: 'title:asc' })
|
||||
expect(router.currentRoute.value.query).toMatchObject({
|
||||
page: '2',
|
||||
sort: 'title:asc',
|
||||
})
|
||||
|
||||
await wrapper.find('input[type="search"]').setValue('plaster')
|
||||
await vi.advanceTimersByTimeAsync(120)
|
||||
await flushPromises()
|
||||
expect(listCalls.at(-1)).toMatchObject({ page: 1, q: 'plaster', sort: 'title:asc' })
|
||||
expect(router.currentRoute.value.query).toMatchObject({ q: 'plaster', sort: 'title:asc' })
|
||||
expect(listCalls.at(-1)).toMatchObject({
|
||||
page: 1,
|
||||
q: 'plaster',
|
||||
sort: 'title:asc',
|
||||
})
|
||||
expect(router.currentRoute.value.query).toMatchObject({
|
||||
q: 'plaster',
|
||||
sort: 'title:asc',
|
||||
})
|
||||
expect(router.currentRoute.value.query.page).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -657,7 +686,10 @@ describe('8e No client-side re-sorting', () => {
|
||||
it('renders the rows in exactly the order the server returned', async () => {
|
||||
listHandler = (params) => {
|
||||
const page = articleEnvelope(articles, params)
|
||||
return mockResponse(200, { ...page, items: [...page.items].reverse() })
|
||||
return mockResponse(200, {
|
||||
...page,
|
||||
items: [...page.items].reverse(),
|
||||
})
|
||||
}
|
||||
await mountAt('/article?sort=title:asc')
|
||||
|
||||
|
||||
Reference in new issue
Block a user