This document outlines the testing approach for the IdeaScore application. Testing will be integrated throughout the development process to ensure quality and reliability.
Unit tests focus on individual functions and components to ensure they work correctly in isolation.
Key Areas to Test:
Example Unit Tests:
// Example test for the ratio calculation function
test('calculateRatio should handle various inputs correctly', () => {
expect(calculateRatio(10, 5)).toBe(2); // Normal case
expect(calculateRatio(0, 5)).toBe(0); // Edge case: zero payoff
expect(calculateRatio(10, 0)).toBe(Infinity); // Edge case: zero effort
expect(calculateRatio(null, 5)).toBe(0); // Edge case: null payoff
});
Integration tests verify that different parts of the application work together correctly.
Key Areas to Test:
Example Integration Tests:
// Example test for idea creation flow
test('Creating a new idea should store it in the database and appear in the list', async () => {
// Submit form with test data
await submitIdeaForm({
title: 'Test Idea',
description: 'Test Description',
effortScore: 5,
payoffScore: 8
});
// Verify the idea appears in the database
const ideas = await getIdeas('test@example.com');
const newIdea = ideas.find(idea => idea.title === 'Test Idea');
expect(newIdea).toBeDefined();
expect(newIdea.effort_score).toBe(5);
expect(newIdea.payoff_score).toBe(8);
// Verify the idea appears in the UI
const ideaElements = document.querySelectorAll('.idea-item');
const uiIdea = Array.from(ideaElements).find(el =>
el.querySelector('.idea-title').textContent === 'Test Idea'
);
expect(uiIdea).toBeDefined();
});
UI tests verify that the user interface works correctly and provides a good user experience.
Key Areas to Test:
Example UI Tests:
// Example test for form validation
test('Idea form should validate required fields', async () => {
// Try to submit the form without required fields
await clickElement('#submit-button');
// Check for error messages
expect(document.querySelector('#title-error')).toBeVisible();
expect(document.querySelector('#effort-score-error')).toBeVisible();
expect(document.querySelector('#payoff-score-error')).toBeVisible();
// Fill out one field and check that only its error is cleared
await typeIntoInput('#title-input', 'Test Idea');
expect(document.querySelector('#title-error')).not.toBeVisible();
expect(document.querySelector('#effort-score-error')).toBeVisible();
});
Data isolation tests verify that data from one application or user doesn't leak into another.
Key Areas to Test:
Example Data Isolation Tests:
// Example test for user data isolation
test('Users should only see their own ideas', async () => {
// Create ideas for two different users
await createIdeaForUser('user1@example.com', {
title: 'User 1 Idea',
effortScore: 5,
payoffScore: 7
});
await createIdeaForUser('user2@example.com', {
title: 'User 2 Idea',
effortScore: 3,
payoffScore: 8
});
// Log in as user1 and verify they only see their ideas
await loginAs('user1@example.com');
const user1Ideas = await getDisplayedIdeas();
expect(user1Ideas.some(idea => idea.title === 'User 1 Idea')).toBe(true);
expect(user1Ideas.some(idea => idea.title === 'User 2 Idea')).toBe(false);
// Log in as user2 and verify they only see their ideas
await loginAs('user2@example.com');
const user2Ideas = await getDisplayedIdeas();
expect(user2Ideas.some(idea => idea.title === 'User 1 Idea')).toBe(false);
expect(user2Ideas.some(idea => idea.title === 'User 2 Idea')).toBe(true);
});
Performance tests verify that the application performs well under various conditions.
Key Areas to Test:
Example Performance Tests:
// Example test for list performance with many ideas
test('Idea list should render quickly with 100+ ideas', async () => {
// Create 100+ test ideas
await createBulkIdeas(100);
// Measure render time
const startTime = performance.now();
await navigateToIdeaList();
const endTime = performance.now();
// Verify render time is acceptable (e.g., under 500ms)
expect(endTime - startTime).toBeLessThan(500);
// Verify all ideas are eventually loaded (might be paginated)
expect(document.querySelectorAll('.idea-item').length).toBeGreaterThan(0);
});
Accessibility tests verify that the application is usable by people with disabilities.
Key Areas to Test:
Example Accessibility Tests:
// Example test for keyboard navigation
test('Users should be able to navigate the idea list with keyboard', async () => {
await navigateToIdeaList();
// Tab to the first idea
await pressTab();
expect(document.activeElement.closest('.idea-item')).toBeDefined();
// Tab to the edit button
await pressTab();
expect(document.activeElement.textContent).toBe('Edit');
// Tab to the delete button
await pressTab();
expect(document.activeElement.textContent).toBe('Delete');
// Tab to the next idea
await pressTab();
expect(document.activeElement.closest('.idea-item')).toBeDefined();
});
For the IdeaScore application, we'll use a lightweight testing approach that works well within the Val Town environment:
Tests will be organized according to the checkpoints in the development roadmap. Each checkpoint will have associated tests that must pass before proceeding to the next checkpoint.
/projects/ideaScore/tests/
├── unit/ # Unit tests for utility functions
├── integration/ # Integration tests for features
├── ui/ # UI testing checklists
├── test-utils.js # Shared testing utilities
└── test-runner.js # Simple test runner
A checkpoint is considered successfully tested when:
The testing strategy will evolve as the project progresses:
This testing strategy provides a framework for ensuring the quality of the IdeaScore application throughout its development lifecycle.