Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

Fix failing tests (#1009)

zebrapurring116e39531b3a
diff --git a/.gitignore b/.gitignore
index b769d9a2..15a2f234 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,7 +60,7 @@ backend/app/api/static/public/*
backend/api
docs/.vitepress/cache/
-/.data/
+.data/
# Playwright
frontend/test-results/
diff --git a/frontend/composables/utils.ts b/frontend/composables/utils.ts
index 5b030164..7d964155 100644
--- a/frontend/composables/utils.ts
+++ b/frontend/composables/utils.ts
@@ -44,7 +44,7 @@ function clampDecimals(currency: string, decimals: number): number {
}
// Type guard to validate currency response shape with strict validation
-function isValidCurrencyItem(item: CurrenciesCurrency) {
+function isValidCurrencyItem(item: CurrenciesCurrency): boolean {
if (
typeof item !== "object" ||
item === null ||
diff --git a/frontend/lib/datelib/datelib.test.ts b/frontend/lib/datelib/datelib.test.ts
index 34f96f9c..d80b2bdb 100644
--- a/frontend/lib/datelib/datelib.test.ts
+++ b/frontend/lib/datelib/datelib.test.ts
@@ -1,20 +1,9 @@
import { describe, expect, test } from "vitest";
-import { factorRange, format, parse, zeroTime } from "./datelib";
-
-describe("format", () => {
- test("should format a date as a string", () => {
- const date = new Date(2020, 1, 1);
- expect(format(date)).toBe("2020-02-01");
- });
-
- test("should return the string if a string is passed in", () => {
- expect(format("2020-02-01")).toBe("2020-02-01");
- });
-});
+import { factorRange, parse, zeroTime } from "./datelib";
describe("zeroTime", () => {
test("should zero out the time", () => {
- const date = new Date(2020, 1, 1, 12, 30, 30);
+ const date = new Date(Date.UTC(2020, 1, 1, 12, 30, 30));
const zeroed = zeroTime(date);
expect(zeroed.getHours()).toBe(0);
expect(zeroed.getMinutes()).toBe(0);
diff --git a/frontend/lib/datelib/datelib.ts b/frontend/lib/datelib/datelib.ts
index 33f7674d..fc7b7b27 100644
--- a/frontend/lib/datelib/datelib.ts
+++ b/frontend/lib/datelib/datelib.ts
@@ -1,19 +1,9 @@
import { addDays } from "date-fns";
-/*
- * Formats a date as a string
- * */
-export function format(date: Date | string): string {
- if (typeof date === "string") {
- return date;
- }
- return date.toISOString().split("T")[0]!;
-}
-
export function zeroTime(date: Date): Date {
- return new Date(
- new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - date.getTimezoneOffset() * 60000
- );
+ const result = new Date(date.getTime());
+ result.setHours(0, 0, 0, 0);
+ return result;
}
export function factorRange(offset: number = 7): [Date, Date] {
diff --git a/frontend/package.json b/frontend/package.json
index be9d7b31..7c56e91f 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -9,7 +9,7 @@
"lint:fix": "eslint --ext \".ts,.js,.vue\" --ignore-pattern \"components/ui\" . --fix",
"lint:ci": "eslint --ext \".ts,.js,.vue\" --ignore-pattern \"components/ui\" . --max-warnings 1",
"typecheck": "pnpm nuxi typecheck --noEmit",
- "test:ci": "TEST_SHUTDOWN_API_SERVER=true vitest --run --config ./test/vitest.config.ts",
+ "test:ci": "TEST_SHUTDOWN_API_SERVER=true vitest --run --config ./test/vitest.config.ts --no-file-parallelism",
"test:local": "TEST_SHUTDOWN_API_SERVER=false && vitest --run --config ./test/vitest.config.ts",
"test:watch": " TEST_SHUTDOWN_API_SERVER=false vitest --config ./test/vitest.config.ts"
},