Files
tilbudgivern/tests/roof-type-verification.spec.js

96 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @ts-check
const { test, expect } = require('@playwright/test');
const BASE_URL = process.env.PLAYWRIGHT_BASE_URL || 'https://tilbudsgiveren.alw.dk';
async function loginIfNeeded(page) {
const loginHeading = page.getByRole('heading', { name: /Log ind/i });
const isLogin = await loginHeading.isVisible().catch(() => false);
if (!isLogin) return;
const username = 'toemrer';
const password = 'tilbud2024';
await page.locator('input[type="text"]').first().fill(username);
await page.locator('input[type="password"]').first().fill(password);
await page.getByRole('button', { name: /Log ind/i }).click();
await page.waitForTimeout(1500);
}
const roofTypes = [
{ value: 'sadeltag', label: 'Sadeltag' },
{ value: 'valmtag', label: 'Valmtag' },
{ value: 'koebenhavnertag', label: 'Københavnertag' },
{ value: 'fladt_tag', label: 'Fladtag' },
{ value: 'pulttag', label: 'Pulttag' },
{ value: 'tag_med_kviste', label: 'Tag med kviste' },
{ value: 'mansard', label: 'Mansardtag' }
];
test.describe('Roof Type Verification', () => {
test('Verify app loads and navigation works', async ({ page }) => {
await page.goto(BASE_URL + '/');
await page.waitForLoadState('networkidle');
console.log('\n🏠 TESTING APP LOAD AND NAVIGATION\n');
// Check if we're at login page (need to login)
const loginButton = page.getByRole('button', { name: /Log ind/i });
const isLoginPageVisible = await loginButton.isVisible().catch(() => false);
if (isLoginPageVisible) {
console.log(' 📝 Login page detected, logging in...');
await loginIfNeeded(page);
await page.waitForLoadState('networkidle');
}
// Check for main app header
const appHeader = page.getByRole('heading', { name: /Tilbudgivern/i });
const headerVisible = await appHeader.isVisible().catch(() => false);
console.log(` ${headerVisible ? '✅' : '❌'} App header: ${headerVisible ? 'Found' : 'Not found'}`);
expect(headerVisible).toBeTruthy();
// Check for navigation buttons
const navButtons = await page.locator('button').count();
console.log(` ✅ Found ${navButtons} navigation buttons`);
// Check that page has some meaningful content
const pageText = await page.locator('body').textContent();
const hasContent = pageText.length > 100;
console.log(` ${hasContent ? '✅' : '❌'} Page has meaningful content: ${hasContent ? 'Yes' : 'No'}`);
expect(hasContent).toBeTruthy();
console.log('\n📊 App Navigation Test Passed\n');
});
test('Check geometry calculator availability', async ({ page }) => {
await page.goto(BASE_URL + '/');
await page.waitForLoadState('networkidle');
await loginIfNeeded(page);
console.log('\n🔍 Checking for geometry calculator...');
// Look for geometry/calculation related elements
const geometryKeywords = ['geometri', 'beregning', 'avanceret', 'tag'];
let foundGeometry = false;
const pageText = await page.locator('body').textContent();
for (const keyword of geometryKeywords) {
if (pageText.toLowerCase().includes(keyword)) {
console.log(` ✅ Found keyword: "${keyword}"`);
foundGeometry = true;
}
}
if (foundGeometry) {
console.log(' ✅ Geometry calculator likely available\n');
} else {
console.log(' Geometry calculator not immediately visible\n');
}
expect(foundGeometry).toBeTruthy();
});
});