import { expect, type Page } from '@playwright/test'

const TEST_USER_EMAIL =
  process.env.PLAYWRIGHT_TEST_EMAIL || 'teamadmin@resolutionflow.example.com'
const TEST_USER_PASSWORD =
  process.env.PLAYWRIGHT_TEST_PASSWORD || 'TestPass123!'

export async function signIn(page: Page) {
  await page.goto('/login')

  await expect(page.getByTestId('login-form')).toBeVisible()
  await page.getByLabel('Email address').fill(TEST_USER_EMAIL)
  await page.getByLabel('Password').fill(TEST_USER_PASSWORD)
  await page.getByTestId('login-submit').click()

  await expect(page.getByTestId('app-shell')).toBeVisible()
}
