mirror of
https://github.com/heyman/heynote.git
synced 2026-02-06 11:27:25 +00:00
Fix tests in CI
This commit is contained in:
parent
b62a8a3886
commit
044319a7fc
@ -1,4 +1,4 @@
|
||||
export function formatDate(date) {
|
||||
export function formatDate(date, locale) {
|
||||
const now = new Date();
|
||||
|
||||
// normalize to local midnight for date-only comparison
|
||||
@ -8,7 +8,7 @@ export function formatDate(date) {
|
||||
|
||||
// Today: show just time
|
||||
if (diffDays === 0) {
|
||||
return date.toLocaleTimeString(undefined, {
|
||||
return date.toLocaleTimeString(locale, {
|
||||
hour: "numeric",
|
||||
minute: "2-digit"
|
||||
});
|
||||
@ -16,7 +16,7 @@ export function formatDate(date) {
|
||||
|
||||
// Yesterday: show "Yesterday, <time>"
|
||||
if (diffDays === 1) {
|
||||
const time = date.toLocaleTimeString(undefined, {
|
||||
const time = date.toLocaleTimeString(locale, {
|
||||
hour: "numeric",
|
||||
minute: "2-digit"
|
||||
});
|
||||
@ -26,7 +26,7 @@ export function formatDate(date) {
|
||||
// Otherwise: full date + time, omit year if same
|
||||
const sameYear = date.getFullYear() === now.getFullYear();
|
||||
|
||||
return date.toLocaleString(undefined, {
|
||||
return date.toLocaleString(locale, {
|
||||
year: sameYear ? undefined : "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
@ -35,8 +35,8 @@ export function formatDate(date) {
|
||||
});
|
||||
}
|
||||
|
||||
export function formatFullDate(date) {
|
||||
return date.toLocaleString(undefined, {
|
||||
export function formatFullDate(date, locale) {
|
||||
return date.toLocaleString(locale, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
|
||||
@ -662,6 +662,6 @@ Another paragraph here`)
|
||||
// Verify block is folded by checking for fold placeholder
|
||||
await expect(page.locator(".cm-foldPlaceholder")).toBeVisible()
|
||||
|
||||
await expect(page.locator(".cm-foldPlaceholder .created-time")).toHaveText(formatDate(date))
|
||||
await expect(page.locator(".cm-foldPlaceholder .created-time")).toHaveText(formatDate(date, "en-GB"))
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user