Füge Cypress Konfiguration und Testumgebung hinzu

- Fügt cypress.config.ts für E2E und Komponenten Tests hinzu
- Fügt Cypress Testskripte und Docker-Compose Konfiguration hinzu
- Ermöglicht automatische E2E-Tests mit separater Testumgebung

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-03-28 10:40:15 +01:00
parent 4e0fa33dee
commit 27e1b2d82c
9 changed files with 433 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
describe('Homepage', () => {
beforeEach(() => {
cy.visit('/')
})
it('loads the homepage successfully', () => {
cy.contains('Manage Your Printers')
cy.get('a[href="/printer"]').should('exist')
})
it('shows printer cards', () => {
cy.get('[class*="w-auto h-36"]').should('exist')
})
it('has working navigation', () => {
cy.get('header').should('exist')
cy.get('a[href="/"]').should('exist')
})
})

View File

@@ -0,0 +1,30 @@
describe('Printer Pages', () => {
it('loads printer detail page', () => {
// Setup a basic printer route with a simple mock
cy.intercept('GET', '/api/printers/*', {
id: '1',
name: 'Test Drucker',
description: 'Ein Testdrucker',
status: 'available'
}).as('getPrinter')
cy.visit('/printer/1')
cy.wait('@getPrinter')
cy.contains('Test Drucker')
})
it('shows all printers', () => {
// Mock printers list
cy.intercept('GET', '/api/printers', [
{ id: '1', name: 'Drucker 1', status: 'available' },
{ id: '2', name: 'Drucker 2', status: 'in_use' },
{ id: '3', name: 'Drucker 3', status: 'maintenance' }
]).as('getPrinters')
cy.visit('/')
cy.wait('@getPrinters')
cy.contains('Drucker 1')
cy.contains('Drucker 2')
cy.contains('Drucker 3')
})
})

View File

@@ -0,0 +1,52 @@
describe('Printer reservation workflow', () => {
beforeEach(() => {
// Login without OAuth
cy.login()
// Mock API responses
cy.intercept('GET', '/api/printers', [
{
id: '1',
name: 'Drucker 1',
description: 'Test Drucker',
status: 'available',
printJobs: []
}
]).as('getPrinters')
})
it('allows a user to view and reserve a printer', () => {
cy.visit('/')
cy.wait('@getPrinters')
// Check printer is shown and available
cy.contains('Drucker 1')
cy.contains('Verfügbar')
// Start reservation process
cy.contains('Reservieren').click()
// Fill in the form
cy.get('input[name="hours"]').clear().type('1')
cy.get('input[name="minutes"]').clear().type('30')
cy.get('textarea[name="comments"]').type('Testauftrag')
// Mock job creation
cy.intercept('POST', '/api/printers/*/reserve', {
id: 'job-123',
printerId: '1',
userId: 'test-user-id',
startTime: new Date().toISOString(),
endTime: new Date(Date.now() + 90 * 60000).toISOString(),
status: 'active'
}).as('createJob')
// Submit the form
cy.contains('button', 'Reservieren').click()
cy.wait('@createJob')
// Verify successful reservation
cy.url().should('include', '/job/')
cy.contains('Druckauftrag').should('exist')
})
})