Default bundled emoji font to on (#11935)

* Update Settings.tsx

* Update tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update snapshot

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update assertion

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2023-11-27 09:59:09 +00:00 committed by GitHub
parent 76b7aa2d33
commit 6f50405e34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 15 deletions

View file

@ -219,6 +219,7 @@ describe("Appearance user settings tab", () => {
cy.findByRole("button", { name: "Show advanced" }).click(); cy.findByRole("button", { name: "Show advanced" }).click();
// force click as checkbox size is zero // force click as checkbox size is zero
cy.findByLabelText("Use bundled emoji font").click({ force: true });
cy.findByLabelText("Use a system font").click({ force: true }); cy.findByLabelText("Use a system font").click({ force: true });
// Assert that the font-family value was removed // Assert that the font-family value was removed

View file

@ -713,7 +713,7 @@ export const SETTINGS: { [setting: string]: ISetting } = {
}, },
"useBundledEmojiFont": { "useBundledEmojiFont": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false, default: true,
displayName: _td("settings|appearance|bundled_emoji_font"), displayName: _td("settings|appearance|bundled_emoji_font"),
controller: new SystemFontController(), controller: new SystemFontController(),
}, },

View file

@ -16,7 +16,9 @@ exports[`<MatrixChat /> Multi-tab lockout shows the lockout page when a second t
`; `;
exports[`<MatrixChat /> Multi-tab lockout shows the lockout page when a second tab opens during crypto init 1`] = ` exports[`<MatrixChat /> Multi-tab lockout shows the lockout page when a second tab opens during crypto init 1`] = `
<body> <body
style="--emoji-font-family: Twemoji;"
>
<div> <div>
<main <main
class="mx_SessionLockStolenView mx_SplashPage" class="mx_SessionLockStolenView mx_SplashPage"

View file

@ -48,9 +48,9 @@ describe("FontWatcher", function () {
it("should load font on start()", async () => { it("should load font on start()", async () => {
const watcher = new FontWatcher(); const watcher = new FontWatcher();
await setSystemFont("Font Name"); await setSystemFont("Font Name");
expect(getFontFamily()).toBe(""); expect(getFontFamily()).toMatchInlineSnapshot(`""`);
await watcher.start(); await watcher.start();
expect(getFontFamily()).toBe('"Font Name"'); expect(getFontFamily()).toMatchInlineSnapshot(`""Font Name", Twemoji"`);
}); });
it("should load font on Action.OnLoggedIn", async () => { it("should load font on Action.OnLoggedIn", async () => {
@ -58,16 +58,16 @@ describe("FontWatcher", function () {
await new FontWatcher().start(); await new FontWatcher().start();
document.body.style.removeProperty(FontWatcher.FONT_FAMILY_CUSTOM_PROPERTY); // clear the fontFamily which was by start which we tested already document.body.style.removeProperty(FontWatcher.FONT_FAMILY_CUSTOM_PROPERTY); // clear the fontFamily which was by start which we tested already
defaultDispatcher.fire(Action.OnLoggedIn, true); defaultDispatcher.fire(Action.OnLoggedIn, true);
expect(getFontFamily()).toBe('"Font Name"'); expect(getFontFamily()).toMatchInlineSnapshot(`""Font Name", Twemoji"`);
}); });
it("should reset font on Action.OnLoggedOut", async () => { it("should reset font on Action.OnLoggedOut", async () => {
await setSystemFont("Font Name"); await setSystemFont("Font Name");
const watcher = new FontWatcher(); const watcher = new FontWatcher();
await watcher.start(); await watcher.start();
expect(getFontFamily()).toBe('"Font Name"'); expect(getFontFamily()).toMatchInlineSnapshot(`""Font Name", Twemoji"`);
defaultDispatcher.fire(Action.OnLoggedOut, true); defaultDispatcher.fire(Action.OnLoggedOut, true);
expect(getFontFamily()).toBe(""); expect(getFontFamily()).toMatchInlineSnapshot(`""`);
}); });
describe("Sets font as expected", () => { describe("Sets font as expected", () => {
@ -82,15 +82,15 @@ describe("FontWatcher", function () {
it("encloses the fonts by double quotes and sets them as the system font", async () => { it("encloses the fonts by double quotes and sets them as the system font", async () => {
await setSystemFont("Fira Sans Thin, Commodore 64"); await setSystemFont("Fira Sans Thin, Commodore 64");
expect(getFontFamily()).toBe(`"Fira Sans Thin","Commodore 64"`); expect(getFontFamily()).toMatchInlineSnapshot(`""Fira Sans Thin","Commodore 64", Twemoji"`);
}); });
it("does not add double quotes if already present and sets the font as the system font", async () => { it("does not add double quotes if already present and sets the font as the system font", async () => {
await setSystemFont(`"Commodore 64"`); await setSystemFont(`"Commodore 64"`);
expect(getFontFamily()).toBe(`"Commodore 64"`); expect(getFontFamily()).toMatchInlineSnapshot(`""Commodore 64", Twemoji"`);
}); });
it("trims whitespace, encloses the fonts by double quotes, and sets them as the system font", async () => { it("trims whitespace, encloses the fonts by double quotes, and sets them as the system font", async () => {
await setSystemFont(` Fira Code , "Commodore 64" `); await setSystemFont(` Fira Code , "Commodore 64" `);
expect(getFontFamily()).toBe(`"Fira Code","Commodore 64"`); expect(getFontFamily()).toMatchInlineSnapshot(`""Fira Code","Commodore 64", Twemoji"`);
}); });
}); });
@ -105,13 +105,13 @@ describe("FontWatcher", function () {
fontWatcher.stop(); fontWatcher.stop();
}); });
it("by default does not add Twemoji font", async () => { it("by default adds Twemoji font", async () => {
expect(getEmojiFontFamily()).toMatchInlineSnapshot(`""`);
});
it("adds Twemoji font when enabled", async () => {
await setUseBundledEmojiFont(true);
expect(getEmojiFontFamily()).toMatchInlineSnapshot(`"Twemoji"`); expect(getEmojiFontFamily()).toMatchInlineSnapshot(`"Twemoji"`);
}); });
it("does not add Twemoji font when disabled", async () => {
await setUseBundledEmojiFont(false);
expect(getEmojiFontFamily()).toMatchInlineSnapshot(`""`);
});
it("works in conjunction with useSystemFont", async () => { it("works in conjunction with useSystemFont", async () => {
await setSystemFont(`"Commodore 64"`); await setSystemFont(`"Commodore 64"`);
await setUseBundledEmojiFont(true); await setUseBundledEmojiFont(true);