New layout selector ui in user settings (#12676)

* feat: reworked the layout switcher

* feat: make the classname optional in EventTilePreview.tsx

* test: add tests to LayoutSwitcher

* feat: change appearance tab

* test: update appearance snapshot

* e2e: add tests

* css: add comment for gap overriding
This commit is contained in:
Florian Duros
2024-07-05 09:30:31 +02:00
committed by GitHub
parent 6f5d21fedb
commit 2f953f1d0f
14 changed files with 1289 additions and 429 deletions
@@ -14,11 +14,12 @@
* limitations under the License.
*/
import { Page } from "@playwright/test";
import { Locator, Page } from "@playwright/test";
import { ElementAppPage } from "../../../pages/ElementAppPage";
import { test as base, expect } from "../../../element-web-test";
import { SettingLevel } from "../../../../src/settings/SettingLevel";
import { Layout } from "../../../../src/settings/enums/Layout";
export { expect };
@@ -57,6 +58,21 @@ class Helpers {
return this.app.settings.openUserSettings("Appearance");
}
/**
* Compare screenshot and hide the matrix chat
* @param locator
* @param screenshot
*/
assertScreenshot(locator: Locator, screenshot: `${string}.png`) {
return expect(locator).toMatchScreenshot(screenshot, {
css: `
#matrixchat {
display: none;
}
`,
});
}
// Theme Panel
/**
@@ -136,4 +152,90 @@ class Helpers {
removeCustomTheme() {
return this.getThemePanel().getByRole("listitem", { name: this.CUSTOM_THEME.name }).getByRole("button").click();
}
// Message layout Panel
/**
* Create and display a room named Test Room
*/
async createAndDisplayRoom() {
await this.app.client.createRoom({ name: "Test Room" });
await this.app.viewRoomByName("Test Room");
}
/**
* Assert the room layout
* @param layout
* @private
*/
private assertRoomLayout(layout: Layout) {
return expect(this.page.locator(`.mx_RoomView_body[data-layout=${layout}]`)).toBeVisible();
}
/**
* Assert the room layout is modern
*/
assertModernLayout() {
return this.assertRoomLayout(Layout.Group);
}
/**
* Assert the room layout is bubble
*/
assertBubbleLayout() {
return this.assertRoomLayout(Layout.Bubble);
}
/**
* Return the layout panel
*/
getMessageLayoutPanel() {
return this.page.getByTestId("layoutPanel");
}
/**
* Return the layout radio button
* @param layoutName
* @private
*/
private getLayout(layoutName: string) {
return this.getMessageLayoutPanel().getByRole("radio", { name: layoutName });
}
/**
* Return the message bubbles layout radio button
*/
getBubbleLayout() {
return this.getLayout("Message bubbles");
}
/**
* Return the modern layout radio button
*/
getModernLayout() {
return this.getLayout("Modern");
}
/**
* Return the IRC layout radio button
*/
getIRCLayout() {
return this.getLayout("IRC (experimental)");
}
/**
* Return the compact layout checkbox
*/
getCompactLayoutCheckbox() {
return this.getMessageLayoutPanel().getByRole("checkbox", { name: "Show compact text and messages" });
}
/**
* Assert the compact layout is enabled
*/
assertCompactLayout() {
return expect(
this.page.locator("#matrixchat .mx_MatrixChat_wrapper.mx_MatrixChat_useCompactLayout"),
).toBeVisible();
}
}