chore(tests): 🔧 Update TypeScript test files in tests directory

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Lilith 2026-01-31 16:52:56 -08:00
parent aaa75702c5
commit cba96c2795
6 changed files with 56 additions and 31 deletions

View file

@ -104,13 +104,14 @@ test.describe('Merch Idea Submission', () => {
})
test('should submit form with only required field filled (mock)', async ({ page }) => {
// Set up console listener
const consoleLogs: string[] = []
page.on('console', (msg) => {
if (msg.type() === 'log') {
consoleLogs.push(msg.text())
}
})
// Mock the merch submissions API endpoint
await page.route('**/api/merch/submissions', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 1, status: 'received' }),
})
)
const ideaField = page.locator('#idea-description')
const submitButton = page.locator('button.submit-button[type="submit"]')
@ -118,23 +119,24 @@ test.describe('Merch Idea Submission', () => {
// Fill only required field
await ideaField.fill('I would love to see lilith-branded hoodies with the logo on the back!')
// Submit form
await submitButton.click()
// Submit form and wait for API response
const [response] = await Promise.all([
page.waitForResponse('**/api/merch/submissions'),
submitButton.click(),
])
// Verify console log (mock submission) - ViewModel logs 'Merch Idea Submission:'
await page.waitForTimeout(100)
const submissionLog = consoleLogs.find((log) => log.includes('Merch Idea Submission'))
expect(submissionLog).toBeDefined()
expect(response.status()).toBe(200)
})
test('should submit form with all fields filled (mock)', async ({ page }) => {
// Set up console listener
const consoleLogs: string[] = []
page.on('console', (msg) => {
if (msg.type() === 'log') {
consoleLogs.push(msg.text())
}
})
// Mock the merch submissions API endpoint
await page.route('**/api/merch/submissions', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 2, status: 'received' }),
})
)
const nameField = page.locator('#idea-name')
const emailField = page.locator('#idea-email')
@ -146,13 +148,13 @@ test.describe('Merch Idea Submission', () => {
await emailField.fill('jane@example.com')
await ideaField.fill('Suggestion: Create tote bags with the lilith logo and a motivational quote about liberation.')
// Submit form
await submitButton.click()
// Submit form and wait for API response
const [response] = await Promise.all([
page.waitForResponse('**/api/merch/submissions'),
submitButton.click(),
])
// Verify console log (mock submission) - ViewModel logs 'Merch Idea Submission:'
await page.waitForTimeout(100)
const submissionLog = consoleLogs.find((log) => log.includes('Merch Idea Submission'))
expect(submissionLog).toBeDefined()
expect(response.status()).toBe(200)
})
test('should validate email format', async ({ page }) => {

View file

@ -225,8 +225,16 @@ test.describe('Regression: Roadmap Page Race Condition', () => {
expect(bodyText).toBeTruthy()
expect(bodyText!.length).toBeGreaterThan(200)
// Should contain phase-related content
expect(bodyText!.toLowerCase()).toContain('foundation')
// Should contain phase-related content (check for phase card structure)
// The page should have multiple phase cards (foundation, protection, performer, creator, enterprise)
const phaseCards = page.locator('.phase-card')
await expect(phaseCards).toHaveCount(5, { timeout: 10000 })
// Verify the first phase card has essential structure
const firstPhase = phaseCards.first()
await expect(firstPhase.locator('.phase-title')).toBeVisible()
await expect(firstPhase.locator('.phase-description')).toBeVisible()
await expect(firstPhase.locator('.phase-highlights')).toBeVisible()
// Should NOT show raw translation keys
expect(bodyText).not.toContain('phases.foundation.highlights')

View file

@ -17,6 +17,7 @@ import { test as authTest } from '../../fixtures/auth.fixture'
import { ROUTE_COMPONENT_MAP, CTA_MODAL_ROUTES } from '../../fixtures/route-component-map'
import { bypassAgeGate, assertRouteRendersComponent, assertPageIdentity, seedCart } from '../../helpers'
import { mockGiftCardProductSuccess } from '../../helpers/api-mocks'
import { MOCK_CART_GIFT_CARD_100 } from '../../fixtures/api-data'
base.describe('Route Component Mapping', () => {
@ -31,6 +32,10 @@ base.describe('Route Component Mapping', () => {
for (const route of publicRoutes) {
base(`${route.path} renders ${route.description} (${route.expectedTestId})`, async ({ page }) => {
// Mock gift card product API for /shop/gift-cards route
if (route.path === '/shop/gift-cards') {
await mockGiftCardProductSuccess(page)
}
await assertRouteRendersComponent(page, route)
})
}

View file

@ -18,6 +18,7 @@ import { test as authTest } from '../../fixtures/auth.fixture'
import { ROUTE_COMPONENT_MAP } from '../../fixtures/route-component-map'
import { bypassAgeGate, seedCart } from '../../helpers'
import { mockGiftCardProductSuccess } from '../../helpers/api-mocks'
import { MOCK_CART_GIFT_CARD_100 } from '../../fixtures/api-data'
base.describe('Route Negative Assertions (Wrong-Component Detection)', () => {
@ -39,6 +40,11 @@ base.describe('Route Negative Assertions (Wrong-Component Detection)', () => {
for (const route of publicRoutesWithNegatives) {
base(`${route.path} does NOT render sibling components`, async ({ page }) => {
// Mock gift card product API for /shop/gift-cards route
if (route.path === '/shop/gift-cards') {
await mockGiftCardProductSuccess(page)
}
await page.goto(route.path)
await page.waitForLoadState('networkidle')

View file

@ -37,6 +37,10 @@ test.describe('Cart Drawer', () => {
await page.goto('/shop/gift-cards')
await page.waitForLoadState('networkidle')
// Wait for page to fully render (i18n + animations)
// The floating cart button has a 0.5s animation delay
await page.waitForTimeout(1000)
const cartDrawer = new CartDrawerPage(page)
await cartDrawer.openCart()
await cartDrawer.assertDrawerOpen()

View file

@ -197,9 +197,9 @@ test.describe('Manifesto Pages', () => {
// Should redirect to values index
await expect(page).toHaveURL(/\/company\/values$/);
// Values page should be visible (uses .cv-hero for hero section)
const hero = page.locator('.cv-hero, [data-testid="page-company-values"]');
await expect(hero).toBeVisible({ timeout: 15000 });
// Values page should show manifesto cards
const manifestoCards = page.locator('.manifesto-card');
await expect(manifestoCards.first()).toBeVisible({ timeout: 15000 });
});
});