⚠️ This is test/experimental code for API integration testing. Do not use in production. Includes: - WellNuo API integration (dashboard, patient context) - Playwright tests for API verification - WebView component for dashboard embedding - API documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
108 lines
4.4 KiB
JavaScript
108 lines
4.4 KiB
JavaScript
const { test, expect } = require('@playwright/test');
|
|
|
|
const GITEA_URL = 'https://gitea.wellnua.com';
|
|
const EMAIL = 'serter2069@gmail.com';
|
|
const USERNAME = 'serter2069';
|
|
const PASSWORD = 'WellNuo2025!Secure';
|
|
|
|
test('register on Gitea and accept invitation', async ({ page }) => {
|
|
console.log('=== GITEA REGISTRATION ===\n');
|
|
|
|
// Step 1: Go to Gitea
|
|
console.log('1. Opening Gitea...');
|
|
await page.goto(GITEA_URL);
|
|
await page.waitForLoadState('networkidle');
|
|
await page.screenshot({ path: 'tests/screenshots/gitea-01-home.png', fullPage: true });
|
|
|
|
// Check current page
|
|
const pageContent = await page.content();
|
|
console.log(' Page title:', await page.title());
|
|
|
|
// Step 2: Find register/login link
|
|
const registerLink = page.locator('a:has-text("Register"), a:has-text("Sign Up"), a[href*="register"]').first();
|
|
const loginLink = page.locator('a:has-text("Sign In"), a:has-text("Login"), a[href*="login"]').first();
|
|
|
|
if (await registerLink.isVisible().catch(() => false)) {
|
|
console.log('2. Found Register link, clicking...');
|
|
await registerLink.click();
|
|
await page.waitForLoadState('networkidle');
|
|
await page.screenshot({ path: 'tests/screenshots/gitea-02-register.png', fullPage: true });
|
|
|
|
// Fill registration form
|
|
console.log('3. Filling registration form...');
|
|
|
|
const usernameField = page.locator('input[name="user_name"], input[id="user_name"], input[placeholder*="Username"]').first();
|
|
const emailField = page.locator('input[name="email"], input[type="email"]').first();
|
|
const passwordField = page.locator('input[name="password"], input[type="password"]').first();
|
|
const confirmField = page.locator('input[name="retype"], input[name="confirm_password"], input[type="password"]').nth(1);
|
|
|
|
if (await usernameField.isVisible()) {
|
|
await usernameField.fill(USERNAME);
|
|
console.log(' - Username filled');
|
|
}
|
|
if (await emailField.isVisible()) {
|
|
await emailField.fill(EMAIL);
|
|
console.log(' - Email filled');
|
|
}
|
|
if (await passwordField.isVisible()) {
|
|
await passwordField.fill(PASSWORD);
|
|
console.log(' - Password filled');
|
|
}
|
|
if (await confirmField.isVisible()) {
|
|
await confirmField.fill(PASSWORD);
|
|
console.log(' - Confirm password filled');
|
|
}
|
|
|
|
await page.screenshot({ path: 'tests/screenshots/gitea-03-form-filled.png', fullPage: true });
|
|
|
|
// Submit registration
|
|
const submitBtn = page.locator('button[type="submit"], input[type="submit"]').first();
|
|
if (await submitBtn.isVisible()) {
|
|
console.log('4. Submitting registration...');
|
|
await submitBtn.click();
|
|
await page.waitForLoadState('networkidle');
|
|
await page.waitForTimeout(2000);
|
|
await page.screenshot({ path: 'tests/screenshots/gitea-04-after-submit.png', fullPage: true });
|
|
|
|
console.log(' Current URL:', page.url());
|
|
}
|
|
|
|
} else if (await loginLink.isVisible().catch(() => false)) {
|
|
console.log('2. Found Login link (maybe already registered), trying to login...');
|
|
await loginLink.click();
|
|
await page.waitForLoadState('networkidle');
|
|
await page.screenshot({ path: 'tests/screenshots/gitea-02-login.png', fullPage: true });
|
|
|
|
// Try to login
|
|
const usernameField = page.locator('input[name="user_name"], input[id="user_name"]').first();
|
|
const passwordField = page.locator('input[name="password"], input[type="password"]').first();
|
|
|
|
if (await usernameField.isVisible()) {
|
|
await usernameField.fill(USERNAME);
|
|
await passwordField.fill(PASSWORD);
|
|
|
|
const submitBtn = page.locator('button[type="submit"]').first();
|
|
await submitBtn.click();
|
|
await page.waitForLoadState('networkidle');
|
|
await page.waitForTimeout(2000);
|
|
await page.screenshot({ path: 'tests/screenshots/gitea-03-after-login.png', fullPage: true });
|
|
|
|
console.log(' Current URL:', page.url());
|
|
}
|
|
} else {
|
|
console.log('2. Cannot find register/login links');
|
|
console.log(' Page HTML:', pageContent.substring(0, 1000));
|
|
}
|
|
|
|
// Step 5: Try to access the repository
|
|
console.log('5. Trying to access repository...');
|
|
await page.goto(`${GITEA_URL}/robert/MobileApp_react_native`);
|
|
await page.waitForLoadState('networkidle');
|
|
await page.screenshot({ path: 'tests/screenshots/gitea-05-repo.png', fullPage: true });
|
|
|
|
console.log(' Repo URL:', page.url());
|
|
console.log(' Page title:', await page.title());
|
|
|
|
console.log('\n=== DONE ===');
|
|
});
|