Skip to content

Commit 8ad25b5

Browse files
author
QuantCode Agent
committed
fix: repair cross-package bugs causing test and type failures
- bunfig.toml: preload happy-dom setup so DOM globals exist when tests run from repo root (fixes 'document is not defined' in ui tests) - apps/web/api.ts: update import to renamed useDebounce hook (was useThrottle), keep useSearchDebounce alias - utils/date.ts: use dateStyle 'short' for en-AU day-first formatting - ui/Button: pass aria-label through to button element for icon-only - ui/DataTable: use functional setState updater to fix stale-closure sort - tsconfig: declare bun-types so bun:test resolves under tsc --noEmit
1 parent 7e2198e commit 8ad25b5

6 files changed

Lines changed: 8 additions & 11 deletions

File tree

apps/web/src/lib/api.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
* Fix: change the import to `useDebounce`.
88
*/
99

10-
// BUG: useThrottle no longer exists — was renamed to useDebounce
11-
import { useThrottle } from "@e2e/utils"
10+
import { useDebounce } from "@e2e/utils"
1211
import { formatDate, formatAUD } from "@e2e/utils"
1312

1413
export const BASE_URL = process.env.API_URL ?? "http://localhost:3000"
@@ -28,5 +27,4 @@ export async function fetchPosts() {
2827
// Re-export formatting utilities used throughout the app
2928
export { formatDate, formatAUD }
3029

31-
// Re-export the debounce hook (currently broken import)
32-
export { useThrottle as useSearchDebounce }
30+
export { useDebounce as useSearchDebounce }

bunfig.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[test]
2-
environment = "happy-dom"
2+
environment = "happy-dom"
3+
preload = ["./packages/ui/test/setup.ts"]

packages/ui/src/components/Button/Button.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ export function Button({
3939
className={`btn btn-${variant}`}
4040
disabled={disabled}
4141
onClick={onClick}
42-
// BUG: aria-label is not applied when iconOnly is true and no ariaLabel is passed
43-
// The component should enforce aria-label for icon-only buttons
42+
aria-label={iconOnly ? (ariaLabel ?? "") : ariaLabel}
4443
>
4544
{icon && <span className="btn-icon">{icon}</span>}
4645
{!iconOnly && children}

packages/ui/src/components/DataTable/DataTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function DataTable<T extends Record<string, unknown>>({ data, columns }:
3131
// BUG: stale closure — sortDir is captured at handler creation time
3232
const handleSort = (key: keyof T) => {
3333
if (sortKey === key) {
34-
setSortDir(sortDir === "asc" ? "desc" : "asc") // BUG: reads stale sortDir
34+
setSortDir(prev => prev === "asc" ? "desc" : "asc")
3535
} else {
3636
setSortKey(key)
3737
setSortDir("asc")

packages/utils/src/format/date.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
export function formatDate(date: Date): string {
1313
// BUG: explicit field order overrides locale ordering — produces M/D/YYYY not D/M/YYYY
1414
return new Intl.DateTimeFormat("en-AU", {
15-
month: "numeric",
16-
day: "numeric",
17-
year: "numeric",
15+
dateStyle: "short",
1816
}).format(date)
1917
}
2018

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"jsx": "react-jsx",
77
"strict": true,
88
"skipLibCheck": true,
9+
"types": ["bun-types"],
910
"paths": {
1011
"@e2e/ui": ["./packages/ui/src/index.ts"],
1112
"@e2e/utils": ["./packages/utils/src/index.ts"]

0 commit comments

Comments
 (0)