Skip to content

Commit

Permalink
chore(lld): 👌 always skip the analytics prompt in e2e tests (#7910)
Browse files Browse the repository at this point in the history
* chore(lld): do not show dismissed analytics prompt during onboarding

* chore(lld): always skip the analytics prompt in e2e tests

* chore: update change log

* fix(lld test): accounts/encrypted.spec.ts

* Revert "chore(lld): do not show dismissed analytics prompt during onboarding"

This reverts commit 38b7ae1.

* chore(lld): accept analytics on onboarding tests

* chore: set hasSeenAnalyticsOptInPrompt to false on all onboarding tests
  • Loading branch information
thesan authored Sep 26, 2024
1 parent 600c7b6 commit 8b3fd36
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-snakes-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

Always skip the analytics prompt in e2e tests
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ const MainFooter = ({ setWantToManagePreferences, onShareAnalyticsChange }: Main
>
{t("analyticsOptInPrompt.variantA.refuse")}
</Button>
<Button variant={"main"} size={"large"} borderRadius={48} onClick={handleAcceptClick}>
<Button
data-testid="accept-analytics-button"
variant={"main"}
size={"large"}
borderRadius={48}
onClick={handleAcceptClick}
>
{t("analyticsOptInPrompt.variantA.accept")}
</Button>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const VariantBFooter = ({ clickOptions }: VariantBFooterProps) => {
{t("analyticsOptInPrompt.variantB.refuse")}
</Button>
<Button
data-testid="accept-analytics-button"
variant={"main"}
size={"large"}
borderRadius={48}
Expand Down
19 changes: 12 additions & 7 deletions apps/ledger-live-desktop/tests/fixtures/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test as base, Page, ElectronApplication, ChromiumBrowserContext } from "@playwright/test";
import fsPromises from "fs/promises";
import merge from "lodash/merge";
import * as path from "path";
import { OptionalFeatureMap } from "@ledgerhq/types-live";
import { getEnv, setEnv } from "@ledgerhq/live-env";
Expand All @@ -16,9 +17,10 @@ type TestFixtures = {
lang: string;
theme: "light" | "dark" | "no-preference" | undefined;
speculosApp: AppInfos;
userdata: string;
userdata?: string;
settings: Record<string, unknown>;
userdataDestinationPath: string;
userdataOriginalFile: string;
userdataOriginalFile?: string;
userdataFile: string;
env: Record<string, string>;
electronApp: ElectronApplication;
Expand All @@ -40,6 +42,7 @@ export const test = base.extend<TestFixtures>({
lang: "en-US",
theme: "dark",
userdata: undefined,
settings: { shareAnalytics: true, hasSeenAnalyticsOptInPrompt: true },
featureFlags: undefined,
simulateCamera: undefined,
speculosApp: undefined,
Expand All @@ -53,7 +56,7 @@ export const test = base.extend<TestFixtures>({
await use(path.join(__dirname, "../artifacts/userdata", randomUUID()));
},
userdataOriginalFile: async ({ userdata }, use) => {
await use(path.join(__dirname, "../userdata/", `${userdata}.json`));
await use(userdata && path.join(__dirname, "../userdata/", `${userdata}.json`));
},
userdataFile: async ({ userdataDestinationPath }, use) => {
const fullFilePath = path.join(userdataDestinationPath, "app.json");
Expand All @@ -63,9 +66,9 @@ export const test = base.extend<TestFixtures>({
{
lang,
theme,
userdata,
userdataDestinationPath,
userdataOriginalFile,
settings,
env,
featureFlags,
simulateCamera,
Expand All @@ -77,9 +80,11 @@ export const test = base.extend<TestFixtures>({
// create userdata path
await fsPromises.mkdir(userdataDestinationPath, { recursive: true });

if (userdata) {
await fsPromises.copyFile(userdataOriginalFile, `${userdataDestinationPath}/app.json`);
}
const fileUserData = userdataOriginalFile
? await fsPromises.readFile(userdataOriginalFile, { encoding: "utf-8" }).then(JSON.parse)
: {};
const userData = merge({ data: { settings } }, fileUserData);
await fsPromises.writeFile(`${userdataDestinationPath}/app.json`, JSON.stringify(userData));

let device: any | undefined;

Expand Down
4 changes: 4 additions & 0 deletions apps/ledger-live-desktop/tests/page/onboarding.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppPage } from "tests/page/abstractClasses";
export class OnboardingPage extends AppPage {
deviceAction = new DeviceAction(this.page);
private getStartedButton = this.page.locator('button:has-text("Get Started")');
private acceptAnalyticsButton = this.page.getByTestId("accept-analytics-button");
private selectDeviceButton = (deviceId: string) => this.page.getByTestId(`v3-device-${deviceId}`);
private checkMyNanoButton = this.page.locator('button:has-text("Check my Nano")');
readonly continueButton = this.page.locator('button:has-text("Continue")');
Expand Down Expand Up @@ -36,6 +37,9 @@ export class OnboardingPage extends AppPage {

async getStarted() {
await this.getStartedButton.click();

// Click on accept analytics button if it exists
await this.acceptAnalyticsButton.click().catch(() => {});
}

async hoverDevice(device: "nanoS" | "nanoX" | "nanoSP" | "stax") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { expect } from "@playwright/test";
import test from "../../fixtures/common";
import { OnboardingPage } from "../../page/onboarding.page";

test.use({
settings: { hasSeenAnalyticsOptInPrompt: false },
});

enum Nano {
nanoX = "nanoX",
nanoS = "nanoS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { expect } from "@playwright/test";
import test from "../../fixtures/common";
import { OnboardingPage } from "../../page/onboarding.page";

test.use({
settings: { hasSeenAnalyticsOptInPrompt: false },
});

enum Nano {
nanoX = "nanoX",
nanoS = "nanoS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import test from "../../fixtures/common";
import { expect } from "@playwright/test";
import { OnboardingPage } from "../../page/onboarding.page";

test.use({
settings: { hasSeenAnalyticsOptInPrompt: false },
});

enum Nano {
nanoX = "nanoX",
nanoS = "nanoS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { expect } from "@playwright/test";
import test from "../../fixtures/common";
import { OnboardingPage } from "../../page/onboarding.page";
import { DeviceModelId } from "@ledgerhq/devices";

test.use({
env: { MOCK_NO_BYPASS: "1" },
settings: { hasSeenAnalyticsOptInPrompt: false },
});

const modelIds = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"loaded": true,
"shareAnalytics": true,
"sharePersonalizedRecommandations": false,
"hasSeenAnalyticsOptInPrompt": false,
"hasSeenAnalyticsOptInPrompt": true,
"sentryLogs": true,
"lastUsedVersion": "99.99.99",
"dismissedBanners": [],
Expand Down

0 comments on commit 8b3fd36

Please sign in to comment.