feat: editorial article list

This commit is contained in:
Florian Sylvain committed 2026-11-02 07:28:44 +01:00
1 parent a0b3c58c52
commit a671b81f80
103 files changed
+6493 -1805

No files matched your search

@@ -11,6 +11,9 @@ describe('parseArticleQuery', () => {
sort: '',
site: '',
seo: '',
lang: '',
tab: '',
author: 0,
})
})
@@ -31,6 +34,9 @@ describe('parseArticleQuery', () => {
sort: 'title:asc',
site: '',
seo: '',
lang: '',
tab: '',
author: 0,
})
})
@@ -55,6 +61,51 @@ describe('parseArticleQuery', () => {
})
})
describe('localized list parameters', () => {
it('reads lang, tab and author', () => {
expect(parseArticleQuery({ lang: 'fr', tab: 'missing', author: '12' })).toMatchObject({
lang: 'fr',
tab: 'missing',
author: 12,
})
})
it.each(['english', 'x', '', 'fr_FR', '12'])('falls back from the lang "%s"', (lang) => {
expect(parseArticleQuery({ lang }).lang).toBe('')
})
it.each(['review', 'all', 'published', ''])('falls back from the tab "%s"', (tab) => {
expect(parseArticleQuery({ tab }).tab).toBe('')
})
it.each(['abc', '0', '-1', '', '1.5'])('falls back from the author "%s"', (author) => {
expect(parseArticleQuery({ author }).author).toBe(0)
})
it('drops the status when the tab is Not in language', () => {
expect(parseArticleQuery({ tab: 'missing', status: 'draft' }).status).toBe('')
})
it('writes lang, tab and author and omits their defaults', () => {
expect(
toRouteQuery({
...parseArticleQuery({}),
lang: 'fr',
tab: 'missing',
author: 4,
}),
).toEqual({ lang: 'fr', tab: 'missing', author: '4' })
expect(toRouteQuery(parseArticleQuery({}))).toEqual({})
})
it('tells queries apart by lang, tab and author', () => {
const base = parseArticleQuery({})
expect(sameArticleQuery(base, { ...base, lang: 'fr' })).toBe(false)
expect(sameArticleQuery(base, { ...base, tab: 'missing' })).toBe(false)
expect(sameArticleQuery(base, { ...base, author: 3 })).toBe(false)
})
})
describe('sort parameter', () => {
it.each(['title:asc', 'status:desc', 'created_at:asc', 'created_at:desc'])(
'keeps %s',