import { Given, When } from '@cucumber/cucumber' import { strict as assert } from 'assert' import type { PerausetWorld } from '../support/world.js' import { openDb } from '../support/db.js' Given('a test notification exists for the current user', async function (this: PerausetWorld) { const userId = await this.getSessionUserId() const db = openDb() try { const row = db .prepare( `INSERT INTO notification (user_id, type, title, body) VALUES (?, 'test', 'Test Notification', 'This is a test notification') RETURNING notification_id` ) .get(userId) as { notification_id: string } ;(this as any).notificationId = row.notification_id } finally { db.close() } }) When('I mark the notification as read', async function (this: PerausetWorld) { const notificationId = (this as any).notificationId assert.ok(notificationId, 'No notification ID stored') await this.post(`/notifications/${notificationId}/read`, { notificationId, }) })