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

const STORYBOOK_BASE_URL = process.env.STORYBOOK_BASE_URL || 'http://127.0.0.1:6006';

const STORIES = [
  { id: 'admin-pages--dashboard', text: 'Total Users' },
  { id: 'admin-pages--department-management', text: 'Department Management' },
  { id: 'admin-pages--internal-dashboard-management', text: 'Internal Dashboard Management' },
  { id: 'admin-pages--external-dashboard-management', text: 'External Dashboard Management' },
];

test.describe('Storybook admin stories smoke', () => {
  for (const story of STORIES) {
    test(`renders ${story.id}`, async ({ page }) => {
      const url = `${STORYBOOK_BASE_URL}/iframe.html?id=${story.id}&viewMode=story`;
      await page.goto(url, { waitUntil: 'domcontentloaded' });
      await expect(page.locator('body')).not.toContainText('No story found');
      await expect(page.locator('body')).not.toContainText('Couldn’t find story');
      await expect(page.locator('body')).toBeVisible({ timeout: 20_000 });
    });
  }
});
