Fix failing tests (#1009)

* chore: ignore all .data directories

* fix: date locale for unit tests

* test: disable parallelism to prevent database locks

* chore: fix lint errors

* chore: remove unused function

---------

Co-authored-by: zebrapurring <>
Co-authored-by: Tonya <tonya@tokia.dev>
This commit is contained in:
zebrapurring
2025-10-09 13:51:51 +02:00
committed by GitHub
parent 8a90b9c133
commit 116e39531b
5 changed files with 8 additions and 29 deletions

2
.gitignore vendored
View File

@@ -60,7 +60,7 @@ backend/app/api/static/public/*
backend/api
docs/.vitepress/cache/
/.data/
.data/
# Playwright
frontend/test-results/

View File

@@ -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 ||

View File

@@ -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);

View File

@@ -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] {

View File

@@ -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"
},