Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions packages/db/src/fixtures/__tests__/seed-demo-data.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions packages/db/src/fixtures/seed-demo-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
githubInstallations,
repositories,
tasks,
taskPullRequests,
users,
} from '../schema';
import { db } from '../db';
Expand Down Expand Up @@ -68,6 +69,33 @@ export const demoSeedTasks = [
},
] as const;

export const demoSeedPullRequests = [
{
taskId: 'demo-seed-task-fix-login',
repository: 'roomote-demo/demo-web',
prNumber: 101,
prUrl: 'https://github.com/roomote-demo/demo-web/pull/101',
prTitle: 'Fix expired-session redirect handling',
status: 'open',
},
{
taskId: 'demo-seed-task-add-webhooks',
repository: 'roomote-demo/demo-api',
prNumber: 201,
prUrl: 'https://github.com/roomote-demo/demo-api/pull/201',
prTitle: 'Add webhook retry policy',
status: 'draft',
},
{
taskId: 'demo-seed-task-add-webhooks',
repository: 'roomote-demo/demo-web',
prNumber: 202,
prUrl: 'https://github.com/roomote-demo/demo-web/pull/202',
prTitle: 'Show webhook retry status',
status: 'open',
},
] as const;

interface DemoSeedSummary {
created: string[];
skipped: string[];
Expand Down Expand Up @@ -240,5 +268,31 @@ export async function seedDemoData(): Promise<DemoSeedSummary> {
record(`task run for ${task.id}`, !existingTaskRun);
}

// A single-PR task and a split task keep the seeded dashboard useful for
// exercising task-level PR presentation without requiring remote GitHub data.
for (const pullRequest of demoSeedPullRequests) {
const existingPullRequest = await db.query.taskPullRequests.findFirst({
where: and(
eq(taskPullRequests.taskId, pullRequest.taskId),
eq(taskPullRequests.prUrl, pullRequest.prUrl),
),
});

if (!existingPullRequest) {
await db.insert(taskPullRequests).values({
taskId: pullRequest.taskId,
sourceControlProvider: 'github',
host: 'github.com',
prUrl: pullRequest.prUrl,
prNumber: pullRequest.prNumber,
prTitle: pullRequest.prTitle,
repository: pullRequest.repository,
status: pullRequest.status,
});
}

record(`pull request ${pullRequest.prUrl}`, !existingPullRequest);
}

return summary;
}
Loading