feat: manage owner usage history records
This commit is contained in:
@@ -84,6 +84,7 @@ function createRepository(
|
||||
createdAt: "2026-07-29T00:00:00.000Z"
|
||||
};
|
||||
},
|
||||
async deleteUsageRecord() {},
|
||||
async getDashboard(periodYear: number) {
|
||||
return {
|
||||
periodYear,
|
||||
@@ -389,6 +390,34 @@ test("business errors retain safe status and code", async t => {
|
||||
assert.equal(JSON.stringify(response.json()).includes("password"), false);
|
||||
});
|
||||
|
||||
test("usage deletion validates the record id and returns no content", async t => {
|
||||
let captured: string | undefined;
|
||||
const repository = createRepository({
|
||||
async deleteUsageRecord(id) {
|
||||
captured = id;
|
||||
}
|
||||
});
|
||||
const { app, cookie } = await buildAuthenticatedApp(repository);
|
||||
t.after(() => app.close());
|
||||
|
||||
const response = await app.inject({
|
||||
method: "DELETE",
|
||||
url: `/usage-records/${usageId}`,
|
||||
headers: { cookie }
|
||||
});
|
||||
assert.equal(response.statusCode, 204);
|
||||
assert.equal(response.body, "");
|
||||
assert.equal(captured, usageId);
|
||||
|
||||
const malformed = await app.inject({
|
||||
method: "DELETE",
|
||||
url: "/usage-records/not-a-uuid",
|
||||
headers: { cookie }
|
||||
});
|
||||
assert.equal(malformed.statusCode, 400);
|
||||
assert.equal(malformed.json().error.code, "VALIDATION_ERROR");
|
||||
});
|
||||
|
||||
test("dashboard and OpenAPI expose the planned surface", async t => {
|
||||
const { app, cookie } = await buildAuthenticatedApp(createRepository());
|
||||
t.after(() => app.close());
|
||||
@@ -412,6 +441,7 @@ test("dashboard and OpenAPI expose the planned surface", async t => {
|
||||
"/owner-accounts",
|
||||
"/owner-accounts/{id}",
|
||||
"/room-types",
|
||||
"/usage-records"
|
||||
"/usage-records",
|
||||
"/usage-records/{id}"
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user