import { test, expect } from '../../fixtures/index';
import { LoginPage } from '../../pom/login.page';
import { DashboardPage } from '../../pom/dashboard.page';

test("Verify all page available", {
    tag: ['@PRODUCTION_001', '@dashboard', '@function', "@PRODUCTION_READ_ONLY", "@PRODUCTION_CHECK"]
}, async ({ page, conf }) => {
    test.setTimeout(150_000);
    let loginPage = new LoginPage(page);
    let dashboard = new DashboardPage(page);

    await test.step("Login first", async () => {
        await loginPage.page.goto("sign-in", { waitUntil: 'domcontentloaded' });
        await loginPage.login(conf.data.username, conf.data.password);
        await expect(loginPage.baseLoc.dashboardContainer).toBeVisible();
    })

    for (const { name, link } of dashboard.pages) {
        await test.step(`Verify page ${name} avaible`, async () => {
            if (name !== "Shared Cases") {
                await dashboard.page.goto(link, { waitUntil: 'domcontentloaded' });
                await expect(dashboard.dashboardLoc.namePage).toContainText(name);
            }
        })
    }
})  