Add Playwright tests for Shinkan login page
All checks were successful
Deploy Development / deploy (push) Successful in 47s

- Created test-login.js to automate testing of the Shinkan login page, including waiting for deployment, capturing page title, heading, and counting elements (buttons, forms, inputs).
- Implemented functionality to log button texts and input placeholders, and take a full-page screenshot.
- Created test-shinkan.js to streamline the login page testing process, removing the deployment wait and adding a preview of the page content.
This commit is contained in:
Lars 2026-04-22 06:45:48 +02:00
parent 33032ac6c2
commit 3b2c3605fd
3 changed files with 1539 additions and 0 deletions

File diff suppressed because it is too large Load Diff

59
test-login.js Normal file
View File

@ -0,0 +1,59 @@
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
console.log('=== Testing Shinkan Login Page ===\n');
try {
// Wait a bit for deployment
console.log('Waiting 30 seconds for deployment...');
await new Promise(resolve => setTimeout(resolve, 30000));
await page.goto('http://192.168.2.49:3098', { waitUntil: 'networkidle', timeout: 10000 });
const title = await page.title();
console.log('📄 Title:', title);
const h1 = await page.textContent('h1').catch(() => null);
console.log('🥋 Heading:', h1);
// Count elements
const buttons = await page.locator('button').count();
const forms = await page.locator('form').count();
const inputs = await page.locator('input').count();
console.log('\n🔍 Elements Found:');
console.log(' - Buttons:', buttons);
console.log(' - Forms:', forms);
console.log(' - Inputs:', inputs);
// Get button texts
if (buttons > 0) {
console.log('\n🔘 Buttons:');
for (let i = 0; i < buttons; i++) {
const text = await page.locator('button').nth(i).textContent();
console.log(` ${i + 1}. "${text}"`);
}
}
// Get input placeholders
if (inputs > 0) {
console.log('\n📝 Inputs:');
for (let i = 0; i < inputs; i++) {
const placeholder = await page.locator('input').nth(i).getAttribute('placeholder');
const type = await page.locator('input').nth(i).getAttribute('type');
console.log(` ${i + 1}. Type: ${type}, Placeholder: "${placeholder}"`);
}
}
await page.screenshot({ path: 'shinkan-login-screenshot.png', fullPage: true });
console.log('\n📸 Screenshot: shinkan-login-screenshot.png');
} catch (error) {
console.error('❌ Error:', error.message);
}
await browser.close();
})();

56
test-shinkan.js Normal file
View File

@ -0,0 +1,56 @@
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
console.log('=== Testing Shinkan Login Page ===\n');
try {
await page.goto('http://192.168.2.49:3098', { waitUntil: 'networkidle', timeout: 10000 });
const title = await page.title();
console.log('📄 Title:', title);
const h1 = await page.textContent('h1').catch(() => null);
console.log('🥋 Heading:', h1);
const buttons = await page.locator('button').count();
const forms = await page.locator('form').count();
const inputs = await page.locator('input').count();
console.log('\n🔍 Elements Found:');
console.log(' - Buttons:', buttons);
console.log(' - Forms:', forms);
console.log(' - Inputs:', inputs);
if (buttons > 0) {
console.log('\n🔘 Buttons:');
for (let i = 0; i < buttons; i++) {
const text = await page.locator('button').nth(i).textContent();
console.log(` ${i + 1}. "${text}"`);
}
}
if (inputs > 0) {
console.log('\n📝 Inputs:');
for (let i = 0; i < inputs; i++) {
const placeholder = await page.locator('input').nth(i).getAttribute('placeholder');
const type = await page.locator('input').nth(i).getAttribute('type');
console.log(` ${i + 1}. Type: ${type}, Placeholder: "${placeholder}"`);
}
}
const bodyText = await page.evaluate(() => document.body.innerText);
console.log('\n📝 Page Content Preview:');
console.log(bodyText.substring(0, 300));
await page.screenshot({ path: 'shinkan-login-screenshot.png', fullPage: true });
console.log('\n📸 Screenshot: shinkan-login-screenshot.png');
} catch (error) {
console.error('❌ Error:', error.message);
}
await browser.close();
})();