Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/admin/routes/submissions/[form]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export default function SubmissionsFormRoute(
<table class="admin-table">
<thead><tr><th>ID</th><th>Submitted</th><th>Status</th><th></th></tr></thead>
<tbody>
{(data.items as Array<{ id: string; createdAt: number; status: string }>).map((s) => (
{(data.items as Array<{ id: string; receivedAt: number; status: string }>).map((s) => (
<tr key={s.id}>
<td><code class="s-6b9c179a">{s.id}</code></td>
<td class="s-3044b600">{new Date(s.createdAt).toLocaleString()}</td>
<td class="s-3044b600">{new Date(s.receivedAt).toLocaleString()}</td>
<td><span class="badge">{s.status}</span></td>
<td><a href={`${data.prefix}/submissions/${data.form}/${s.id}`} class="btn btn-sm">View</a></td>
</tr>
Expand Down
27 changes: 27 additions & 0 deletions tests/admin/submissions_list_test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @jsxImportSource preact */
/**
* Regression test: the per-form submissions list must render the submission
* timestamp from `receivedAt` (Unix ms, the field on the Submission
* interface). It previously read `s.createdAt`, which does not exist, so
* every row showed "Invalid Date".
*/

import { assertEquals, assertStringIncludes } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { render } from "preact-render-to-string";
import SubmissionsFormRoute from "../../src/admin/routes/submissions/[form]/index.tsx";

Deno.test("submissions list: renders a valid date from receivedAt (not 'Invalid Date')", () => {
const receivedAt = 1788249949694;
const html = render(
<SubmissionsFormRoute
data={{
form: "join",
prefix: "/admin",
items: [{ id: "abc123", receivedAt, status: "new" }],
}}
/>,
);

assertEquals(html.includes("Invalid Date"), false);
assertStringIncludes(html, new Date(receivedAt).toLocaleString());
});