The Atlantisz logo has white lettering made for a dark header, invisible on our light background, and its official name differs between the logo and the admin entry. The partner_references migration now classifies it as a pending client reference in environments where it has not run yet; the follow-up 20260929_atlantisz_pending migration moves the already granted staging entry to pending, touching only the automatic classification (a later admin decision is left alone). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
3.7 KiB
TypeScript
69 lines
3.7 KiB
TypeScript
import { classifyPartner, seedReferencesSection, up } from '../migrations/20260929_partner_references'
|
|
import { markAtlantiszPending, PENDING_REFERENCE } from '../migrations/20260929_atlantisz_pending'
|
|
import { fakeArgs, fakeCollection } from './helpers/fake-mongo'
|
|
|
|
type Doc = Record<string, unknown>
|
|
|
|
describe('20260929_partner_references migration (MITHOME-131)', () => {
|
|
it('should mark the confirmed client as a client reference with written permission', () => {
|
|
const doc: Doc = { name: 'Angele Pihenőház', url: 'https://angelepihenohaz.hu' }
|
|
expect(classifyPartner(doc)).toBe(1)
|
|
expect(doc).toMatchObject({ relationship: 'client-reference', publicationPermission: 'granted' })
|
|
expect(doc.permissionReference).toMatch(/Írásos engedély/)
|
|
})
|
|
|
|
it('should mark the Atlantisz contracted client as a client reference, pending until its logo is settled', () => {
|
|
const doc: Doc = { name: 'Atlantisz Horgászüdülő és Halásztanya' }
|
|
classifyPartner(doc)
|
|
expect(doc).toMatchObject({ relationship: 'client-reference', publicationPermission: 'pending' })
|
|
})
|
|
|
|
it('should move an already granted Atlantisz entry to pending, but respect later admin decisions', () => {
|
|
const auto: Doc = {
|
|
name: 'Atlantisz Horgászüdülő és Halásztanya',
|
|
publicationPermission: 'granted',
|
|
permissionReference: 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)',
|
|
}
|
|
expect(markAtlantiszPending(auto)).toBe(1)
|
|
expect(auto).toMatchObject({ publicationPermission: 'pending', permissionReference: PENDING_REFERENCE })
|
|
expect(markAtlantiszPending(auto)).toBe(0)
|
|
const admin: Doc = { name: 'Atlantisz Horgászüdülő és Halásztanya', publicationPermission: 'granted', permissionReference: 'E-mail, 2026-10-05' }
|
|
expect(markAtlantiszPending(admin)).toBe(0)
|
|
const angele: Doc = { name: 'Angele Pihenőház', publicationPermission: 'granted', permissionReference: 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)' }
|
|
expect(markAtlantiszPending(angele)).toBe(0)
|
|
})
|
|
|
|
it('should hide any other uncategorised entry until someone classifies it', () => {
|
|
const doc: Doc = { name: 'Ismeretlen Kft.' }
|
|
classifyPartner(doc)
|
|
expect(doc).toEqual({ name: 'Ismeretlen Kft.', publicationPermission: 'none' })
|
|
})
|
|
|
|
it('should not touch an already categorised entry', () => {
|
|
const doc: Doc = { name: 'Angele Pihenőház', relationship: 'supplier', publicationPermission: 'pending' }
|
|
expect(classifyPartner(doc)).toBe(0)
|
|
expect(doc.relationship).toBe('supplier')
|
|
})
|
|
|
|
it('should seed the section copy in both languages only when missing', () => {
|
|
const doc: Doc = {}
|
|
seedReferencesSection(doc)
|
|
expect(doc.referencesSection).toMatchObject({
|
|
clientsTitle: { hu: 'Akik már minket választottak', en: 'Clients who chose us' },
|
|
relationshipLabels: { infrastructure: { hu: 'Technológiai háttér', en: 'Infrastructure provider' } },
|
|
})
|
|
const edited: Doc = { referencesSection: { clientsTitle: { hu: 'Saját cím' } } }
|
|
expect(seedReferencesSection(edited)).toBe(0)
|
|
})
|
|
|
|
it('should update the partners collection and the home global, idempotently', async () => {
|
|
const partners = fakeCollection([{ _id: 'p1', name: 'Angele Pihenőház' }])
|
|
const globals = fakeCollection([{ _id: 'h', globalType: 'home' }])
|
|
const { args, payload } = fakeArgs({ globals, collections: { partners } })
|
|
await up(args)
|
|
expect(payload.logger.info).toHaveBeenLastCalledWith('MITHOME-131 references: 1 partner record(s) classified, 1 home record(s) seeded')
|
|
await up(args)
|
|
expect(payload.logger.info).toHaveBeenLastCalledWith('MITHOME-131 references: 0 partner record(s) classified, 0 home record(s) seeded')
|
|
})
|
|
})
|