mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-22 10:30:28 +00:00
wip: notifiers UI
This commit is contained in:
parent
30b1879c35
commit
b6f44dfe58
5 changed files with 298 additions and 3 deletions
59
frontend/lib/api/__test__/user/notifier.test.ts
Normal file
59
frontend/lib/api/__test__/user/notifier.test.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
import { faker } from "@faker-js/faker";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { factories } from "../factories";
|
||||
|
||||
describe("basic notifier workflows", () => {
|
||||
test("user should be able to create, update, and delete a notifier", async () => {
|
||||
const { client } = await factories.client.singleUse();
|
||||
|
||||
// Create Notifier
|
||||
const result = await client.notifiers.create({
|
||||
name: faker.name.firstName(),
|
||||
url: faker.internet.url(),
|
||||
isActive: true,
|
||||
});
|
||||
|
||||
expect(result.error).toBeFalsy();
|
||||
expect(result.status).toBe(201);
|
||||
expect(result.data).toBeTruthy();
|
||||
|
||||
const notifier = result.data;
|
||||
|
||||
// Update Notifier with new URL
|
||||
{
|
||||
const updateData = {
|
||||
name: faker.name.firstName(),
|
||||
url: faker.internet.url(),
|
||||
isActive: true,
|
||||
};
|
||||
|
||||
const updateResult = await client.notifiers.update(notifier.id, updateData);
|
||||
expect(updateResult.error).toBeFalsy();
|
||||
expect(updateResult.status).toBe(200);
|
||||
expect(updateResult.data).toBeTruthy();
|
||||
expect(updateResult.data.name).not.toBe(notifier.name);
|
||||
}
|
||||
|
||||
// Update Notifier with empty URL
|
||||
{
|
||||
const updateData = {
|
||||
name: faker.name.firstName(),
|
||||
url: "",
|
||||
isActive: true,
|
||||
};
|
||||
|
||||
const updateResult = await client.notifiers.update(notifier.id, updateData);
|
||||
expect(updateResult.error).toBeFalsy();
|
||||
expect(updateResult.status).toBe(200);
|
||||
expect(updateResult.data).toBeTruthy();
|
||||
expect(updateResult.data.name).not.toBe(notifier.name);
|
||||
}
|
||||
|
||||
// Delete Notifier
|
||||
{
|
||||
const deleteResult = await client.notifiers.delete(notifier.id);
|
||||
expect(deleteResult.error).toBeFalsy();
|
||||
expect(deleteResult.status).toBe(204);
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue