fix(custom-widgets): restore bundled authoring
This commit is contained in:
16 files changed
+180
-58
No files matched your search
@@ -3,11 +3,13 @@ import { MySqlContainer } from "@testcontainers/mysql";
|
||||
import { drizzle } from "drizzle-orm/mysql2";
|
||||
import { migrate } from "drizzle-orm/mysql2/migrator";
|
||||
import mysql from "mysql2";
|
||||
import { describe, test } from "vitest";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { DB_CASING } from "@homarr/core/infrastructure/db/constants";
|
||||
|
||||
import * as mysqlSchema from "../schema/mysql";
|
||||
import type { Database } from "..";
|
||||
import { seedDataAsync } from "../migrations/seed";
|
||||
|
||||
describe("Mysql Migration", () => {
|
||||
test("should add all tables and keys specified in migration files", async () => {
|
||||
@@ -31,9 +33,15 @@ describe("Mysql Migration", () => {
|
||||
await migrate(database, {
|
||||
migrationsFolder: path.join(__dirname, "..", "migrations", "mysql"),
|
||||
});
|
||||
await seedDataAsync(database as unknown as Database);
|
||||
|
||||
// Check if users table exists
|
||||
await database.query.users.findMany();
|
||||
const bundledWidgets = await database.query.customWidgetDefinitions.findMany({
|
||||
where: (table, { like }) => like(table.id, "seed-%"),
|
||||
});
|
||||
expect(bundledWidgets).toHaveLength(4);
|
||||
expect(bundledWidgets.every(({ enabled }) => !enabled)).toBe(true);
|
||||
|
||||
connection.end();
|
||||
await mysqlContainer.stop();
|
||||
|
||||
@@ -3,11 +3,13 @@ import { PostgreSqlContainer } from "@testcontainers/postgresql";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
import { Pool } from "pg";
|
||||
import { describe, test } from "vitest";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { DB_CASING } from "@homarr/core/infrastructure/db/constants";
|
||||
|
||||
import * as pgSchema from "../schema/postgresql";
|
||||
import type { Database } from "..";
|
||||
import { seedDataAsync } from "../migrations/seed";
|
||||
|
||||
describe("PostgreSql Migration", () => {
|
||||
test("should add all tables and keys specified in migration files", async () => {
|
||||
@@ -36,9 +38,15 @@ describe("PostgreSql Migration", () => {
|
||||
await migrate(database, {
|
||||
migrationsFolder: path.join(__dirname, "..", "migrations", "postgresql"),
|
||||
});
|
||||
await seedDataAsync(database as unknown as Database);
|
||||
|
||||
// Check if users table exists
|
||||
await database.query.users.findMany();
|
||||
const bundledWidgets = await database.query.customWidgetDefinitions.findMany({
|
||||
where: (table, { like }) => like(table.id, "seed-%"),
|
||||
});
|
||||
expect(bundledWidgets).toHaveLength(4);
|
||||
expect(bundledWidgets.every(({ enabled }) => !enabled)).toBe(true);
|
||||
|
||||
// Close the pool to release resources
|
||||
await pool.end();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import path from "path";
|
||||
import BetterSqlite3 from "better-sqlite3";
|
||||
import { drizzle } from "drizzle-orm/better-sqlite3";
|
||||
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import { DB_CASING } from "@homarr/core/infrastructure/db/constants";
|
||||
|
||||
import type { Database } from "..";
|
||||
import { seedDataAsync } from "../migrations/seed";
|
||||
import * as sqliteSchema from "../schema/sqlite";
|
||||
|
||||
test("SQLite migrations seed the four disabled bundled custom widgets", async () => {
|
||||
const connection = new BetterSqlite3(":memory:");
|
||||
const database = drizzle(connection, { schema: sqliteSchema, casing: DB_CASING });
|
||||
|
||||
migrate(database, { migrationsFolder: path.join(__dirname, "..", "migrations", "sqlite") });
|
||||
await seedDataAsync(database as unknown as Database);
|
||||
|
||||
const bundledWidgets = await database.query.customWidgetDefinitions.findMany({
|
||||
where: (table, { like }) => like(table.id, "seed-%"),
|
||||
});
|
||||
expect(bundledWidgets).toHaveLength(4);
|
||||
expect(bundledWidgets.every(({ enabled }) => !enabled)).toBe(true);
|
||||
|
||||
connection.close();
|
||||
});
|
||||
Reference in new issue
Block a user