const { test, expect } = require('@playwright/test');

test.describe('Nexus POS — Auth Guard', () => {
  test('unauthenticated user redirected to login', async ({ page }) => {
    // Ensure no auth state
    await page.goto('/pos/login');
    await page.evaluate(() => {
      localStorage.clear();
      sessionStorage.clear();
    });

    await page.goto('/pos/sale');
    // app-init.js redirects to /pos/login when no token is found
    await expect(page).toHaveURL(/login/i, { timeout: 5000 });
  });
});
