import { createRequire } from 'node:module'

import { describe, expect, it } from 'vitest'

const require = createRequire(import.meta.url)

describe('dashboard next config', () => {
  it('allows generated static media assets to be loaded across local app origins', async () => {
    const nextConfig = require('../next.config.js')

    const headers = await nextConfig.headers()

    expect(headers).toEqual(
      expect.arrayContaining([
        {
          source: '/_next/static/media/:path*',
          headers: expect.arrayContaining([
            {
              key: 'Access-Control-Allow-Origin',
              value: '*',
            },
          ]),
        },
      ]),
    )
  })
})
