Skip to content

Commit 0148b59

Browse files
authored
Merge branch 'main' into multi-token-campaign-support
2 parents b66ff94 + 3e9e0fc commit 0148b59

21 files changed

Lines changed: 2046 additions & 349 deletions

CAMPAIGN_FORM_TESTING_COMPLETE.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Campaign Form Testing - Implementation Complete ✅
2+
3+
## Issue Summary
4+
**Problem:** The campaign creation form had no automated tests, so validation logic and submission behavior could break silently.
5+
6+
**Solution:** Comprehensive test suite already implemented covering all validation rules and form submission scenarios.
7+
8+
## Implementation Status: COMPLETE ✅
9+
10+
All acceptance criteria have been met:
11+
12+
### ✅ Tests verify field validation rules for required fields
13+
- Creator account validation (Stellar address format)
14+
- Title validation (4-80 characters)
15+
- Description validation (20-500 characters)
16+
- Target amount validation (minimum 0.01)
17+
- Deadline hours validation (1-8760 hours)
18+
19+
### ✅ Submission with valid data triggers the expected API call
20+
- onCreate callback invoked with correct payload
21+
- Deadline calculated correctly (hours → Unix timestamp)
22+
- Optional metadata included when provided
23+
- Text fields trimmed of whitespace
24+
- Asset code converted to uppercase
25+
26+
### ✅ Submission with invalid data shows error messages
27+
- Form submission prevented when validation errors exist
28+
- All validation errors displayed on submit attempt
29+
- Submit button disabled when form is invalid
30+
- Real-time validation feedback as user types
31+
32+
### ✅ Tests run with the existing frontend test toolchain
33+
- Vitest test runner
34+
- @testing-library/react for component testing
35+
- @testing-library/user-event for user interactions
36+
- No additional dependencies required
37+
38+
## Test Files
39+
40+
### 1. CreateCampaignForm.test.tsx
41+
**Location:** `frontend/src/components/CreateCampaignForm.test.tsx`
42+
**Lines:** 400+ lines
43+
**Test Cases:** 40+ tests
44+
**Coverage:**
45+
- Component rendering
46+
- Field validation (all required fields)
47+
- Form submission (valid and invalid data)
48+
- API error handling
49+
- Asset selection
50+
- Form reset after submission
51+
52+
### 2. CreateCampaignForm.validation.test.tsx
53+
**Location:** `frontend/src/components/CreateCampaignForm.validation.test.tsx`
54+
**Lines:** 150+ lines
55+
**Test Cases:** 10+ tests
56+
**Coverage:**
57+
- Field error display
58+
- Submit button state
59+
- Error styling (CSS classes)
60+
- Real-time validation
61+
62+
### 3. validation.test.ts
63+
**Location:** `frontend/src/utils/validation.test.ts`
64+
**Lines:** 200+ lines
65+
**Test Cases:** 30+ tests
66+
**Coverage:**
67+
- Individual validation functions
68+
- Boundary conditions
69+
- Edge cases
70+
- Form validation aggregation
71+
72+
## Running the Tests
73+
74+
```bash
75+
# Navigate to frontend directory
76+
cd frontend
77+
78+
# Run all tests
79+
npm test
80+
81+
# Run CreateCampaignForm tests specifically
82+
npm test CreateCampaignForm
83+
84+
# Run tests in watch mode
85+
npm test -- --watch
86+
87+
# Run tests with coverage report
88+
npm test -- --coverage
89+
```
90+
91+
## Test Coverage Summary
92+
93+
| Category | Test Cases | Status |
94+
|----------|-----------|--------|
95+
| Component Rendering | 5 ||
96+
| Creator Account Validation | 5 ||
97+
| Title Validation | 4 ||
98+
| Description Validation | 4 ||
99+
| Target Amount Validation | 4 ||
100+
| Deadline Hours Validation | 3 ||
101+
| Form Submission (Valid) | 7 ||
102+
| Form Submission (Invalid) | 4 ||
103+
| API Error Handling | 4 ||
104+
| Asset Selection | 2 ||
105+
| Real-time Validation | 5 ||
106+
| Utility Functions | 30+ ||
107+
| **TOTAL** | **60+** | **** |
108+
109+
## Validation Rules Implemented
110+
111+
### Required Fields
112+
1. **Creator Account**
113+
- Must be exactly 56 characters
114+
- Must start with 'G'
115+
- Must contain only A-Z and 2-7
116+
- Follows Stellar account format
117+
118+
2. **Title**
119+
- Minimum: 4 characters
120+
- Maximum: 80 characters
121+
122+
3. **Description**
123+
- Minimum: 20 characters
124+
- Maximum: 500 characters
125+
126+
4. **Target Amount**
127+
- Must be > 0
128+
- Minimum: 0.01
129+
130+
5. **Deadline Hours**
131+
- Minimum: 1 hour
132+
- Maximum: 8760 hours (365 days)
133+
134+
6. **Asset Code**
135+
- Selected from dropdown
136+
- Converted to uppercase
137+
138+
### Optional Fields
139+
- Image URL (URL format)
140+
- External Link (URL format)
141+
142+
## Key Test Scenarios Covered
143+
144+
### Happy Path
145+
- ✅ User fills valid form → onCreate called with correct payload
146+
- ✅ Form resets after successful submission
147+
- ✅ Optional metadata included when provided
148+
149+
### Error Handling
150+
- ✅ Invalid fields show error messages
151+
- ✅ Submit button disabled when form invalid
152+
- ✅ API errors displayed with details
153+
- ✅ Real-time validation feedback
154+
155+
### Edge Cases
156+
- ✅ Boundary values (min/max lengths)
157+
- ✅ Whitespace trimming
158+
- ✅ Asset code uppercase conversion
159+
- ✅ Deadline calculation (hours to timestamp)
160+
- ✅ Form state during submission
161+
162+
## Documentation
163+
164+
Detailed test documentation available at:
165+
- `frontend/src/components/CREATE_CAMPAIGN_FORM_TEST_SUMMARY.md`
166+
167+
## Conclusion
168+
169+
The CreateCampaignForm component has comprehensive automated test coverage that prevents validation logic and submission behavior from breaking silently. All acceptance criteria have been met, and the tests are integrated with the existing frontend test toolchain.
170+
171+
**Status:** ✅ COMPLETE - No additional work required

