Extract duplicate date formatting functions to shared utilities
- Created frontend/app/utils/date.ts with formatDate, formatTime, formatDateTime, formatDisplayDate - Created frontend/e2e/helpers/date.ts with formatDateLocal, getTomorrowDateStr - Updated all frontend pages and e2e tests to use shared utilities - Removed duplicate date formatting code from 6 files
This commit is contained in:
parent
eefdfd714f
commit
6ff3c0a133
9 changed files with 78 additions and 98 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { test, expect, Page } from "@playwright/test";
|
||||
import { formatDateLocal, getTomorrowDateStr } from "./helpers/date";
|
||||
|
||||
/**
|
||||
* Availability Page E2E Tests
|
||||
|
|
@ -45,20 +46,6 @@ function getTomorrowDisplay(): string {
|
|||
return tomorrow.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" });
|
||||
}
|
||||
|
||||
// Helper to get a date string in YYYY-MM-DD format using local timezone
|
||||
function formatDateLocal(d: Date): string {
|
||||
const year = d.getFullYear();
|
||||
const month = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
function getTomorrowDateStr(): string {
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
return formatDateLocal(tomorrow);
|
||||
}
|
||||
|
||||
test.describe("Availability Page - Admin Access", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await clearAuth(page);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue