teqo-backup/tests/e2e/campaignAuth.e2e.spec.ts
Francisco Ignácio Fontoura Solla 4806c417c8 Engineering Pass 3: consolidate patterns and lock them with guards.
Fold duplicated campanha access, loaders, list/filter/form shells, and scripts into shared modules; reorganize utilities by domain; stabilize e2e; and document prevention-first audit workflow so the same smells cannot creep back in.
2026-07-29 06:11:29 -03:00

32 lines
1.2 KiB
TypeScript

import { CAMPAIGN_SESSION_TTL_LONG } from '../../src/lib/campaignSessionTtl.js'
import { expect, test } from './fixtures/campaignE2EFixtures.js'
test('logs in with a remembered fourteen-day campaign session', async ({
campaign,
context,
page,
}) => {
test.slow()
const { fixtures } = campaign
const rememberedUser = await fixtures.createCampaignUser('advisor', {
name: fixtures.value('Usuária lembrada'),
})
const email = rememberedUser.email!
const password = rememberedUser.password
await page.goto('/campanha/login')
const rememberMe = page.getByRole('checkbox', {
name: 'Lembrar de mim neste dispositivo',
})
await expect(rememberMe).toBeVisible()
await expect(rememberMe).not.toBeChecked()
await page.getByLabel('E-mail ou celular').fill(email)
await page.getByLabel('Senha').fill(password)
await rememberMe.check()
const loggedInAt = Math.floor(Date.now() / 1000)
await page.getByRole('button', { name: 'Entrar', exact: true }).click()
await page.waitForURL(/\/campanha$/)
const tokenCookie = (await context.cookies()).find((cookie) => cookie.name === 'campaign-token')
expect(tokenCookie?.expires).toBeGreaterThan(loggedInAt + CAMPAIGN_SESSION_TTL_LONG - 60)
})