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

Commit e8eefeb

Browse files
authored
Avoid hardcoding branding in user onboarding (#9206)
* Avoid hardcoding branding in user onboarding * Make spotlight test more reliable
1 parent ef0ba77 commit e8eefeb

File tree

6 files changed

+52
-37
lines changed

6 files changed

+52
-37
lines changed

cypress/e2e/spotlight/spotlight.spec.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -349,30 +349,34 @@ describe("Spotlight", () => {
349349
cy.get(".mx_RoomSublist[aria-label=People]").should("contain", bot2Name);
350350

351351
// Invite BotBob into existing DM with ByteBot
352-
cy.getDmRooms(bot2.getUserId()).then(dmRooms => dmRooms[0])
353-
.then(groupDmId => cy.inviteUser(groupDmId, bot1.getUserId()))
354-
.then(() => {
355-
cy.roomHeaderName().should("contain", `${bot1Name} and ${bot2Name}`);
356-
cy.get(".mx_RoomSublist[aria-label=People]").should("contain", `${bot1Name} and ${bot2Name}`);
357-
});
358-
359-
// Search for BotBob by id, should return group DM and user
360-
cy.openSpotlightDialog().within(() => {
361-
cy.spotlightFilter(Filter.People);
362-
cy.spotlightSearch().clear().type(bot1.getUserId());
363-
cy.wait(1000); // wait for the dialog code to settle
364-
cy.spotlightResults().should("have.length", 2);
365-
cy.spotlightResults().eq(0).should("contain", `${bot1Name} and ${bot2Name}`);
366-
});
352+
cy.getDmRooms(bot2.getUserId())
353+
.should("have.length", 1)
354+
.then(dmRooms => cy.getClient().then(client => client.getRoom(dmRooms[0])))
355+
.then(groupDm => {
356+
cy.inviteUser(groupDm.roomId, bot1.getUserId());
357+
cy.roomHeaderName().should(($element) =>
358+
expect($element.get(0).innerText).contains(groupDm.name));
359+
cy.get(".mx_RoomSublist[aria-label=People]").should(($element) =>
360+
expect($element.get(0).innerText).contains(groupDm.name));
361+
362+
// Search for BotBob by id, should return group DM and user
363+
cy.openSpotlightDialog().within(() => {
364+
cy.spotlightFilter(Filter.People);
365+
cy.spotlightSearch().clear().type(bot1.getUserId());
366+
cy.wait(1000); // wait for the dialog code to settle
367+
cy.spotlightResults().should("have.length", 2);
368+
cy.spotlightResults().eq(0).should("contain", groupDm.name);
369+
});
367370

368-
// Search for ByteBot by id, should return group DM and user
369-
cy.openSpotlightDialog().within(() => {
370-
cy.spotlightFilter(Filter.People);
371-
cy.spotlightSearch().clear().type(bot2.getUserId());
372-
cy.wait(1000); // wait for the dialog code to settle
373-
cy.spotlightResults().should("have.length", 2);
374-
cy.spotlightResults().eq(0).should("contain", `${bot1Name} and ${bot2Name}`);
375-
});
371+
// Search for ByteBot by id, should return group DM and user
372+
cy.openSpotlightDialog().within(() => {
373+
cy.spotlightFilter(Filter.People);
374+
cy.spotlightSearch().clear().type(bot2.getUserId());
375+
cy.wait(1000); // wait for the dialog code to settle
376+
cy.spotlightResults().should("have.length", 2);
377+
cy.spotlightResults().eq(0).should("contain", groupDm.name);
378+
});
379+
});
376380
});
377381

378382
// Test against https://github.com/vector-im/element-web/issues/22851

src/components/views/user-onboarding/UserOnboardingFeedback.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ export function UserOnboardingFeedback() {
3232
<div className="mx_UserOnboardingFeedback">
3333
<div className="mx_UserOnboardingFeedback_content">
3434
<Heading size="h4" className="mx_UserOnboardingFeedback_title">
35-
{ _t("How are you finding Element so far?") }
35+
{ _t("How are you finding %(brand)s so far?", {
36+
brand: SdkConfig.get("brand"),
37+
}) }
3638
</Heading>
3739
<div className="mx_UserOnboardingFeedback_text">
38-
{ _t("We’d appreciate any feedback on how you’re finding Element.") }
40+
{ _t("We’d appreciate any feedback on how you’re finding %(brand)s.", {
41+
brand: SdkConfig.get("brand"),
42+
}) }
3943
</div>
4044
</div>
4145
<AccessibleButton

src/components/views/user-onboarding/UserOnboardingList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function UserOnboardingList({ completedTasks, waitingTasks }: Props) {
6262
</div>
6363
<ol className="mx_UserOnboardingList_list">
6464
{ tasks.map(([task, completed]) => (
65-
<UserOnboardingTask key={task.title} completed={completed} task={task} />
65+
<UserOnboardingTask key={task.id} completed={completed} task={task} />
6666
)) }
6767
</ol>
6868
</div>

src/components/views/user-onboarding/UserOnboardingTask.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ interface Props {
2727
}
2828

2929
export function UserOnboardingTask({ task, completed = false }: Props) {
30+
const title = typeof task.title === "function" ? task.title() : task.title;
31+
const description = typeof task.description === "function" ? task.description() : task.description;
32+
3033
return (
3134
<li className={classNames("mx_UserOnboardingTask", {
3235
"mx_UserOnboardingTask_completed": completed,
@@ -42,10 +45,10 @@ export function UserOnboardingTask({ task, completed = false }: Props) {
4245
id={`mx_UserOnboardingTask_${task.id}`}
4346
className="mx_UserOnboardingTask_content">
4447
<Heading size="h4" className="mx_UserOnboardingTask_title">
45-
{ task.title }
48+
{ title }
4649
</Heading>
4750
<div className="mx_UserOnboardingTask_description">
48-
{ task.description }
51+
{ description }
4952
</div>
5053
</div>
5154
{ task.action && (!task.action.hideOnComplete || !completed) && (

src/hooks/useUserOnboardingTasks.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ import { _t } from "../languageHandler";
2525
import Modal from "../Modal";
2626
import { Notifier } from "../Notifier";
2727
import PosthogTrackers from "../PosthogTrackers";
28+
import SdkConfig from "../SdkConfig";
2829
import { UseCase } from "../settings/enums/UseCase";
2930
import { useSettingValue } from "./useSettings";
3031
import { UserOnboardingContext } from "./useUserOnboardingContext";
3132

3233
export interface UserOnboardingTask {
3334
id: string;
34-
title: string;
35-
description: string;
35+
title: string | (() => string);
36+
description: string | (() => string);
3637
relevant?: UseCase[];
3738
action?: {
3839
label: string;
@@ -95,8 +96,12 @@ const tasks: InternalUserOnboardingTask[] = [
9596
},
9697
{
9798
id: "download-apps",
98-
title: _t("Download Element"),
99-
description: _t("Don’t miss a thing by taking Element with you"),
99+
title: () => _t("Download %(brand)s", {
100+
brand: SdkConfig.get("brand"),
101+
}),
102+
description: () => _t("Don’t miss a thing by taking %(brand)s with you", {
103+
brand: SdkConfig.get("brand"),
104+
}),
100105
completed: (ctx: UserOnboardingContext) => {
101106
return Boolean(ctx.devices.filter(it => it.device_id !== ctx.myDevice).length);
102107
},

src/i18n/strings/en_EN.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,8 @@
10021002
"Get stuff done by finding your teammates": "Get stuff done by finding your teammates",
10031003
"Find people": "Find people",
10041004
"Find and invite your community members": "Find and invite your community members",
1005-
"Download Element": "Download Element",
1006-
"Don’t miss a thing by taking Element with you": "Don’t miss a thing by taking Element with you",
1005+
"Download %(brand)s": "Download %(brand)s",
1006+
"Don’t miss a thing by taking %(brand)s with you": "Don’t miss a thing by taking %(brand)s with you",
10071007
"Download apps": "Download apps",
10081008
"Set up your profile": "Set up your profile",
10091009
"Make sure people know it’s really you": "Make sure people know it’s really you",
@@ -1148,8 +1148,8 @@
11481148
"Headphones": "Headphones",
11491149
"Folder": "Folder",
11501150
"Welcome": "Welcome",
1151-
"How are you finding Element so far?": "How are you finding Element so far?",
1152-
"We’d appreciate any feedback on how you’re finding Element.": "We’d appreciate any feedback on how you’re finding Element.",
1151+
"How are you finding %(brand)s so far?": "How are you finding %(brand)s so far?",
1152+
"We’d appreciate any feedback on how you’re finding %(brand)s.": "We’d appreciate any feedback on how you’re finding %(brand)s.",
11531153
"Feedback": "Feedback",
11541154
"Secure messaging for friends and family": "Secure messaging for friends and family",
11551155
"With free end-to-end encrypted messaging, and unlimited voice and video calls, %(brand)s is a great way to stay in touch.": "With free end-to-end encrypted messaging, and unlimited voice and video calls, %(brand)s is a great way to stay in touch.",
@@ -2493,7 +2493,6 @@
24932493
"We <Bold>don't</Bold> record or profile any account data": "We <Bold>don't</Bold> record or profile any account data",
24942494
"We <Bold>don't</Bold> share information with third parties": "We <Bold>don't</Bold> share information with third parties",
24952495
"You can turn this off anytime in settings": "You can turn this off anytime in settings",
2496-
"Download %(brand)s": "Download %(brand)s",
24972496
"Download %(brand)s Desktop": "Download %(brand)s Desktop",
24982497
"iOS": "iOS",
24992498
"Download on the App Store": "Download on the App Store",

0 commit comments

Comments
 (0)