Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User trait fix old commit #30135

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
966 changes: 7 additions & 959 deletions .circleci/config.yml

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions app/scripts/controllers/metametrics-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ export default class MetaMetricsController extends BaseController<
),
};

if (!previousUserTraits) {
if (!previousUserTraits && metamaskState.participateInMetaMetrics) {
this.update((state) => {
state.previousUserTraits = currentTraits;
});
Expand All @@ -1252,9 +1252,13 @@ export default class MetaMetricsController extends BaseController<
const previous = previousUserTraits[k];
return !isEqual(previous, v);
});
this.update((state) => {
state.previousUserTraits = currentTraits;
});

if (metamaskState.participateInMetaMetrics) {
this.update((state) => {
state.previousUserTraits = currentTraits;
});
}

return updates;
}

Expand Down
10 changes: 10 additions & 0 deletions test/e2e/page-objects/flows/onboarding.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ import { E2E_SRP } from '../../default-fixture';
* @param [options.password] - The password to create. Defaults to WALLET_PASSWORD.
* @param [options.participateInMetaMetrics] - Whether to participate in MetaMetrics. Defaults to false.
* @param [options.needNavigateToNewPage] - Indicates whether to navigate to a new page before starting the onboarding flow. Defaults to true.
* @param [options.dataCollectionForMarketing] - Whether to opt in to data collection for marketing. Defaults to false.
*/
export const createNewWalletOnboardingFlow = async ({
driver,
password = WALLET_PASSWORD,
participateInMetaMetrics = false,
needNavigateToNewPage = true,
dataCollectionForMarketing = false,
}: {
driver: Driver;
password?: string;
participateInMetaMetrics?: boolean;
needNavigateToNewPage?: boolean;
dataCollectionForMarketing?: boolean;
}): Promise<void> => {
console.log('Starting the creation of a new wallet onboarding flow');
if (needNavigateToNewPage) {
Expand All @@ -40,6 +43,9 @@ export const createNewWalletOnboardingFlow = async ({

const onboardingMetricsPage = new OnboardingMetricsPage(driver);
await onboardingMetricsPage.check_pageIsLoaded();
if (dataCollectionForMarketing) {
await onboardingMetricsPage.clickDataCollectionForMarketingCheckbox();
}
if (participateInMetaMetrics) {
await onboardingMetricsPage.clickIAgreeButton();
} else {
Expand Down Expand Up @@ -109,24 +115,28 @@ export const importSRPOnboardingFlow = async ({
* @param [options.password] - The password to use. Defaults to WALLET_PASSWORD.
* @param [options.participateInMetaMetrics] - Whether to participate in MetaMetrics. Defaults to false.
* @param [options.needNavigateToNewPage] - Indicates whether to navigate to a new page before starting the onboarding flow. Defaults to true.
* @param [options.dataCollectionForMarketing] - Whether to opt in to data collection for marketing. Defaults to false.
*/
export const completeCreateNewWalletOnboardingFlow = async ({
driver,
password = WALLET_PASSWORD,
participateInMetaMetrics = false,
needNavigateToNewPage = true,
dataCollectionForMarketing = false,
}: {
driver: Driver;
password?: string;
participateInMetaMetrics?: boolean;
needNavigateToNewPage?: boolean;
dataCollectionForMarketing?: boolean;
}): Promise<void> => {
console.log('start to complete create new wallet onboarding flow ');
await createNewWalletOnboardingFlow({
driver,
password,
participateInMetaMetrics,
needNavigateToNewPage,
dataCollectionForMarketing,
});
const onboardingCompletePage = new OnboardingCompletePage(driver);
await onboardingCompletePage.check_pageIsLoaded();
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/page-objects/pages/header-navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class HeaderNavbar {

private readonly switchNetworkDropDown = '[data-testid="network-display"]';

private readonly notificationsMenuItem =
'[data-testid="notifications-menu-item"]';

private readonly networkPicker = '.mm-picker-network';

constructor(driver: Driver) {
Expand Down Expand Up @@ -63,6 +66,7 @@ class HeaderNavbar {
async openThreeDotMenu(): Promise<void> {
console.log('Open account options menu');
await this.driver.clickElement(this.threeDotMenuButton);
await this.driver.waitForSelector(this.notificationsMenuItem);
}

async openPermissionsPage(): Promise<void> {
Expand All @@ -80,7 +84,7 @@ class HeaderNavbar {
async openSettingsPage(): Promise<void> {
console.log('Open settings page');
await this.openThreeDotMenu();
await this.driver.clickElement(this.settingsButton);
await this.driver.clickElementAndWaitToDisappear(this.settingsButton);
}

async clickSwitchNetworkDropDown(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class OnboardingMetricsPage {

private readonly iAgreeButton = '[data-testid="metametrics-i-agree"]';

private readonly dataCollectionForMarketingCheckbox =
'[data-testid="metametrics-data-collection-checkbox"]';

private readonly metametricsMessage = {
text: 'Help us improve MetaMask',
tag: 'h2',
Expand Down Expand Up @@ -39,6 +42,10 @@ class OnboardingMetricsPage {
async clickIAgreeButton(): Promise<void> {
await this.driver.clickElementAndWaitToDisappear(this.iAgreeButton);
}

async clickDataCollectionForMarketingCheckbox(): Promise<void> {
await this.driver.clickElement(this.dataCollectionForMarketingCheckbox);
}
}

export default OnboardingMetricsPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Driver } from '../../../webdriver/driver';
import HeaderNavbar from '../header-navbar';
import SettingsPage from './settings-page';

class SecurityAndPrivacySettings {
private readonly driver: Driver;

private readonly securityAndPrivacySettingsPageTitle = {
text: 'Security & privacy',
tag: 'h4',
};

private readonly participateInMetaMetricsToggle =
'[data-testid="participate-in-meta-metrics-toggle"] .toggle-button';

private readonly dataCollectionForMarketingToggle =
'[data-testid="data-collection-for-marketing-toggle"] .toggle-button';

constructor(driver: Driver) {
this.driver = driver;
}

async check_pageIsLoaded(): Promise<void> {
try {
await this.driver.waitForSelector(
this.securityAndPrivacySettingsPageTitle,
);
} catch (e) {
console.log(
'Timeout while waiting for Security and Privacy settings page to be loaded',
e,
);
throw e;
}
console.log('Security and Privacy settings page is loaded');
}

async navigateToPage() {
const headerNavbar = new HeaderNavbar(this.driver);
await headerNavbar.openSettingsPage();
const settingsPage = new SettingsPage(this.driver);
await settingsPage.check_pageIsLoaded();
await settingsPage.goToPrivacySettings();
await this.check_pageIsLoaded();
}

async toggleParticipateInMetaMetrics(): Promise<void> {
console.log(
'Toggle participate in meta metrics in Security and Privacy settings page',
);
await this.driver.clickElement(this.participateInMetaMetricsToggle);
}

async toggleDataCollectionForMarketing(): Promise<void> {
console.log(
'Toggle data collection for marketing in Security and Privacy settings page',
);
await this.driver.clickElement(this.dataCollectionForMarketingToggle);
}
}

export default SecurityAndPrivacySettings;
2 changes: 2 additions & 0 deletions test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@

console.log('My test list:', myTestList);

myTestList = myTestList.filter(tp => tp.match(/segment/))

Check failure on line 247 in test/e2e/run-all.js

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

Replace `tp·=>·tp.match(/segment/))` with `(tp)·=>·tp.match(/segment/));`

Check failure on line 247 in test/e2e/run-all.js

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

Use the 'u' flag

// spawn `run-e2e-test.js` for each test in myTestList
for (let testPath of myTestList) {
if (testPath !== '') {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/metrics/marketing-cookieid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const selectors = {
globalMenuSettingsButton: '[data-testid="global-menu-settings"]',
securityAndPrivacySettings: { text: 'Security & privacy', tag: 'div' },
dataCollectionForMarketingToggle:
'[data-testid="dataCollectionForMarketing"] .toggle-button',
'[data-testid="data-collection-for-marketing-toggle"] .toggle-button',
dataCollectionWarningAckButton: { text: 'Okay', tag: 'Button' },
};

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tests/metrics/metametrics-persistence.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('MetaMetrics ID persistence', function () {

// toggle off
await driver.clickElement(
'[data-testid="participateInMetaMetrics"] .toggle-button',
'[data-testid="participate-in-meta-metrics-toggle"] .toggle-button',
);

// wait for state to update
Expand All @@ -65,7 +65,7 @@ describe('MetaMetrics ID persistence', function () {

// toggle back on
await driver.clickElement(
'[data-testid="participateInMetaMetrics"] .toggle-button',
'[data-testid="participate-in-meta-metrics-toggle"] .toggle-button',
);

// wait for state to update
Expand Down
Loading
Loading