Allow user to set timezone (#12775)

* Allow user to set timezone

* Update test snapshots

---------

Co-authored-by: Florian Duros <florianduros@element.io>
This commit is contained in:
Timshel 2024-09-02 11:07:07 +02:00 committed by GitHub
parent acc7342758
commit ae15bbe6e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 256 additions and 9 deletions

View file

@ -66,6 +66,7 @@ describe("<SendMessageComposer/>", () => {
lowBandwidth: false,
alwaysShowTimestamps: false,
showTwelveHourTimestamps: false,
userTimezone: undefined,
readMarkerInViewThresholdMs: 3000,
readMarkerOutOfViewThresholdMs: 30000,
showHiddenEvents: false,

View file

@ -55,6 +55,32 @@ describe("PreferencesUserSettingsTab", () => {
expect(reloadStub).toHaveBeenCalled();
});
it("should search and select a user timezone", async () => {
renderTab();
expect(await screen.findByText(/Browser default/)).toBeInTheDocument();
const timezoneDropdown = await screen.findByRole("button", { name: "Set timezone" });
await userEvent.click(timezoneDropdown);
// Without filtering `expect(screen.queryByRole("option" ...` take over 1s.
await fireEvent.change(screen.getByRole("combobox", { name: "Set timezone" }), {
target: { value: "Africa/Abidjan" },
});
expect(screen.queryByRole("option", { name: "Africa/Abidjan" })).toBeInTheDocument();
expect(screen.queryByRole("option", { name: "Europe/Paris" })).not.toBeInTheDocument();
await fireEvent.change(screen.getByRole("combobox", { name: "Set timezone" }), {
target: { value: "Europe/Paris" },
});
expect(screen.queryByRole("option", { name: "Africa/Abidjan" })).not.toBeInTheDocument();
const option = await screen.getByRole("option", { name: "Europe/Paris" });
await userEvent.click(option);
expect(await screen.findByText("Europe/Paris")).toBeInTheDocument();
});
it("should not show spell check setting if unsupported", async () => {
PlatformPeg.get()!.supportsSpellCheckSettings = jest.fn().mockReturnValue(false);

View file

@ -31,7 +31,7 @@ exports[`PreferencesUserSettingsTab should render 1`] = `
class="mx_SettingsSubsection_content"
>
<div
class="mx_SettingsSubsection_contentStretch"
class="mx_SettingsSubsection_dropdown"
>
Application language
<div
@ -224,6 +224,35 @@ exports[`PreferencesUserSettingsTab should render 1`] = `
<div
class="mx_SettingsSubsection_content"
>
<div
class="mx_SettingsSubsection_dropdown"
>
Set timezone
<div
class="mx_Dropdown mx_dropdownUserTimezone"
>
<div
aria-describedby="mx_dropdownUserTimezone_value"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="Set timezone"
aria-owns="mx_dropdownUserTimezone_input"
class="mx_AccessibleButton mx_Dropdown_input mx_no_textinput"
role="button"
tabindex="0"
>
<div
class="mx_Dropdown_option"
id="mx_dropdownUserTimezone_value"
>
Browser default (UTC)
</div>
<span
class="mx_Dropdown_arrow"
/>
</div>
</div>
</div>
<div
class="mx_SettingsFlag"
>