CONTRIBUTING.md

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +0,0 @@
1-
# Contributing to Stellar Goal Vault
2-
3-
First off, thank you for considering contributing to Stellar Goal Vault! It's people like you that make the open-source community such an amazing place to learn, inspire, and create.
4-
5-
Stellar Goal Vault is a lightweight crowdfunding MVP for the Stellar ecosystem, and we welcome contributions of all kinds: from bug fixes and documentation to new features and UI improvements.
6-
7-
---
8-
9-
## Table of Contents
10-
11-
1. [Getting Started](#getting-started)
12-
2. [Local Development Setup](#local-development-setup)
13-
3. [Testing](#testing)
14-
4. [Contribution Workflow](#contribution-workflow)
15-
5. [Style & Branch Naming](#style--branch-naming)
16-
6. [Issue Labeling](#issue-labeling)
17-
7. [Pull Request Expectations](#pull-request-expectations)
18-
19-
---
20-
21-
## Getting Started
22-
23-
1. **Fork the repository** on GitHub.
24-
2. **Clone your fork** locally:
25-
```bash
26-
git clone https://github.com/YOUR_USERNAME/stellar-goal-vault.git
27-
cd stellar-goal-vault
28-
```
29-
3. **Set up the upstream remote** to stay synced with the main project:
30-
```bash
31-
git remote add upstream https://github.com/SamixYasuke/stellar-goal-vault.git
32-
```
33-
34-
### Prerequisites
35-
36-
- **Node.js 18+**
37-
- **npm 9+**
38-
- (Optional) **Rust & Soroban CLI** (if you're working on smart contracts)
39-
40-
---
41-
42-
## Local Development Setup
43-
44-
The project is split into three main parts: `frontend`, `backend`, and `contracts`.
45-
46-
### 1. Install All Dependencies
47-
48-
From the repository root, you can install dependencies for both the frontend and backend using:
49-
50-
```bash
51-
npm run install:all
52-
```
53-
54-
### 2. Backend Setup
55-
56-
The backend uses **Express** and **SQLite**.
57-
58-
1. Navigate to the backend directory:
59-
```bash
60-
cd backend
61-
```
62-
2. Create/copy a `.env` file (if needed, see `README.md` for defaults).
63-
3. Run the development server:
64-
```bash
65-
npm run dev
66-
```
67-
The API will be available at `http://localhost:3001`.
68-
69-
### 3. Frontend Setup
70-
71-
The frontend is built with **React + Vite**.
72-
73-
1. Navigate to the frontend directory:
74-
```bash
75-
cd frontend
76-
```
77-
2. Run the development server:
78-
```bash
79-
npm run dev
80-
```
81-
The dashboard will be available at `http://localhost:3000`.
82-
83-
---
84-
85-
## Testing
86-
87-
We use **Vitest** for testing both the frontend and backend.
88-
89-
- **Frontend tests:** Run `npm run test` inside the `/frontend` directory.
90-
- **Backend tests:** Run `npm run test` inside the `/backend` directory.
91-
92-
Before submitting a PR, please ensure that all tests pass.
93-
94-
---
95-
96-
## Contribution Workflow
97-
98-
1. **Find an Issue:** Look for issues labeled `help wanted` or `good first issue`. If you have a new idea, please open an issue first to discuss it.
99-
2. **Assign Yourself:** Comment on the issue to let others know you're working on it.
100-
3. **Create a Branch:** (See [Style & Branch Naming](#style--branch-naming)).
101-
4. **Implementation:** Write your code, following existing patterns and styles.
102-
5. **Add Tests:** If you're adding a feature or fixing a bug, please include tests.
103-
6. **Submit a PR:** Push your branch and open a Pull Request against the `main` branch.
104-
105-
---
106-
107-
## Style & Branch Naming
108-
109-
### Branch Naming Conventions
110-
111-
To keep the repository organized, please use the following prefixes for your branches:
112-
113-
- `feat/` — For new features (e.g., `feat/add-freighter-signing`)
114-
- `fix/` — For bug fixes (e.g., `fix/sqlite-connection-leak`)
115-
- `docs/` — For documentation changes (e.g., `docs/update-api-reference`)
116-
- `refactor/` — For code cleanup or restructuring
117-
- `test/` — For adding or improving tests
118-
119-
### Coding Standards
120-
121-
- Use **TypeScript** for both frontend and backend.
122-
- Follow **standard Prettier/ESLint rules** (automated linting runs in CI).
123-
- Keep components small and modular.
124-
125-
---
126-
127-
## Issue Labeling
128-
129-
We use labels to categorize issues and make it easier for contributors to find tasks:
130-
131-
- `good first issue` — Perfect for new contributors. Usually small, well-defined tasks.
132-
- `help wanted` — Tasks we need help with but might be more complex.
133-
- `bug` — Something isn't working as expected.
134-
- `enhancement` — New features or improvements.
135-
- `frontend` / `backend` / `soroban` — Indicates which part of the stack is involved.
136-
- `ux` — Focuses on user interface and experience improvements.
137-
- `indexer` — Related to the on-chain event indexing logic.
138-
139-
---
140-
141-
## Pull Request Expectations
142-
143-
When you open a PR, please fill out the provided template (if available) or ensure it includes:
144-
145-
- **What changed?** A clear summary of your work.
146-
- **Why?** Link to the issue being addressed.
147-
- **How was it tested?** Detail your manual and automated testing.
148-
- **Screenshots?** Highly recommended for any frontend/UI changes.
149-
150-
---
151-
152-
## Thank You!
153-
154-
Your contributions make this project better for everyone in the Stellar ecosystem. If you have any questions, feel free to reach out via GitHub Issues.

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,51 @@ Build:
161161
npm run build
162162
```
163163

164+
## API load testing
165+
166+
The backend includes a configurable load test script built with `autocannon` to simulate concurrent campaign reads and pledge writes.
167+
168+
1. Start the backend locally:
169+
170+
```bash
171+
npm run dev:backend
172+
```
173+
174+
2. In a second terminal, run the load test:
175+
176+
```bash
177+
cd backend
178+
npm run load:test -- --base-url http://127.0.0.1:3001 --connections 20 --duration 20
179+
```
180+
181+
The script seeds synthetic campaigns first, then runs a mixed workload across:
182+
- `GET /api/campaigns`
183+
- `GET /api/campaigns/:id`
184+
- `POST /api/campaigns/:id/pledges`
185+
186+
The console output includes:
187+
- Latency percentiles (`p50`, `p90`, `p97.5`, `p99`, `max`)
188+
- Error rate, timeout count, and non-2xx responses
189+
- Average requests per second and throughput
190+
191+
Useful flags:
192+
- `--connections <number>`: concurrent connections
193+
- `--duration <seconds>`: test duration
194+
- `--campaigns <number>`: number of seed campaigns created before the run
195+
- `--read-weight <number>`: relative share of campaign read requests
196+
- `--pledge-weight <number>`: relative share of pledge requests
197+
- `--pledge-amount <number>`: amount sent in each pledge request
198+
- `--target-amount <number>`: target amount assigned to each seed campaign
199+
- `--asset-code <code>`: asset code used while seeding campaigns
200+
- `--deadline-hours <hours>`: how far into the future seeded campaign deadlines are set
201+
202+
Example validation run:
203+
204+
```bash
205+
cd backend
206+
npm run load:test -- --base-url http://127.0.0.1:3001 --duration 5 --connections 5 --campaigns 4 --read-weight 3 --pledge-weight 2
207+
```
208+
164209
## Deploy contract
165210

166211
Set a funded Stellar testnet secret key and run:
@@ -204,6 +249,10 @@ That issue is already represented in:
204249
- `OPEN_SOURCE_ISSUES.md`
205250
- The frontend backlog panel
206251

252+
## Contributing
253+
Please see the [Contributing Guide](./CONTRIBUTING.md) for setup and contribution guidelines.
254+
255+
207256
## Known limitations
208257

209258
- Campaign creation is still local-first, so pledges will only simulate successfully for campaign IDs that also exist in the configured contract

0 commit comments

Comments
 (0)