Fix all linter errors
- Remove unused biome suppression comment in completions.ts - Remove unnecessary if condition in execute-bootstrap.test.ts - Add eslint-disable comments for any type assertions in client.test.ts - Add eslint-disable comments for expect().rejects patterns - Fix template literal number expression with toString() - Fix error handling in test-db.ts to avoid object stringify Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,15 +15,19 @@ const describeE2E = describe.skipIf(SKIP_DB_TESTS);
|
||||
|
||||
describe("createDb", () => {
|
||||
test("throws error for empty connection string", () => {
|
||||
expect(() => createDb("")).toThrow("Database connection string is required");
|
||||
expect(() => createDb("")).toThrow(
|
||||
"Database connection string is required",
|
||||
);
|
||||
});
|
||||
|
||||
test("throws error for null-ish connection string", () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument -- testing edge case
|
||||
// biome-ignore lint/suspicious/noExplicitAny: testing edge case with invalid input
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
||||
expect(() => createDb(null as any)).toThrow(
|
||||
"Database connection string is required",
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument -- testing edge case
|
||||
// biome-ignore lint/suspicious/noExplicitAny: testing edge case with invalid input
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
||||
expect(() => createDb(undefined as any)).toThrow(
|
||||
"Database connection string is required",
|
||||
);
|
||||
|
||||
@@ -42,7 +42,7 @@ let testCounter = 0;
|
||||
const uniqueTestId = (): string => {
|
||||
const timestamp = Date.now();
|
||||
testCounter++;
|
||||
return `${timestamp}-${testCounter.toString()}`;
|
||||
return `${timestamp.toString()}-${testCounter.toString()}`;
|
||||
};
|
||||
|
||||
/** Truncate all tables */
|
||||
@@ -95,10 +95,8 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (db) {
|
||||
await truncateAllTables(db);
|
||||
await db.destroy();
|
||||
}
|
||||
await truncateAllTables(db);
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
test("creates superuser with correct email and password", async () => {
|
||||
@@ -263,6 +261,7 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
|
||||
test("throws error for password less than 8 characters", async () => {
|
||||
await withTestTransaction(db, async (trx) => {
|
||||
// eslint-disable-next-line @typescript-eslint/await-thenable, @typescript-eslint/no-confusing-void-expression
|
||||
await expect(
|
||||
executeBootstrap(trx, {
|
||||
email: "admin@example.com",
|
||||
@@ -274,6 +273,7 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
|
||||
test("throws error for password exactly 7 characters", async () => {
|
||||
await withTestTransaction(db, async (trx) => {
|
||||
// eslint-disable-next-line @typescript-eslint/await-thenable, @typescript-eslint/no-confusing-void-expression
|
||||
await expect(
|
||||
executeBootstrap(trx, {
|
||||
email: "admin@example.com",
|
||||
@@ -296,6 +296,7 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
|
||||
test("throws error for invalid email without @", async () => {
|
||||
await withTestTransaction(db, async (trx) => {
|
||||
// eslint-disable-next-line @typescript-eslint/await-thenable, @typescript-eslint/no-confusing-void-expression
|
||||
await expect(
|
||||
executeBootstrap(trx, {
|
||||
email: "invalidemail",
|
||||
@@ -326,6 +327,7 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
});
|
||||
|
||||
// Attempt to create the same user again
|
||||
// eslint-disable-next-line @typescript-eslint/await-thenable, @typescript-eslint/no-confusing-void-expression
|
||||
await expect(
|
||||
executeBootstrap(trx, {
|
||||
email: "admin@example.com",
|
||||
@@ -552,19 +554,19 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
});
|
||||
|
||||
// Create another org and invite
|
||||
const [otherOrg] = await trx
|
||||
const otherOrg = await trx
|
||||
.insertInto("orgs")
|
||||
.values({
|
||||
slug: `other-org-${uniqueId}`,
|
||||
display_name: "Other Org",
|
||||
})
|
||||
.returning(["id"])
|
||||
.execute();
|
||||
.executeTakeFirstOrThrow();
|
||||
|
||||
await trx
|
||||
.insertInto("org_invites")
|
||||
.values({
|
||||
org_id: otherOrg!.id,
|
||||
org_id: otherOrg.id,
|
||||
email: "invitee@example.com",
|
||||
role: "member",
|
||||
invited_by: result1.user.id,
|
||||
@@ -611,14 +613,14 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
.execute();
|
||||
|
||||
// Add org invites (to the org, not by the user)
|
||||
const [anotherUser] = await trx
|
||||
const anotherUser = await trx
|
||||
.insertInto("users")
|
||||
.values({
|
||||
email: `other-${uniqueId}@example.com`,
|
||||
display_name: "Other User",
|
||||
})
|
||||
.returning(["id"])
|
||||
.execute();
|
||||
.executeTakeFirstOrThrow();
|
||||
|
||||
await trx
|
||||
.insertInto("org_invites")
|
||||
@@ -626,7 +628,7 @@ describeE2E("[e2e] executeBootstrap", () => {
|
||||
org_id: result1.org.id,
|
||||
email: "invitee@example.com",
|
||||
role: "member",
|
||||
invited_by: anotherUser!.id,
|
||||
invited_by: anotherUser.id,
|
||||
token: "invite-token-2",
|
||||
expires_at: new Date(Date.now() + 86400000),
|
||||
})
|
||||
|
||||
@@ -30,5 +30,5 @@ export async function withTransaction<T>(
|
||||
}
|
||||
|
||||
// Not in a transaction, start one
|
||||
return (db as Kysely<Database>).transaction().execute(callback);
|
||||
return db.transaction().execute(callback);
|
||||
}
|
||||
|
||||
@@ -202,9 +202,11 @@ export async function runMigrations(): Promise<void> {
|
||||
await client.query(schemaSql);
|
||||
} catch (error) {
|
||||
// Ignore "already exists" errors - schema may have already been applied
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const message = error instanceof Error ? error.message : "Unknown error";
|
||||
if (!message.includes("already exists")) {
|
||||
throw new Error(`Schema application failed: ${message}`);
|
||||
throw error instanceof Error
|
||||
? error
|
||||
: new Error(`Schema application failed: ${message}`);
|
||||
}
|
||||
} finally {
|
||||
await client.end();
|
||||
|
||||
Reference in New Issue
Block a user