From 35a020ccec6bfe18643ffd9cb132829f291e86a7 Mon Sep 17 00:00:00 2001 From: Bartek Igielski Date: Sat, 21 Nov 2026 17:53:26 +0100 Subject: [PATCH] test: use recorded RDAP data in domain expiry test The test looked up google.wiki over the network and expected a fixed expiry date. The domain was renewed, so CI on main has failed since 2026-11-19. Serve recorded IANA and RDAP answers instead so the test runs offline. --- test/backend-test/domain.test.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/test/backend-test/domain.test.ts b/test/backend-test/domain.test.ts index 09d65268..48d10f4c 100644 --- a/test/backend-test/domain.test.ts +++ b/test/backend-test/domain.test.ts @@ -6,6 +6,7 @@ import TestDB from "../mock-testdb"; import { Settings } from "@/server/settings"; import dayjs from "dayjs"; import dayjsPlugin_10 from "dayjs/plugin/utc"; +import rdapDnsFixture from "@/server/assets/rdap-dns.json" with { type: "json" }; process.env.IGLO_MONITOR_HIDE_LOG = ["info_db", "info_server"].join(","); @@ -49,8 +50,33 @@ describe("Domain Expiry", () => { }); test("getExpiryDate() returns correct expiry date for .wiki domain with no A record", async () => { - const d = DomainExpiry.createByName("google.wiki", testDb.store); - expect(await d.getExpiryDate(settings)).toEqual(new Date("2026-11-26T23:59:59.000Z")); + // Recorded RDAP answers instead of live lookups: the real registration changes when the + // domain is renewed, which made this test fail once google.wiki was renewed in 2026. + const realFetch = globalThis.fetch; + const fetchSpy = spyOn(globalThis, "fetch").mockImplementation(async (input, init) => { + const url = String(input instanceof Request ? input.url : input); + if (url.startsWith("https://data.iana.org/rdap/dns.json")) { + return Response.json(rdapDnsFixture); + } + if (url.endsWith("/domain/google.wiki")) { + return Response.json({ + objectClassName: "domain", + ldhName: "google.wiki", + events: [ + { eventAction: "registration", eventDate: "2015-05-26T15:29:31Z" }, + { eventAction: "expiration", eventDate: "2027-11-26T23:59:59Z" }, + ], + }); + } + return realFetch(input, init); + }); + try { + const d = DomainExpiry.createByName("google.wiki", testDb.store); + expect(await d.getExpiryDate(settings)).toEqual(new Date("2027-11-26T23:59:59.000Z")); + expect(fetchSpy.mock.calls.some(([input]) => String(input).endsWith("/domain/google.wiki"))).toBe(true); + } finally { + fetchSpy.mockRestore(); + } }); describe("checkSupport()", () => {