Merge pull request #20338 from calixteman/test_date_tz

Add a test for PR #20320
This commit is contained in:
Tim van der Meij 2025-10-05 20:24:02 +02:00 committed by GitHub
commit f4104326f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 51 additions and 1 deletions

View File

@ -2585,6 +2585,56 @@ describe("Interaction", () => {
}); });
}); });
describe("Date HTML element in different timezone", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait(
"dates.pdf",
getAnnotationSelector("26R"),
null,
null,
async page => {
// Make sure that 00:00 UTC is the day before in the local timezone.
await page.emulateTimezone("Pacific/Niue");
}
);
});
afterEach(async () => {
await closePages(pages);
});
it("must check that the inputs are correct", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await waitForScripting(page);
await waitForSandboxTrip(page);
const firstInputSelector = `${getAnnotationSelector("26R")} > input`;
await page.waitForSelector(`${firstInputSelector}[type="text"]`);
await page.click(firstInputSelector);
await waitForSandboxTrip(page);
await page.waitForSelector(`${firstInputSelector}[type="date"]`);
await page.$eval(firstInputSelector, el => {
el.value = "2025-10-05";
});
const secondInputSelector = `${getAnnotationSelector("27R")} > input`;
await page.waitForSelector(`${secondInputSelector}[type="text"]`);
await page.click(secondInputSelector);
await waitForSandboxTrip(page);
const firstInputValue = await page.$eval(
firstInputSelector,
el => el.value
);
expect(firstInputValue)
.withContext(`In ${browserName}`)
.toEqual("05-Oct-25");
})
);
});
});
describe("Date HTML element with initial values", () => { describe("Date HTML element with initial values", () => {
let pages; let pages;

View File

@ -49,7 +49,7 @@ function loadAndWait(filename, selector, zoom, setups, options, viewport) {
: options; : options;
// Options must be handled in app.js::_parseHashParams. // Options must be handled in app.js::_parseHashParams.
for (const [key, value] of Object.entries(optionsObject)) { for (const [key, value] of Object.entries(optionsObject || {})) {
app_options += `&${key}=${encodeURIComponent(value)}`; app_options += `&${key}=${encodeURIComponent(value)}`;
} }
} }