
import { test, expect } from '@playwright/test';

test.describe('PWA Manifest', () => {
    test('should serve a valid manifest.webmanifest', async ({ request }) => {
        const response = await request.get('/manifest.webmanifest');
        expect(response.status()).toBe(200);
        expect(response.headers()['content-type']).toContain('application/manifest+json');

        const manifest = await response.json();

        // Core properties matching manifest.ts
        expect(manifest.name).toBe('Test01');
        expect(manifest.short_name).toBe('Test01');
        expect(manifest.display).toBe('standalone');
        expect(manifest.start_url).toBe('/');
        expect(manifest.background_color).toBe('#F8FAFC');
        expect(manifest.theme_color).toBe('#64748B');

        // Icons
        expect(manifest.icons.length).toBeGreaterThanOrEqual(2);
        expect(manifest.icons).toEqual(
            expect.arrayContaining([
                expect.objectContaining({
                    src: '/icons/icon-192x192.png',
                    sizes: '192x192',
                    type: 'image/png'
                }),
                expect.objectContaining({
                    src: '/icons/icon-512x512.png',
                    sizes: '512x512',
                    type: 'image/png'
                })
            ])
        );
    });

    test('should have accessible icon files', async ({ request }) => {
        const icon192 = await request.get('/icons/icon-192x192.png');
        expect(icon192.status()).toBe(200);

        const icon512 = await request.get('/icons/icon-512x512.png');
        expect(icon512.status()).toBe(200);
    });
});
