mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 06:43:06 +00:00
CLI operacional `content:instagram:import`: lê o feed oficial do perfil, filtra a janela por dias (default 60), deduplica pela identidade do post e processa cada novidade inline pelo pipeline C220 (download, transcrição, catalogação); --publish publica ao final o que terminou pronto, mais antigo primeiro, e revalida a Central pública. Guardas C155/C195/C231 (TEQO_ENV + nome exato do banco, confirmação explícita, S3_* obrigatórias, dry-run padrão).
62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getGlobalCacheTag } from '@/utilities/globals'
|
|
import { MUNICIPALITY_CATALOG_CACHE_TAG } from '@/utilities/municipality/municipalityCatalogCache'
|
|
import {
|
|
REVALIDATE_CONTENT_PIECES_TAG,
|
|
REVALIDATE_POSTS_TAG,
|
|
REVALIDATE_PRIVACY_POLICY_CACHE_TAG,
|
|
resolveRevalidateTag,
|
|
} from '@/utilities/revalidateRequest'
|
|
|
|
describe('resolveRevalidateTag', () => {
|
|
it('defaults to posts when no tag is provided', () => {
|
|
expect(resolveRevalidateTag(null, null)).toEqual({ ok: true, tag: REVALIDATE_POSTS_TAG })
|
|
expect(resolveRevalidateTag(undefined, undefined)).toEqual({
|
|
ok: true,
|
|
tag: REVALIDATE_POSTS_TAG,
|
|
})
|
|
expect(resolveRevalidateTag('', '')).toEqual({ ok: true, tag: REVALIDATE_POSTS_TAG })
|
|
})
|
|
|
|
it('accepts allowlisted tags from query or body', () => {
|
|
expect(resolveRevalidateTag('posts', null)).toEqual({ ok: true, tag: REVALIDATE_POSTS_TAG })
|
|
expect(resolveRevalidateTag(null, 'posts')).toEqual({ ok: true, tag: REVALIDATE_POSTS_TAG })
|
|
expect(resolveRevalidateTag(null, REVALIDATE_PRIVACY_POLICY_CACHE_TAG)).toEqual({
|
|
ok: true,
|
|
tag: REVALIDATE_PRIVACY_POLICY_CACHE_TAG,
|
|
})
|
|
expect(resolveRevalidateTag(MUNICIPALITY_CATALOG_CACHE_TAG, null)).toEqual({
|
|
ok: true,
|
|
tag: MUNICIPALITY_CATALOG_CACHE_TAG,
|
|
})
|
|
// C230-followup — the import CLI busts the Central's listing through here.
|
|
expect(resolveRevalidateTag(REVALIDATE_CONTENT_PIECES_TAG, null)).toEqual({
|
|
ok: true,
|
|
tag: REVALIDATE_CONTENT_PIECES_TAG,
|
|
})
|
|
})
|
|
|
|
it('prefers query tag over body tag', () => {
|
|
expect(resolveRevalidateTag('posts', REVALIDATE_PRIVACY_POLICY_CACHE_TAG)).toEqual({
|
|
ok: true,
|
|
tag: REVALIDATE_POSTS_TAG,
|
|
})
|
|
})
|
|
|
|
it('rejects unknown tags', () => {
|
|
const result = resolveRevalidateTag('global_metadata', null)
|
|
expect(result.ok).toBe(false)
|
|
if (!result.ok) {
|
|
expect(result.error).toContain('Unknown tag')
|
|
expect(result.error).toContain(REVALIDATE_POSTS_TAG)
|
|
expect(result.error).toContain(REVALIDATE_PRIVACY_POLICY_CACHE_TAG)
|
|
}
|
|
})
|
|
|
|
it('maps privacy-policy global slug to the shared cache tag helper', () => {
|
|
expect(REVALIDATE_PRIVACY_POLICY_CACHE_TAG).toBe(getGlobalCacheTag('privacy-policy'))
|
|
})
|
|
})
|