import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import Footer from '@/components/brand/Footer'
// The production CSP is `img-src 'self' data: blob:` (DEPLOY.md): every
// footer image must be served by the application itself (R4.10j, the
// ZenQuality logo was hotlinked from zenquality.fr and refused).
describe('Footer', () => {
it('serves every image from the application, never an external host', () => {
render()
const sources = screen.getAllByRole('img').map((img) => img.getAttribute('src'))
expect(sources).toHaveLength(2)
for (const src of sources) {
expect(src).toMatch(/^\/(?!\/)|^data:|^blob:/)
expect(src).not.toMatch(/^https?:/)
}
})
it('keeps the credit links', () => {
render()
expect(screen.getByRole('link', { name: 'ZenQuality' })).toHaveAttribute(
'href',
'https://zenquality.fr',
)
expect(screen.getByRole('link', { name: 'Paws in Harmony' })).toHaveAttribute(
'href',
'https://www.instagram.com/paws.iin.harmony',
)
})
})