Skip to content

Commit 14eb67a

Browse files
committed
Can inject more application level faults
1 parent a5712c1 commit 14eb67a

12 files changed

Lines changed: 654 additions & 590 deletions

File tree

‎app/(dashboard)/dashboard/activity/page.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
1414
import { getActivityLogs } from "@/lib/db/queries";
1515
import { ActivityType } from "@/lib/db/schema";
16+
import { isFaultActive } from "@/lib/faults";
1617

1718
const iconMap: Record<ActivityType, LucideIcon> = {
1819
[ActivityType.SIGN_UP]: UserPlus,
@@ -70,6 +71,9 @@ function formatAction(action: ActivityType): string {
7071

7172
export default async function ActivityPage() {
7273
const logs = await getActivityLogs();
74+
const visibleLogs = (await isFaultActive("activity-missing-create-team"))
75+
? logs.filter((log) => log.action !== ActivityType.CREATE_TEAM)
76+
: logs;
7377

7478
return (
7579
<section className="flex-1 p-4 lg:p-8">
@@ -81,9 +85,9 @@ export default async function ActivityPage() {
8185
<CardTitle>Recent Activity</CardTitle>
8286
</CardHeader>
8387
<CardContent>
84-
{logs.length > 0 ? (
88+
{visibleLogs.length > 0 ? (
8589
<ul className="space-y-4">
86-
{logs.map((log) => {
90+
{visibleLogs.map((log) => {
8791
const Icon = iconMap[log.action as ActivityType] || Settings;
8892
const formattedAction = formatAction(
8993
log.action as ActivityType,

‎app/api/team/route.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import { getTeamForUser } from "@/lib/db/queries";
2+
import { isFaultActive } from "@/lib/faults";
23

34
export async function GET() {
5+
if (await isFaultActive("api-team-malformed-json")) {
6+
return new Response("{", {
7+
status: 200,
8+
headers: {
9+
"content-type": "application/json",
10+
"x-fault-injected": "api-team-malformed-json",
11+
},
12+
});
13+
}
14+
415
const team = await getTeamForUser();
516
return Response.json(team);
617
}

‎cf/wrangler.jsonc‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"main": "src/index.js",
44
"compatibility_date": "2026-03-25",
55
"routes": [
6-
{
7-
"pattern": "playwright-tutorial-sqlite-db-every-hour-cleanup.endform.dev",
8-
"custom_domain": true
9-
}
10-
],
6+
{
7+
"pattern": "playwright-tutorial-sqlite-db-every-hour-cleanup.endform.dev",
8+
"custom_domain": true
9+
}
10+
],
1111
"durable_objects": {
1212
"bindings": [
1313
{

‎lib/auth/login.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { and, eq } from "drizzle-orm";
2-
import { hashPassword, setSession } from "@/lib/auth/session";
2+
import { hashPassword } from "@/lib/auth/session";
33
import { db } from "@/lib/db/drizzle";
44
import {
55
ActivityType,
@@ -11,6 +11,7 @@ import {
1111
teams,
1212
users,
1313
} from "@/lib/db/schema";
14+
import { isFaultActive } from "@/lib/faults";
1415
import { logActivity } from "./activity";
1516

1617
export async function signup(
@@ -115,8 +116,14 @@ export async function signup(
115116
role: userRole,
116117
};
117118

119+
const skipTeamMembership =
120+
Boolean(inviteId) &&
121+
(await isFaultActive("invite-accepted-but-member-missing"));
122+
118123
await Promise.all([
119-
db.insert(teamMembers).values(newTeamMember),
124+
...(skipTeamMembership
125+
? []
126+
: [db.insert(teamMembers).values(newTeamMember)]),
120127
logActivity(teamId, createdUser.id, ActivityType.SIGN_UP),
121128
]);
122129

0 commit comments

Comments
 (0)