Initial commit with tests and deployment pipeline
Test and Deploy Website / test-and-deploy (push) Successful in 1m12s

This commit is contained in:
2026-06-15 14:00:18 +02:00
commit f0b4f42cb1
11 changed files with 613 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
const { test, expect } = require('@playwright/test');
test.describe('E2E Tests: Portfolio Homepage', () => {
test('should load page and display correct title and header', async ({ page }) => {
await page.goto('/');
// Check title
await expect(page).toHaveTitle(/Robert Müller/i);
// Check header heading
const heading = page.locator('h1');
await expect(heading).toBeVisible();
await expect(heading).toContainText('Robert Müller');
});
test('should contain interactive email link', async ({ page }) => {
await page.goto('/');
// Check if mail link exists and has correct href
const mailLink = page.locator('a[href^="mailto:"]');
await expect(mailLink).toBeVisible();
await expect(mailLink).toHaveAttribute('href', 'mailto:mail@robert-mueller.net');
});
});
+35
View File
@@ -0,0 +1,35 @@
const test = require('node:test');
const assert = require('node:assert');
const http = require('http');
const { spawn } = require('child_process');
test('Integration Tests: Local Static Server', async (t) => {
// Start server as a child process
const serverProcess = spawn('node', ['server.js']);
// Wait for server to start
await new Promise((resolve) => setTimeout(resolve, 1500));
await t.test('Server returns 200 OK for index.html', () => {
return new Promise((resolve, reject) => {
http.get('http://localhost:8080/', (res) => {
assert.strictEqual(res.statusCode, 200);
assert.match(res.headers['content-type'], /text\/html/);
resolve();
}).on('error', reject);
});
});
await t.test('Server returns 404 for non-existent routes', () => {
return new Promise((resolve, reject) => {
http.get('http://localhost:8080/non-existent-page.html', (res) => {
assert.strictEqual(res.statusCode, 404);
resolve();
}).on('error', reject);
});
});
// Stop server
serverProcess.kill();
await new Promise((resolve) => setTimeout(resolve, 500));
});
+16
View File
@@ -0,0 +1,16 @@
const test = require('node:test');
const assert = require('node:assert');
const { validateEmail, formatGreeting } = require('../public/js/utils.js');
test('Unit Tests: validateEmail', (t) => {
assert.strictEqual(validateEmail('mail@robert-mueller.net'), true);
assert.strictEqual(validateEmail('invalid-email'), false);
assert.strictEqual(validateEmail('@domain.com'), false);
});
test('Unit Tests: formatGreeting', (t) => {
assert.strictEqual(
formatGreeting('evening', 'Robert Müller'),
"Good evening, welcome to Robert Müller's portfolio!"
);
});