test: locale/timeZone should affect Intl.DateTimeFormat() (#27898)

https://github.com/microsoft/playwright/issues/27802
This commit is contained in:
Max Schmitt 2023-11-01 17:29:57 +01:00 committed by GitHub
parent f518684d89
commit d983941447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -174,3 +174,12 @@ it('should format number in workers', async ({ browser, server }) => {
expect(await worker.evaluate(() => (10000.20).toLocaleString())).toBe('10,000.2');
await context.close();
});
it('should affect Intl.DateTimeFormat().resolvedOptions().locale', async ({ browser, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27802' });
const context = await browser.newContext({ locale: 'en-GB' });
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
expect(await page.evaluate(() => (new Intl.DateTimeFormat()).resolvedOptions().locale)).toBe('en-GB');
await context.close();
});

View File

@ -94,3 +94,11 @@ it('should not change default timezone in another context', async ({ browser, se
await context.close();
}
});
it('should affect Intl.DateTimeFormat().resolvedOptions().timeZone', async ({ browser, server }) => {
const context = await browser.newContext({ timezoneId: 'America/Jamaica' });
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
expect(await page.evaluate(() => (new Intl.DateTimeFormat()).resolvedOptions().timeZone)).toBe('America/Jamaica');
await context.close();
});