next.js/test/e2e/app-dir/sitemap-group/sitemap-group.test.ts
sitemap-group.test.ts43 lines1.3 KB
import { nextTestSetup } from 'e2e-utils'

describe('sitemap-group', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

  it('should not add suffix to sitemap under group routes', async () => {
    const res = await next.fetch('/foo/sitemap.xml')
    expect(res.status).toBe(200)
    expect(res.headers.get('content-type')).toBe('application/xml')
    const text = await res.text()
    expect(text).toMatchInlineSnapshot(`
      "<?xml version="1.0" encoding="UTF-8"?>
      <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
      <url>
      <loc>https://www.vercel.com</loc>
      <lastmod>2024-12-05T23:45:13.405Z</lastmod>
      <changefreq>monthly</changefreq>
      </url>
      </urlset>
      "
    `)
  })

  it('should not add suffix to static sitemap.xml under group routes', async () => {
    const res = await next.fetch('/bar/sitemap.xml')
    expect(res.status).toBe(200)
    expect(res.headers.get('content-type')).toBe('application/xml')
    const text = await res.text()
    expect(text).toMatchInlineSnapshot(`
      "<?xml version="1.0" encoding="UTF-8"?>
      <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <url>
          <loc>https://vercel.com/</loc>
          <lastmod>2023-03-06T18:04:14.008Z</lastmod>
        </url>
      </urlset>
      "
    `)
  })
})
Quest for Codev2.0.0
/
SIGN IN