mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-30 04:25:40 +00:00
23b5892aef
* introduce scaffold for new models * wip: shoutrrr wrapper (may remove) * update schema files * gen: ent code * gen: migrations * go mod tidy * add group_id to notifier * db migration * new mapper helpers * notifier repo * introduce experimental adapter pattern for hdlrs * refactor adapters to fit more common use cases * new routes for notifiers * update errors to fix validation panic * go tidy * reverse checkbox label display * wip: notifiers UI * use badges instead of text * improve documentation * add scaffold schema reference * remove notifier service * refactor schema folder * support group edges via scaffold * delete test file * include link to API docs * audit and update documentation + improve format * refactor schema edges * refactor * add custom validator * set validate + order fields by name * fix failing tests
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
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: "discord://" + faker.random.alphaNumeric(10),
|
|
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: "discord://" + faker.random.alphaNumeric(10),
|
|
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: null,
|
|
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);
|
|
}
|
|
});
|
|
});
|