
Your account could not be loaded.
Testing Infrastructure
Automated testing setup and examples
Unit Tests
Passed
142Failed
3Skipped
5Coverage78%
Integration Tests
Passed
48Failed
1Skipped
2Coverage65%
E2E Tests
Passed
23Failed
0Skipped
1Coverage85%
Unit Test Example - Customer Validation
// tests/utils/customerValidation.test.js
import { validateCustomer } from '@/utils/validation';
describe('Customer Validation', () => {
test('should validate correct customer data', () => {
const customer = {
contact_name: 'John Doe',
phone: '+1234567890',
email: 'john@example.com',
};
const result = validateCustomer(customer);
expect(result.valid).toBe(true);
expect(result.errors).toHaveLength(0);
});
test('should reject customer without name', () => {
const customer = {
phone: '+1234567890',
email: 'john@example.com',
};
const result = validateCustomer(customer);
expect(result.valid).toBe(false);
expect(result.errors).toContain('Contact name is required');
});
test('should reject invalid email format', () => {
const customer = {
contact_name: 'John Doe',
phone: '+1234567890',
email: 'invalid-email',
};
const result = validateCustomer(customer);
expect(result.valid).toBe(false);
expect(result.errors).toContain('Invalid email format');
});
test('should accept customer without email', () => {
const customer = {
contact_name: 'John Doe',
phone: '+1234567890',
};
const result = validateCustomer(customer);
expect(result.valid).toBe(true);
});
});Integration Test Example - Invoice API
// tests/integration/invoice.test.js
import { base44 } from '@/api/base44Client';
describe('Invoice API Integration', () => {
let testCustomer;
let testInvoice;
beforeAll(async () => {
// Create test customer
testCustomer = await base44.entities.Customer.create({
contact_name: 'Test Customer',
phone: '+1234567890',
email: 'test@example.com',
});
});
afterAll(async () => {
// Cleanup
if (testInvoice?.id) {
await base44.entities.Invoice.delete(testInvoice.id);
}
if (testCustomer?.id) {
await base44.entities.Customer.delete(testCustomer.id);
}
});
test('should create invoice successfully', async () => {
testInvoice = await base44.entities.Invoice.create({
customer_id: testCustomer.id,
customer_name: testCustomer.contact_name,
issue_date: new Date().toISOString().split('T')[0],
due_date: new Date(Date.now() + 30*24*60*60*1000).toISOString().split('T')[0],
line_items: [
{
description: 'HVAC Maintenance',
quantity: 1,
unit_price: 150,
total: 150,
}
],
subtotal: 150,
tax_rate: 0.13,
tax_amount: 19.5,
total_amount: 169.5,
balance_due: 169.5,
});
expect(testInvoice.id).toBeDefined();
expect(testInvoice.status).toBe('draft');
expect(testInvoice.total_amount).toBe(169.5);
});
test('should calculate tax correctly', async () => {
expect(testInvoice.tax_amount).toBe(testInvoice.subtotal * testInvoice.tax_rate);
});
test('should send invoice via email', async () => {
const result = await base44.functions.invoke('sendInvoiceEmail', {
invoice_id: testInvoice.id,
});
expect(result.data.success).toBe(true);
expect(result.data.sent_to).toBe(testCustomer.email);
});
});E2E Test Example - Job Creation Flow
// tests/e2e/jobCreation.spec.js
// Using Playwright or Cypress
describe('Job Creation Flow', () => {
beforeEach(() => {
// Login
cy.visit('/');
cy.login('test@example.com', 'password123');
});
it('should create a job end-to-end', () => {
// Navigate to Jobs page
cy.visit('/Jobs');
cy.contains('Jobs').should('be.visible');
// Click Create Job button
cy.contains('Create Job').click();
// Fill in job details
cy.get('[name="title"]').type('HVAC Repair');
cy.get('[name="description"]').type('AC not cooling properly');
// Select customer
cy.get('[data-testid="customer-select"]').click();
cy.contains('John Doe').click();
// Select job type
cy.get('[name="job_type"]').select('repair');
// Set priority
cy.get('[name="priority"]').select('high');
// Schedule
cy.get('[data-testid="date-picker"]').click();
cy.contains('15').click(); // Select 15th
cy.get('[name="start_time"]').type('10:00');
// Assign technician
cy.get('[data-testid="technician-select"]').click();
cy.contains('Mike Smith').click();
// Submit
cy.contains('Create Job').click();
// Verify success
cy.contains('Job created successfully').should('be.visible');
cy.url().should('include', '/JobDetail');
cy.contains('HVAC Repair').should('be.visible');
cy.contains('John Doe').should('be.visible');
});
it('should validate required fields', () => {
cy.visit('/Jobs');
cy.contains('Create Job').click();
// Try to submit without required fields
cy.contains('Create Job').click();
// Should show validation errors
cy.contains('Title is required').should('be.visible');
cy.contains('Customer is required').should('be.visible');
});
});Component Test Example - JobCard
// tests/components/JobCard.test.jsx
import { render, screen, fireEvent } from '@testing-library/react';
import JobCard from '@/components/jobs/JobCard';
describe('JobCard Component', () => {
const mockJob = {
id: '1',
job_number: 'JOB-2024-0001',
title: 'HVAC Repair',
customer_name: 'John Doe',
status: 'scheduled',
priority: 'high',
scheduled_date: '2024-01-15',
scheduled_start_time: '10:00',
technician_name: 'Mike Smith',
};
const mockOnClick = jest.fn();
const mockOnStatusChange = jest.fn();
test('renders job information correctly', () => {
render(<JobCard job={mockJob} onClick={mockOnClick} />);
expect(screen.getByText('HVAC Repair')).toBeInTheDocument();
expect(screen.getByText('John Doe')).toBeInTheDocument();
expect(screen.getByText('JOB-2024-0001')).toBeInTheDocument();
expect(screen.getByText('Mike Smith')).toBeInTheDocument();
});
test('displays correct status badge', () => {
render(<JobCard job={mockJob} onClick={mockOnClick} />);
const statusBadge = screen.getByText('Scheduled');
expect(statusBadge).toBeInTheDocument();
expect(statusBadge).toHaveClass('bg-blue-100');
});
test('displays high priority indicator', () => {
render(<JobCard job={mockJob} onClick={mockOnClick} />);
expect(screen.getByText('High Priority')).toBeInTheDocument();
});
test('calls onClick when card is clicked', () => {
render(<JobCard job={mockJob} onClick={mockOnClick} />);
fireEvent.click(screen.getByText('HVAC Repair'));
expect(mockOnClick).toHaveBeenCalledWith(mockJob);
});
test('handles status change', () => {
render(
<JobCard
job={mockJob}
onClick={mockOnClick}
onStatusChange={mockOnStatusChange}
/>
);
const statusButton = screen.getByRole('button', { name: /status/i });
fireEvent.click(statusButton);
const completeOption = screen.getByText('Mark as Completed');
fireEvent.click(completeOption);
expect(mockOnStatusChange).toHaveBeenCalledWith(mockJob, 'completed');
});
});Recent Test Runs
Invoice creation flow
tests/invoices.test.js
2.3s
Customer CRUD operations
tests/customers.test.js
1.8s
Payment processing
tests/payments.test.js
Expected payment status to be 'succeeded', got 'pending'
0.5s
Job scheduling
tests/jobs.test.js
3.1s