Skip to content

Commit 18a7ef6

Browse files
committed
feat: add starter project with intentional bugs and TODOs for e2e testing
1 parent dac07b1 commit 18a7ef6

6 files changed

Lines changed: 152 additions & 1 deletion

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
# quantcode-e2e-test
2-
E2E test repository for QuantCode autonomous agents
2+
3+
E2E test repository for QuantCode autonomous agents.
4+
5+
## Structure
6+
7+
- `src/calculator.ts` — Basic arithmetic functions (has a division-by-zero bug)
8+
- `src/string-utils.ts` — String utility functions (has a word count bug, missing truncate function)
9+
- `src/task-manager.ts` — Task management class (missing remove, update, and sortBy methods)
10+
- `test/` — Test files (incomplete coverage)
11+
12+
## Running Tests
13+
14+
```bash
15+
bun test
16+
```

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "quantcode-e2e-test",
3+
"version": "1.0.0",
4+
"description": "E2E test repository for QuantCode autonomous agents",
5+
"type": "module",
6+
"scripts": {
7+
"test": "bun test",
8+
"lint": "echo 'no linter configured'"
9+
},
10+
"devDependencies": {}
11+
}

src/calculator.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Simple calculator module.
3+
* Used for testing QuantCode autonomous agent capabilities.
4+
*/
5+
6+
export function add(a: number, b: number): number {
7+
return a + b
8+
}
9+
10+
export function subtract(a: number, b: number): number {
11+
return a - b
12+
}
13+
14+
export function multiply(a: number, b: number): number {
15+
return a * b
16+
}
17+
18+
// BUG: Division by zero is not handled
19+
export function divide(a: number, b: number): number {
20+
return a / b
21+
}

src/string-utils.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* String utility functions.
3+
*/
4+
5+
export function capitalize(str: string): string {
6+
if (!str) return str
7+
return str.charAt(0).toUpperCase() + str.slice(1)
8+
}
9+
10+
export function reverse(str: string): string {
11+
return str.split("").reverse().join("")
12+
}
13+
14+
// TODO: implement truncate function
15+
// Should truncate a string to maxLength and add "..." if truncated
16+
// Should not truncate in the middle of a word
17+
18+
export function slugify(str: string): string {
19+
return str
20+
.toLowerCase()
21+
.replace(/[^a-z0-9]+/g, "-")
22+
.replace(/^-|-$/g, "")
23+
}
24+
25+
// BUG: This doesn't handle multiple consecutive spaces
26+
export function wordCount(str: string): number {
27+
if (!str.trim()) return 0
28+
return str.split(" ").length
29+
}

src/task-manager.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Simple task manager.
3+
* Manages a list of tasks with priorities and status tracking.
4+
*/
5+
6+
export type Priority = "low" | "medium" | "high"
7+
export type Status = "pending" | "in_progress" | "completed"
8+
9+
export interface Task {
10+
id: string
11+
title: string
12+
description?: string
13+
priority: Priority
14+
status: Status
15+
createdAt: Date
16+
completedAt?: Date
17+
}
18+
19+
export class TaskManager {
20+
private tasks: Map<string, Task> = new Map()
21+
private nextId = 1
22+
23+
add(title: string, priority: Priority = "medium", description?: string): Task {
24+
const task: Task = {
25+
id: String(this.nextId++),
26+
title,
27+
description,
28+
priority,
29+
status: "pending",
30+
createdAt: new Date(),
31+
}
32+
this.tasks.set(task.id, task)
33+
return task
34+
}
35+
36+
get(id: string): Task | undefined {
37+
return this.tasks.get(id)
38+
}
39+
40+
list(filter?: { status?: Status; priority?: Priority }): Task[] {
41+
let result = Array.from(this.tasks.values())
42+
if (filter?.status) result = result.filter((t) => t.status === filter.status)
43+
if (filter?.priority) result = result.filter((t) => t.priority === filter.priority)
44+
return result
45+
}
46+
47+
complete(id: string): boolean {
48+
const task = this.tasks.get(id)
49+
if (!task) return false
50+
task.status = "completed"
51+
task.completedAt = new Date()
52+
return true
53+
}
54+
55+
// TODO: implement remove method
56+
// TODO: implement update method to change title/description/priority
57+
// TODO: implement sortBy method (by priority, createdAt, or status)
58+
}

test/calculator.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { describe, test, expect } from "bun:test"
2+
import { add, subtract, multiply } from "../src/calculator"
3+
4+
// Note: divide is intentionally not tested — has a known bug
5+
6+
describe("calculator", () => {
7+
test("adds two numbers", () => {
8+
expect(add(2, 3)).toBe(5)
9+
})
10+
11+
test("subtracts two numbers", () => {
12+
expect(subtract(5, 3)).toBe(2)
13+
})
14+
15+
test("multiplies two numbers", () => {
16+
expect(multiply(4, 3)).toBe(12)
17+
})
18+
})

0 commit comments

Comments
 (0)