Avoid hardcoding branding in user onboarding (#9206)

* Avoid hardcoding branding in user onboarding
* Make spotlight test more reliable
pull/28217/head
Janne Mareike Koschinski 2022-08-22 12:11:24 +02:00 committed by GitHub
parent ef0ba77f14
commit e8eefeb937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 37 deletions

View File

@ -349,30 +349,34 @@ describe("Spotlight", () => {
cy.get(".mx_RoomSublist[aria-label=People]").should("contain", bot2Name); cy.get(".mx_RoomSublist[aria-label=People]").should("contain", bot2Name);
// Invite BotBob into existing DM with ByteBot // Invite BotBob into existing DM with ByteBot
cy.getDmRooms(bot2.getUserId()).then(dmRooms => dmRooms[0]) cy.getDmRooms(bot2.getUserId())
.then(groupDmId => cy.inviteUser(groupDmId, bot1.getUserId())) .should("have.length", 1)
.then(() => { .then(dmRooms => cy.getClient().then(client => client.getRoom(dmRooms[0])))
cy.roomHeaderName().should("contain", `${bot1Name} and ${bot2Name}`); .then(groupDm => {
cy.get(".mx_RoomSublist[aria-label=People]").should("contain", `${bot1Name} and ${bot2Name}`); cy.inviteUser(groupDm.roomId, bot1.getUserId());
cy.roomHeaderName().should(($element) =>
expect($element.get(0).innerText).contains(groupDm.name));
cy.get(".mx_RoomSublist[aria-label=People]").should(($element) =>
expect($element.get(0).innerText).contains(groupDm.name));
// Search for BotBob by id, should return group DM and user
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1.getUserId());
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 2);
cy.spotlightResults().eq(0).should("contain", groupDm.name);
});
// Search for ByteBot by id, should return group DM and user
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2.getUserId());
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 2);
cy.spotlightResults().eq(0).should("contain", groupDm.name);
});
}); });
// Search for BotBob by id, should return group DM and user
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1.getUserId());
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 2);
cy.spotlightResults().eq(0).should("contain", `${bot1Name} and ${bot2Name}`);
});
// Search for ByteBot by id, should return group DM and user
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2.getUserId());
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 2);
cy.spotlightResults().eq(0).should("contain", `${bot1Name} and ${bot2Name}`);
});
}); });
// Test against https://github.com/vector-im/element-web/issues/22851 // Test against https://github.com/vector-im/element-web/issues/22851

View File

