// @ts-check
import { test, expect } from "@playwright/test";

test("Test de connexion", async ({ page }) => {
  const account = "Bilouuuuuuu94!@@";

  await page.goto("/login");
  await page.waitForURL("/login");

  await page
    .locator(
      "#layout-container > main > div > form > input[type=text]:nth-child(1)",
    )
    .fill(account);
  await page
    .locator(
      "#layout-container > main > div > form > input[type=password]:nth-child(2)",
    )
    .fill(account);
  await page.locator("#layout-container > main > div > form > button").click({
    button: "left",
  });

  await page.waitForURL("/");

  expect(await page.title()).toBe("Accueil");
  expect(await page.locator("#title").innerText()).toBe(`Bonjour ${account} !`);

  test.setTimeout(10000);

  await page.waitForURL("/");
});
