Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into kerry/24922/user-settings-headings-labs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry Archibald committed May 4, 2023
2 parents 6d2d8ca + 3ca957b commit 75ef939
Show file tree
Hide file tree
Showing 17 changed files with 231 additions and 51 deletions.
174 changes: 174 additions & 0 deletions cypress/e2e/invite/invite-dialog.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
Copyright 2023 Suguru Hirahara
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import type { MatrixClient } from "matrix-js-sdk/src/client";
import { HomeserverInstance } from "../../plugins/utils/homeserver";

describe("Invite dialog", function () {
let homeserver: HomeserverInstance;
let bot: MatrixClient;
const botName = "BotAlice";

beforeEach(() => {
cy.startHomeserver("default").then((data) => {
homeserver = data;
cy.initTestUser(homeserver, "Hanako");

cy.getBot(homeserver, { displayName: botName, autoAcceptInvites: true }).then((_bot) => {
bot = _bot;
});
});
});

afterEach(() => {
cy.stopHomeserver(homeserver);
});

it("should support inviting a user to a room", () => {
// Create and view a room
cy.createRoom({ name: "Test Room" }).viewRoomByName("Test Room");

// Assert that the room was configured
cy.findByText("Hanako created and configured the room.").should("exist");

// Open the room info panel
cy.findByRole("button", { name: "Room info" }).click();

// Click "People" button on the panel
// Regex pattern due to the string of "mx_BaseCard_Button_sublabel"
cy.findByRole("button", { name: /People/ }).click();

cy.get(".mx_BaseCard_header").within(() => {
// Click "Invite to this room" button
// Regex pattern due to "mx_MemberList_invite span::before"
cy.findByRole("button", { name: /Invite to this room/ }).click();
});

cy.get(".mx_InviteDialog_other").within(() => {
cy.get(".mx_Dialog_header .mx_Dialog_title").within(() => {
// Assert that the header is rendered
cy.findByText("Invite to Test Room").should("exist");
});

// Assert that the bar is rendered
cy.get(".mx_InviteDialog_addressBar").should("exist");
});

// TODO: unhide userId
const percyCSS = ".mx_InviteDialog_helpText_userId { visibility: hidden !important; }";

// Take a snapshot of the invite dialog including its wrapper
cy.get(".mx_Dialog_wrapper").percySnapshotElement("Invite Dialog - Room (without a user)", { percyCSS });

cy.get(".mx_InviteDialog_other").within(() => {
cy.get(".mx_InviteDialog_identityServer").should("not.exist");

cy.findByTestId("invite-dialog-input").type(bot.getUserId());

// Assert that notification about identity servers appears after typing userId
cy.get(".mx_InviteDialog_identityServer").should("exist");

cy.get(".mx_InviteDialog_tile_nameStack").within(() => {
cy.get(".mx_InviteDialog_tile_nameStack_userId").within(() => {
// Assert that the bot id is rendered properly
cy.findByText(bot.getUserId()).should("exist");
});

cy.get(".mx_InviteDialog_tile_nameStack_name").within(() => {
cy.findByText(botName).click();
});
});

cy.get(".mx_InviteDialog_userTile_pill .mx_InviteDialog_userTile_name").within(() => {
cy.findByText(botName).should("exist");
});
});

// Take a snapshot of the invite dialog with a user pill
cy.get(".mx_Dialog_wrapper").percySnapshotElement("Invite Dialog - Room (with a user pill)", { percyCSS });

cy.get(".mx_InviteDialog_other").within(() => {
// Invite the bot
cy.findByRole("button", { name: "Invite" }).click();
});

// Assert that the invite dialog disappears
cy.get(".mx_InviteDialog_other").should("not.exist");

// Assert that they were invited and joined
cy.findByText(`${botName} joined the room`).should("exist");
});

it("should support inviting a user to Direct Messages", () => {
cy.get(".mx_RoomList").within(() => {
cy.findByRole("button", { name: "Start chat" }).click();
});

cy.get(".mx_InviteDialog_other").within(() => {
cy.get(".mx_Dialog_header .mx_Dialog_title").within(() => {
// Assert that the header is rendered
cy.findByText("Direct Messages").should("exist");
});

// Assert that the bar is rendered
cy.get(".mx_InviteDialog_addressBar").should("exist");
});

// TODO: unhide userId and invite link
const percyCSS =
".mx_InviteDialog_footer_link, .mx_InviteDialog_helpText_userId { visibility: hidden !important; }";

// Take a snapshot of the invite dialog including its wrapper
cy.get(".mx_Dialog_wrapper").percySnapshotElement("Invite Dialog - Direct Messages (without a user)", {
percyCSS,
});

cy.get(".mx_InviteDialog_other").within(() => {
cy.findByTestId("invite-dialog-input").type(bot.getUserId());

cy.get(".mx_InviteDialog_tile_nameStack").within(() => {
cy.findByText(bot.getUserId()).should("exist");
cy.findByText(botName).click();
});

cy.get(".mx_InviteDialog_userTile_pill .mx_InviteDialog_userTile_name").within(() => {
cy.findByText(botName).should("exist");
});
});

// Take a snapshot of the invite dialog with a user pill
cy.get(".mx_Dialog_wrapper").percySnapshotElement("Invite Dialog - Direct Messages (with a user pill)", {
percyCSS,
});

cy.get(".mx_InviteDialog_other").within(() => {
// Open a direct message UI
cy.findByRole("button", { name: "Go" }).click();
});

// Assert that the invite dialog disappears
cy.get(".mx_InviteDialog_other").should("not.exist");

// Send a message to invite the bots
cy.getComposer().type("Hello{enter}");

// Assert that they were invited and joined
cy.findByText(`${botName} joined the room`).should("exist");

// Assert that the message is displayed at the bottom
cy.get(".mx_EventTile_last").findByText("Hello").should("exist");
});
});
6 changes: 3 additions & 3 deletions cypress/e2e/timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe("Timeline", () => {
// Check the profile resizer's place
// See: _IRCLayout
// --RoomView_MessageList-padding = 18px (See: _RoomView.pcss)
// --MessageTimestamp-width = $MessageTimestamp_width = 46px (See: _common.pcss)
// --MessageTimestamp-width = 46px (See: _MessageTimestamp.pcss)
// --icon-width = 14px
// --right-padding = 5px
// --name-width = 80px
Expand Down Expand Up @@ -371,7 +371,7 @@ describe("Timeline", () => {
// Check inline start spacing of collapsed GELS
// See: _EventTile.pcss
// .mx_GenericEventListSummary[data-layout="irc"] > .mx_EventTile_line
// = var(--name-width) + var(--icon-width) + $MessageTimestamp_width + 2 * var(--right-padding)
// = var(--name-width) + var(--icon-width) + var(--MessageTimestamp-width) + 2 * var(--right-padding)
// = 80 + 14 + 46 + 2 * 5
// = 150px
cy.get(".mx_GenericEventListSummary[data-layout=irc] > .mx_EventTile_line").should(
Expand All @@ -388,7 +388,7 @@ describe("Timeline", () => {
.should("have.css", "margin-inline-end", "0px");
// --icon-width should be applied
cy.get(".mx_EventTile .mx_EventTile_avatar > .mx_BaseAvatar").should("have.css", "width", "14px");
// $MessageTimestamp_width should be applied
// var(--MessageTimestamp-width) should be applied
cy.get(".mx_EventTile > a").should("have.css", "min-width", "46px");
// Record alignment of collapsed GELS and messages on messagePanel
cy.get(".mx_MainSplit").percySnapshotElement("Collapsed GELS and messages on IRC layout", { percyCSS });
Expand Down
4 changes: 0 additions & 4 deletions res/css/_common.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ $hover-transition: 0.08s cubic-bezier(0.46, 0.03, 0.52, 0.96); /* quadratic */

$selected-message-border-width: 4px;

$MessageTimestamp_width: 46px; /* 8 + 30 (avatar) + 8 */
$MessageTimestamp_width_hover: calc($MessageTimestamp_width - 2 * $selected-message-border-width);

$slider-dot-size: 1em;
$slider-selection-dot-size: 2.4em;

Expand All @@ -41,7 +38,6 @@ $timeline-image-border-radius: 8px;
--container-gap-width: 8px; /* only even numbers should be used because otherwise we get 0.5px margin values. */
--transition-short: 0.1s;
--transition-standard: 0.3s;
--MessageTimestamp-width: $MessageTimestamp_width;
--buttons-dialog-gap-row: $spacing-8;
--buttons-dialog-gap-column: $spacing-8;
}
Expand Down
2 changes: 1 addition & 1 deletion res/css/structures/_MainSplit.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ limitations under the License.
padding-left: calc(var(--container-gap-width) / 2);
height: calc(100vh - 51px); /* height of .mx_RoomHeader.light-panel */

&:hover .mx_ResizeHandle_horizontal::before {
&:hover .mx_ResizeHandle--horizontal::before {
position: absolute;
top: 50%;
left: 50%;
Expand Down
4 changes: 2 additions & 2 deletions res/css/structures/_MatrixChat.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ limitations under the License.
/* negative margin greater than its positive padding. If it's the same */
/* or less, Safari and other WebKit based browsers get confused about overflows somehow and */
/* https://github.com/vector-im/element-web/issues/19863 happens. */
.mx_MatrixChat > .mx_ResizeHandle.mx_ResizeHandle_horizontal {
.mx_MatrixChat > .mx_ResizeHandle.mx_ResizeHandle--horizontal {
margin: 0 calc(-5.5px - var(--container-gap-width) / 2) 0 calc(-6.5px + var(--container-gap-width) / 2);
/* The condition to prevent bleeding is: (margin-left + margin-right < -11px) */
/* (IF there is NO margin on the leftPanel_wrapper) */
Expand All @@ -94,7 +94,7 @@ limitations under the License.
/* We want the handle to be in the middle of the gap so it is shifted by (var(--container-gap-width) / 2) */
}

.mx_MatrixChat > .mx_ResizeHandle_horizontal:hover {
.mx_MatrixChat > .mx_ResizeHandle--horizontal:hover {
position: relative;

&::before {
Expand Down
39 changes: 19 additions & 20 deletions res/css/views/elements/_ResizeHandle.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@ limitations under the License.
cursor: row-resize;
flex: 0 0 auto;
z-index: 100;
}

.mx_ResizeHandle.mx_ResizeHandle_horizontal {
margin: 0 -5px;
padding: 0 5px;
cursor: col-resize;
}

.mx_ResizeHandle.mx_ResizeHandle_vertical {
margin: -5px 0;
padding: 5px 0;
cursor: row-resize;
}

.mx_ResizeHandle.mx_ResizeHandle_horizontal > div {
width: 1px;
height: 100%;
}

.mx_ResizeHandle.mx_ResizeHandle_vertical > div {
height: 1px;
&.mx_ResizeHandle--horizontal {
margin: 0 -5px;
padding: 0 5px;
cursor: col-resize;

> div {
width: 1px;
height: 100%;
}
}

&.mx_ResizeHandle--vertical {
margin: -5px 0;
padding: 5px 0;

> div {
height: 1px;
}
}
}
2 changes: 1 addition & 1 deletion res/css/views/messages/_EventTileBubble.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.
padding: 10px; /* TODO: Use a spacing variable */
border-radius: 8px;
/* Reserve space for external timestamps, but also cap the width */
max-width: min(calc(100% - 2 * $MessageTimestamp_width), 600px);
max-width: min(calc(100% - 2 * var(--MessageTimestamp-width)), 600px);
box-sizing: border-box;
display: grid;
grid-template-columns: 24px minmax(0, 1fr) min-content min-content;
Expand Down
7 changes: 5 additions & 2 deletions res/css/views/messages/_MessageTimestamp.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_MessageTimestamp {
:root {
--MessageTimestamp-width: 46px; /* 8 + 30 (avatar) + 8 */
--MessageTimestamp-max-width: 80px;
--MessageTimestamp-color: $event-timestamp-color;
}

.mx_MessageTimestamp {
color: var(--MessageTimestamp-color);
font-size: $font-10px;
font-variant-numeric: tabular-nums;
display: block; /* enable the width setting below */
width: $MessageTimestamp_width;
width: var(--MessageTimestamp-width);
white-space: nowrap;
user-select: none;
}
4 changes: 2 additions & 2 deletions res/css/views/right_panel/_TimelineCard.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ limitations under the License.
&.mx_EventTile_info .mx_EventTile_line,
.mx_EventTile_line {
padding: var(--BaseCard_EventTile_line-padding-block) var(--BaseCard_EventTile-spacing-inline);
padding-inline-end: $MessageTimestamp_width; /* ensure timestamp is not hidden */
padding-inline-end: var(--MessageTimestamp-width); /* ensure timestamp is not hidden */

.mx_EventTile_e2eIcon {
inset-inline-start: $spacing-8;
Expand Down Expand Up @@ -157,7 +157,7 @@ limitations under the License.
.mx_EventTile_line,
.mx_GenericEventListSummary_unstyledList > .mx_EventTile_info .mx_EventTile_avatar ~ .mx_EventTile_line {
padding-inline-start: var(--BaseCard_EventTile-spacing-inline);
padding-inline-end: $MessageTimestamp_width; /* ensure timestamp is not hidden */
padding-inline-end: var(--MessageTimestamp-width); /* ensure timestamp is not hidden */
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions res/css/views/rooms/_AppsDrawer.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $MinWidth: 240px;
background: $primary-content;
}

.mx_ResizeHandle_horizontal::before {
.mx_ResizeHandle--horizontal::before {
position: absolute;
left: 3px;
top: 50%;
Expand Down Expand Up @@ -140,7 +140,7 @@ $MinWidth: 240px;
border-radius: 0 10px 10px 0;
}

.mx_ResizeHandle_horizontal {
.mx_ResizeHandle--horizontal {
position: relative;

> div {
Expand Down
7 changes: 4 additions & 3 deletions res/css/views/rooms/_EventTile.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ $left-gutter: 64px;

> a {
text-decoration: none; /* timestamps are links which shouldn't be underlined */
min-width: $MessageTimestamp_width; /* ensure space for EventTile without timestamp */
min-width: var(--MessageTimestamp-width); /* ensure space for EventTile without timestamp */
}

> * {
Expand Down Expand Up @@ -650,7 +650,7 @@ $left-gutter: 64px;
/* add --right-padding value of MessageTimestamp and avatar only */
/* stylelint-disable-next-line declaration-colon-space-after */
padding-left: calc(
var(--name-width) + var(--icon-width) + $MessageTimestamp_width + 2 * var(--right-padding)
var(--name-width) + var(--icon-width) + var(--MessageTimestamp-width) + 2 * var(--right-padding)
);
}
}
Expand Down Expand Up @@ -1218,7 +1218,8 @@ $left-gutter: 64px;
padding-top: 0;

.mx_EventTile_avatar {
left: calc($MessageTimestamp_width + 14px - 4px); /* 14px: avatar width, 4px: align with text */
/* 14px: avatar width, 4px: align with text */
left: calc(var(--MessageTimestamp-width) + 14px - 4px);
z-index: 9; /* position above the hover styling */
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class LoggedInView extends React.Component<IProps, IState> {
const resizer = new Resizer(this._resizeContainer.current, CollapseDistributor, collapseConfig);
resizer.setClassNames({
handle: "mx_ResizeHandle",
vertical: "mx_ResizeHandle_vertical",
vertical: "mx_ResizeHandle--vertical",
});
return resizer;
}
Expand Down
Loading

0 comments on commit 75ef939

Please sign in to comment.