@ -32,10 +32,14 @@ export function UserOnboardingFeedback() {
<div className="mx_UserOnboardingFeedback"> <div className="mx_UserOnboardingFeedback">
<div className="mx_UserOnboardingFeedback_content"> <div className="mx_UserOnboardingFeedback_content">
<Heading size="h4" className="mx_UserOnboardingFeedback_title"> <Heading size="h4" className="mx_UserOnboardingFeedback_title">
{ _t("How are you finding Element so far?") } { _t("How are you finding %(brand)s so far?", {
brand: SdkConfig.get("brand"),
}) }
</Heading> </Heading>
<div className="mx_UserOnboardingFeedback_text"> <div className="mx_UserOnboardingFeedback_text">
{ _t("Wed appreciate any feedback on how youre finding Element.") } { _t("Wed appreciate any feedback on how youre finding %(brand)s.", {
brand: SdkConfig.get("brand"),
}) }
</div> </div>
</div> </div>
<AccessibleButton <AccessibleButton

View File

@ -62,7 +62,7 @@ export function UserOnboardingList({ completedTasks, waitingTasks }: Props) {
</div> </div>
<ol className="mx_UserOnboardingList_list"> <ol className="mx_UserOnboardingList_list">
{ tasks.map(([task, completed]) => ( { tasks.map(([task, completed]) => (
<UserOnboardingTask key={task.title} completed={completed} task={task} /> <UserOnboardingTask key={task.id} completed={completed} task={task} />
)) } )) }
</ol> </ol>
</div> </div>

View File

@ -27,6 +27,9 @@ interface Props {
} }
export function UserOnboardingTask({ task, completed = false }: Props) { export function UserOnboardingTask({ task, completed = false }: Props) {
const title = typeof task.title === "function" ? task.title() : task.title;
const description = typeof task.description === "function" ? task.description() : task.description;
return ( return (
<li className={classNames("mx_UserOnboardingTask", { <li className={classNames("mx_UserOnboardingTask", {
"mx_UserOnboardingTask_completed": completed, "mx_UserOnboardingTask_completed": completed,
@ -42,10 +45,10 @@ export function UserOnboardingTask({ task, completed = false }: Props) {
id={`mx_UserOnboardingTask_${task.id}`} id={`mx_UserOnboardingTask_${task.id}`}
className="mx_UserOnboardingTask_content"> className="mx_UserOnboardingTask_content">
<Heading size="h4" className="mx_UserOnboardingTask_title"> <Heading size="h4" className="mx_UserOnboardingTask_title">
{ task.title } { title }
</Heading> </Heading>
<div className="mx_UserOnboardingTask_description"> <div className="mx_UserOnboardingTask_description">
{ task.description } { description }
</div> </div>
</div> </div>
{ task.action && (!task.action.hideOnComplete || !completed) && ( { task.action && (!task.action.hideOnComplete || !completed) && (

View File

@ -25,14 +25,15 @@ import { _t } from "../languageHandler";
import Modal from "../Modal"; import Modal from "../Modal";
import { Notifier } from "../Notifier"; import { Notifier } from "../Notifier";
import PosthogTrackers from "../PosthogTrackers"; import PosthogTrackers from "../PosthogTrackers";
import SdkConfig from "../SdkConfig";
import { UseCase } from "../settings/enums/UseCase"; import { UseCase } from "../settings/enums/UseCase";
import { useSettingValue } from "./useSettings"; import { useSettingValue } from "./useSettings";
import { UserOnboardingContext } from "./useUserOnboardingContext"; import { UserOnboardingContext } from "./useUserOnboardingContext";
export interface UserOnboardingTask { export interface UserOnboardingTask {
id: string; id: string;
title: string; title: string | (() => string);
description: string; description: string | (() => string);
relevant?: UseCase[]; relevant?: UseCase[];
action?: { action?: {
label: string; label: string;
@ -95,8 +96,12 @@ const tasks: InternalUserOnboardingTask[] = [
}, },
{ {
id: "download-apps", id: "download-apps",
title: _t("Download Element"), title: () => _t("Download %(brand)s", {
description: _t("Dont miss a thing by taking Element with you"), brand: SdkConfig.get("brand"),
}),
description: () => _t("Dont miss a thing by taking %(brand)s with you", {
brand: SdkConfig.get("brand"),
}),
completed: (ctx: UserOnboardingContext) => { completed: (ctx: UserOnboardingContext) => {
return Boolean(ctx.devices.filter(it => it.device_id !== ctx.myDevice).length); return Boolean(ctx.devices.filter(it => it.device_id !== ctx.myDevice).length);
}, },

View File

@ -1002,8 +1002,8 @@
"Get stuff done by finding your teammates": "Get stuff done by finding your teammates", "Get stuff done by finding your teammates": "Get stuff done by finding your teammates",
"Find people": "Find people", "Find people": "Find people",
"Find and invite your community members": "Find and invite your community members", "Find and invite your community members": "Find and invite your community members",
"Download Element": "Download Element", "Download %(brand)s": "Download %(brand)s",
"Dont miss a thing by taking Element with you": "Dont miss a thing by taking Element with you", "Dont miss a thing by taking %(brand)s with you": "Dont miss a thing by taking %(brand)s with you",
"Download apps": "Download apps", "Download apps": "Download apps",
"Set up your profile": "Set up your profile", "Set up your profile": "Set up your profile",
"Make sure people know its really you": "Make sure people know its really you", "Make sure people know its really you": "Make sure people know its really you",
@ -1148,8 +1148,8 @@
"Headphones": "Headphones", "Headphones": "Headphones",
"Folder": "Folder", "Folder": "Folder",
"Welcome": "Welcome", "Welcome": "Welcome",
"How are you finding Element so far?": "How are you finding Element so far?", "How are you finding %(brand)s so far?": "How are you finding %(brand)s so far?",
"Wed appreciate any feedback on how youre finding Element.": "Wed appreciate any feedback on how youre finding Element.", "Wed appreciate any feedback on how youre finding %(brand)s.": "Wed appreciate any feedback on how youre finding %(brand)s.",
"Feedback": "Feedback", "Feedback": "Feedback",
"Secure messaging for friends and family": "Secure messaging for friends and family", "Secure messaging for friends and family": "Secure messaging for friends and family",
"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.", "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 @@
"We <Bold>don't</Bold> record or profile any account data": "We <Bold>don't</Bold> record or profile any account data", "We <Bold>don't</Bold> record or profile any account data": "We <Bold>don't</Bold> record or profile any account data",
"We <Bold>don't</Bold> share information with third parties": "We <Bold>don't</Bold> share information with third parties", "We <Bold>don't</Bold> share information with third parties": "We <Bold>don't</Bold> share information with third parties",
"You can turn this off anytime in settings": "You can turn this off anytime in settings", "You can turn this off anytime in settings": "You can turn this off anytime in settings",
"Download %(brand)s": "Download %(brand)s",
"Download %(brand)s Desktop": "Download %(brand)s Desktop", "Download %(brand)s Desktop": "Download %(brand)s Desktop",
"iOS": "iOS", "iOS": "iOS",
"Download on the App Store": "Download on the App Store", "Download on the App Store": "Download on the App Store",