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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ jobs:
- name: Seed admin account
run: npx tsx prisma/seed.ts

- name: Seed e2e fixtures
run: npx tsx e2e/seed.ts

- name: Build
run: npm run build

Expand Down
36 changes: 36 additions & 0 deletions e2e/seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { PrismaClient } from "@prisma/client"
import { PrismaPg } from "@prisma/adapter-pg"

// E2E fixture: one employee so a fresh instance counts as set up
// (the dashboard redirects empty workspaces to /setup). Run after
// prisma/seed.ts; used by the CI e2e job only.
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! })
const prisma = new PrismaClient({ adapter })

async function main() {
const company = await prisma.company.findUniqueOrThrow({
where: { domain: "datashield.dev" },
})

await prisma.employee.upsert({
where: {
email_companyId: { email: "jane.doe@datashield.dev", companyId: company.id },
},
update: {},
create: {
email: "jane.doe@datashield.dev",
firstName: "Jane",
lastName: "Doe",
department: "Engineering",
companyId: company.id,
},
})

}

main()
.then(() => prisma.$disconnect())
.catch((e) => {
console.error(e)
process.exit(1)
})
10 changes: 10 additions & 0 deletions e2e/smoke.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { test, expect } from "@playwright/test"

let cspViolations: string[]
let pageErrors: string[]

test.beforeEach(({ page }) => {
cspViolations = []
pageErrors = []
page.on("console", (msg) => {
const text = msg.text()
if (text.includes("Content Security Policy") || text.includes("Refused to")) {
cspViolations.push(text)
}
})
page.on("pageerror", (err) => {
pageErrors.push(err.message)
})
})

test.afterEach(() => {
expect(cspViolations).toEqual([])
expect(pageErrors).toEqual([])
})

test("admin signs in, sees dashboard and alerts", async ({ page }) => {
Expand All @@ -27,4 +33,8 @@ test("admin signs in, sees dashboard and alerts", async ({ page }) => {

await page.goto("/alerts")
await expect(page.getByRole("main")).toBeVisible()

await page.goto("/dashboard/widgets")
await expect(page.getByRole("heading", { name: "Widget Library" })).toBeVisible()
await expect(page.getByRole("heading", { name: "Alert Severity" })).toBeVisible()
})
13 changes: 8 additions & 5 deletions src/app/(dashboard)/dashboard/widgets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getDashboardData } from "@/lib/dashboard"
import { prisma } from "@/lib/prisma"
import { WIDGETS } from "@/lib/widgetRegistry"
import { WidgetLibrary } from "@/components/dashboard/WidgetLibrary"
import { DetailDrawerProvider } from "@/contexts/DetailDrawerContext"
import { StatsRow } from "@/components/dashboard/StatsRow"
import { TrendChart } from "@/components/dashboard/TrendChart"
import { DataTypeBreakdown } from "@/components/dashboard/DataTypeBreakdown"
Expand Down Expand Up @@ -86,10 +87,12 @@ export default async function WidgetsPage() {
}

return (
<WidgetLibrary
preset={preset}
allWidgets={WIDGETS}
widgetPreviews={widgetPreviews}
/>
<DetailDrawerProvider>
<WidgetLibrary
preset={preset}
allWidgets={WIDGETS}
widgetPreviews={widgetPreviews}
/>
</DetailDrawerProvider>
)
}