mirror of
https://github.com/home-assistant/frontend.git
synced 2026-08-17 10:32:44 +01:00
* Add UTC time zone to the time zone picker The time zone list is built from google-timezones-json, which is missing the bare "UTC" and "Etc/UTC" zones. Both are valid IANA identifiers and a common server default, so an instance configured to UTC showed up as an unknown time zone in the settings. Add the two zones to the picker options, guarded against duplicates in case the source list starts including them. * Accept UTC time zone in the clock card config The clock card validated its time_zone against the raw timezone list, so it rejected UTC even though the picker now offers it. Validate against the shared timezone options instead, keeping a single source. * Correct the invalid Asia/Sakhalin time zone id google-timezones-json ships Asia/Yuzhno-Sakhalinsk, which is not a valid IANA identifier, so selecting it failed backend validation. Map it to the correct Asia/Sakhalin id.
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { getTimezoneOptions } from "../../src/components/ha-timezone-picker";
|
|
|
|
describe("getTimezoneOptions", () => {
|
|
const options = getTimezoneOptions();
|
|
|
|
it("includes the bare UTC zone so a UTC config is recognized", () => {
|
|
const utc = options.find((option) => option.id === "UTC");
|
|
expect(utc).toBeDefined();
|
|
expect(utc?.primary).toContain("UTC");
|
|
});
|
|
|
|
it("includes the Etc/UTC zone", () => {
|
|
expect(options.some((option) => option.id === "Etc/UTC")).toBe(true);
|
|
});
|
|
|
|
it("does not duplicate any zone id", () => {
|
|
const ids = options.map((option) => option.id);
|
|
expect(new Set(ids).size).toBe(ids.length);
|
|
});
|
|
|
|
it("keeps the zones from the source list", () => {
|
|
// A sanity check that the base list is still present alongside the additions.
|
|
expect(options.some((option) => option.id === "Europe/Amsterdam")).toBe(
|
|
true
|
|
);
|
|
expect(options.length).toBeGreaterThan(100);
|
|
});
|
|
|
|
it("corrects the invalid Asia/Yuzhno-Sakhalinsk id to Asia/Sakhalin", () => {
|
|
expect(
|
|
options.some((option) => option.id === "Asia/Yuzhno-Sakhalinsk")
|
|
).toBe(false);
|
|
const sakhalin = options.find((option) => option.id === "Asia/Sakhalin");
|
|
expect(sakhalin).toBeDefined();
|
|
expect(sakhalin?.secondary).toBe("Asia/Sakhalin");
|
|
});
|
|
});
|