forked from mirrors/homebox
chore: rewrite generator to resolve strange name generation (#612)
* rewrite generator to resolve strange name generation * fix asset id types * ignore errored types * remove depreciated calls * use more random words * random user Former-commit-id: 4738a9b131e75479b30bda3b9967329268f69685
This commit is contained in:
parent
f74736b369
commit
742ece7923
18 changed files with 139 additions and 1183 deletions
|
@ -15,7 +15,7 @@ function itemField(id = null): ItemField {
|
|||
type: "text",
|
||||
textValue: faker.lorem.sentence(),
|
||||
booleanValue: false,
|
||||
numberValue: faker.datatype.number(),
|
||||
numberValue: faker.number.int(),
|
||||
timeValue: "",
|
||||
};
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ function user(): UserRegistration {
|
|||
return {
|
||||
email: faker.internet.email(),
|
||||
password: faker.internet.password(),
|
||||
name: faker.name.firstName(),
|
||||
name: faker.person.firstName(),
|
||||
token: "",
|
||||
};
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ function user(): UserRegistration {
|
|||
function location(parentId: string | null = null): LocationCreate {
|
||||
return {
|
||||
parentId,
|
||||
name: faker.address.city(),
|
||||
name: faker.location.city(),
|
||||
description: faker.lorem.sentence(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { beforeAll, expect } from "vitest";
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { UserClient } from "../user";
|
||||
import { factories } from "./factories";
|
||||
|
||||
|
@ -15,9 +16,9 @@ export async function sharedUserClient(): Promise<UserClient> {
|
|||
return factories.client.user(cache.token);
|
||||
}
|
||||
const testUser = {
|
||||
email: "__test__@__test__.com",
|
||||
name: "__test__",
|
||||
password: "__test__",
|
||||
email: faker.internet.email(),
|
||||
name: faker.person.fullName(),
|
||||
password: faker.internet.password(),
|
||||
token: "",
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe("first time user workflow (register, login, join group)", () => {
|
|||
test("user should be able to update group", async () => {
|
||||
const { client } = await factories.client.singleUse();
|
||||
|
||||
const name = faker.name.firstName();
|
||||
const name = faker.person.firstName();
|
||||
|
||||
const { response, data: group } = await client.group.update({
|
||||
name,
|
||||
|
@ -34,7 +34,7 @@ describe("first time user workflow (register, login, join group)", () => {
|
|||
|
||||
for (const currency of currencies) {
|
||||
const { response, data: group } = await client.group.update({
|
||||
name: faker.name.firstName(),
|
||||
name: faker.person.firstName(),
|
||||
currency: currency.code,
|
||||
});
|
||||
|
||||
|
|
|
@ -135,9 +135,9 @@ describe("user should be able to create an item and add an attachment", () => {
|
|||
const { response, data } = await api.items.maintenance.create(item.id, {
|
||||
name: faker.vehicle.model(),
|
||||
description: faker.lorem.paragraph(1),
|
||||
completedDate: faker.date.past(1),
|
||||
completedDate: faker.date.past(),
|
||||
scheduledDate: "null",
|
||||
cost: faker.datatype.number(100).toString(),
|
||||
cost: faker.number.int(100).toString(),
|
||||
});
|
||||
|
||||
expect(response.status).toBe(201);
|
||||
|
|
|
@ -8,8 +8,8 @@ describe("basic notifier workflows", () => {
|
|||
|
||||
// Create Notifier
|
||||
const result = await client.notifiers.create({
|
||||
name: faker.name.firstName(),
|
||||
url: "discord://" + faker.random.alphaNumeric(10),
|
||||
name: faker.word.words(2),
|
||||
url: "discord://" + faker.string.alphanumeric(10),
|
||||
isActive: true,
|
||||
});
|
||||
|
||||
|
@ -22,8 +22,8 @@ describe("basic notifier workflows", () => {
|
|||
// Update Notifier with new URL
|
||||
{
|
||||
const updateData = {
|
||||
name: faker.name.firstName(),
|
||||
url: "discord://" + faker.random.alphaNumeric(10),
|
||||
name: faker.word.words(2),
|
||||
url: "discord://" + faker.string.alphanumeric(10),
|
||||
isActive: true,
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe("basic notifier workflows", () => {
|
|||
// Update Notifier with empty URL
|
||||
{
|
||||
const updateData = {
|
||||
name: faker.name.firstName(),
|
||||
name: faker.word.words(2),
|
||||
url: null,
|
||||
isActive: true,
|
||||
};
|
||||
|
|
|
@ -40,8 +40,8 @@ function importFileGenerator(entries: number): ImportObj[] {
|
|||
|
||||
const pick = (arr: string[]) => arr[Math.floor(Math.random() * arr.length)];
|
||||
|
||||
const labels = faker.random.words(5).split(" ").join(";");
|
||||
const locations = faker.random.words(3).split(" ");
|
||||
const labels = faker.word.words(5).split(" ").join(";");
|
||||
const locations = faker.word.words(3).split(" ");
|
||||
|
||||
const half = Math.floor(entries / 2);
|
||||
|
||||
|
@ -53,21 +53,21 @@ function importFileGenerator(entries: number): ImportObj[] {
|
|||
[`HB.import_ref`]: faker.database.mongodbObjectId(),
|
||||
[`HB.location`]: pick(locations),
|
||||
[`HB.labels`]: labels,
|
||||
[`HB.quantity`]: Number(faker.random.numeric(2)),
|
||||
[`HB.name`]: faker.random.words(3),
|
||||
[`HB.quantity`]: Number(faker.number.int(2)),
|
||||
[`HB.name`]: faker.word.words(3),
|
||||
[`HB.description`]: "",
|
||||
[`HB.insured`]: faker.datatype.boolean(),
|
||||
[`HB.serial_number`]: faker.random.alphaNumeric(5),
|
||||
[`HB.model_number`]: faker.random.alphaNumeric(5),
|
||||
[`HB.manufacturer`]: faker.random.alphaNumeric(5),
|
||||
[`HB.serial_number`]: faker.string.alphanumeric(5),
|
||||
[`HB.model_number`]: faker.string.alphanumeric(5),
|
||||
[`HB.manufacturer`]: faker.string.alphanumeric(5),
|
||||
[`HB.notes`]: "",
|
||||
[`HB.purchase_from`]: faker.name.fullName(),
|
||||
[`HB.purchase_price`]: faker.datatype.number(100),
|
||||
[`HB.purchase_from`]: faker.person.fullName(),
|
||||
[`HB.purchase_price`]: faker.number.int(100),
|
||||
[`HB.purchase_time`]: faker.date.past().toDateString(),
|
||||
[`HB.lifetime_warranty`]: half > i,
|
||||
[`HB.warranty_details`]: "",
|
||||
[`HB.sold_to`]: faker.name.fullName(),
|
||||
[`HB.sold_price`]: faker.datatype.number(100),
|
||||
[`HB.sold_to`]: faker.person.fullName(),
|
||||
[`HB.sold_price`]: faker.number.int(100),
|
||||
[`HB.sold_time`]: formatDate(faker.date.past()),
|
||||
[`HB.sold_notes`]: "",
|
||||
});
|
||||
|
|
|
@ -141,6 +141,7 @@ export interface ItemSummary {
|
|||
|
||||
export interface ItemUpdate {
|
||||
archived: boolean;
|
||||
/** @example "0" */
|
||||
assetId: string;
|
||||
description: string;
|
||||
fields: ItemField[];
|
||||
|
@ -172,7 +173,6 @@ export interface ItemUpdate {
|
|||
soldTime: Date | string;
|
||||
soldTo: string;
|
||||
warrantyDetails: string;
|
||||
/** Sold */
|
||||
warrantyExpires: Date | string;
|
||||
}
|
||||
|
||||
|
@ -244,36 +244,30 @@ export interface LocationUpdate {
|
|||
}
|
||||
|
||||
export interface MaintenanceEntry {
|
||||
/** Sold */
|
||||
completedDate: Date | string;
|
||||
/** @example "0" */
|
||||
cost: string;
|
||||
description: string;
|
||||
id: string;
|
||||
name: string;
|
||||
/** Sold */
|
||||
scheduledDate: Date | string;
|
||||
}
|
||||
|
||||
export interface MaintenanceEntryCreate {
|
||||
/** Sold */
|
||||
completedDate: Date | string;
|
||||
/** @example "0" */
|
||||
cost: string;
|
||||
description: string;
|
||||
name: string;
|
||||
/** Sold */
|
||||
scheduledDate: Date | string;
|
||||
}
|
||||
|
||||
export interface MaintenanceEntryUpdate {
|
||||
/** Sold */
|
||||
completedDate: Date | string;
|
||||
/** @example "0" */
|
||||
cost: string;
|
||||
description: string;
|
||||
name: string;
|
||||
/** Sold */
|
||||
scheduledDate: Date | string;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue