Skip to content

Commit

Permalink
attempt to fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DDDDDanica committed Feb 4, 2025
1 parent 2093957 commit f5aa530
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import SettingsPage from './settings-page';
class SecurityAndPrivacySettings {
private readonly driver: Driver;

private readonly securityAndPrivacySettingsPageTitle = {
text: 'Security & privacy',
tag: 'h4',
};
private readonly securityAndPrivacySettingsPageBodySection =
'[data-testid="settings-page-body-section"]';

private readonly participateInMetaMetricsToggle =
'[data-testid="participate-in-meta-metrics-toggle"] .toggle-button';
Expand All @@ -23,7 +21,7 @@ class SecurityAndPrivacySettings {
async check_pageIsLoaded(): Promise<void> {
try {
await this.driver.waitForSelector(
this.securityAndPrivacySettingsPageTitle,
this.securityAndPrivacySettingsPageBodySection,
);
} catch (e) {
console.log(
Expand All @@ -41,7 +39,6 @@ class SecurityAndPrivacySettings {
const settingsPage = new SettingsPage(this.driver);
await settingsPage.check_pageIsLoaded();
await settingsPage.goToPrivacySettings();
await this.check_pageIsLoaded();
}

async toggleParticipateInMetaMetrics(): Promise<void> {
Expand Down
18 changes: 6 additions & 12 deletions test/e2e/page-objects/pages/settings/settings-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ class SettingsPage {
private readonly closeSettingsPageButton =
'.settings-page__header__title-container__close-button';

private readonly developerOptionsButton = {
text: 'Developer Options',
css: '.tab-bar__tab__content__title',
};
private readonly developerOptionsButton =
'[data-testid="tab-content-Developer Options"]';

private readonly experimentalSettingsButton = {
text: 'Experimental',
css: '.tab-bar__tab__content__title',
};
private readonly experimentalSettingsButton =
'[data-testid="tab-content-Experimental"]';

private readonly privacySettingsButton = {
text: 'Security & privacy',
css: '.tab-bar__tab__content__title',
};
private readonly privacySettingsButton =
'[data-testid="tab-content-Security & privacy"]';

private readonly settingsPageTitle = {
text: 'Settings',
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/tests/metrics/segment-user-traits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe('Segment User Traits', function () {
driver,
);
await securityAndPrivacySettings.navigateToPage();
await securityAndPrivacySettings.check_pageIsLoaded();
await securityAndPrivacySettings.toggleParticipateInMetaMetrics();
events = await getEventPayloads(driver, mockedEndpoints);
assert.equal(events.length, 1);
Expand Down Expand Up @@ -156,6 +157,7 @@ describe('Segment User Traits', function () {
driver,
);
await securityAndPrivacySettings.navigateToPage();
await securityAndPrivacySettings.check_pageIsLoaded();
await securityAndPrivacySettings.toggleParticipateInMetaMetrics();
await securityAndPrivacySettings.toggleDataCollectionForMarketing();
events = await getEventPayloads(driver, mockedEndpoints);
Expand All @@ -166,12 +168,13 @@ describe('Segment User Traits', function () {
);
});

it('should stop sending identify events when user disables metrics in privacy settings after opting in during onboarding', async function () {
it.only('should stop sending identify events when user disables metrics in privacy settings after opting in during onboarding', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true })
.withMetaMetricsController({
metaMetricsId: MOCK_META_METRICS_ID,
participateInMetaMetrics: true,
})
.build(),
title: this.test?.fullTitle(),
Expand All @@ -190,6 +193,7 @@ describe('Segment User Traits', function () {
driver,
);
await securityAndPrivacySettings.navigateToPage();
await securityAndPrivacySettings.check_pageIsLoaded();
await securityAndPrivacySettings.toggleParticipateInMetaMetrics();
events = await getEventPayloads(driver, mockedEndpoints);
assert.equal(events.length, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ exports[`SnapUIAddress renders Ethereum address 1`] = `
<rect
fill="#F29602"
height="32"
transform="translate(-2.81750896228304 4.951916544006229) rotate(230.4 16 16)"
transform="translate(-2.8175089622830405 4.951916544006229) rotate(230.4 16 16)"
width="32"
x="0"
y="0"
Expand Down Expand Up @@ -476,7 +476,7 @@ exports[`SnapUIAddress renders legacy Ethereum address 1`] = `
<rect
fill="#F29602"
height="32"
transform="translate(-2.81750896228304 4.951916544006229) rotate(230.4 16 16)"
transform="translate(-2.8175089622830405 4.951916544006229) rotate(230.4 16 16)"
width="32"
x="0"
y="0"
Expand Down
7 changes: 6 additions & 1 deletion ui/components/app/tab-bar/tab-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ const TabBar = (props) => {
)}
<div className="tab-bar__tab__content">
<div className="tab-bar__tab__content__icon">{icon}</div>
<div className="tab-bar__tab__content__title">{content}</div>
<div
className="tab-bar__tab__content__title"
data-testid={`tab-content-${content}`}
>
{content}
</div>
</div>
<Icon
name={IconName.ArrowRight}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ exports[`Connect More Accounts Modal should render correctly 1`] = `
<rect
fill="#FA4300"
height="32"
transform="translate(-1.712066926084717 -0.6920409130150889) rotate(264.3 16 16)"
transform="translate(-1.712066926084717 -0.6920409130150887) rotate(264.3 16 16)"
width="32"
x="0"
y="0"
Expand Down Expand Up @@ -218,7 +218,7 @@ exports[`Connect More Accounts Modal should render correctly 1`] = `
<rect
fill="#FA4300"
height="32"
transform="translate(-1.712066926084717 -0.6920409130150889) rotate(264.3 16 16)"
transform="translate(-1.712066926084717 -0.6920409130150887) rotate(264.3 16 16)"
width="32"
x="0"
y="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Security Tab should match snapshot 1`] = `
<div>
<div
class="settings-page__body"
data-testid="settings-page-body-section"
>
<div
class="mm-box settings-page__content-row mm-box--display-flex mm-box--gap-4 mm-box--flex-direction-row mm-box--justify-content-space-between"
Expand Down
5 changes: 4 additions & 1 deletion ui/pages/settings/security-tab/security-tab.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,10 @@ export default class SecurityTab extends PureComponent {
const { showDataCollectionDisclaimer } = this.state;

return (
<div className="settings-page__body">
<div
className="settings-page__body"
data-testid="settings-page-body-section"
>
{this.renderUseExternalServices()}
{showDataCollectionDisclaimer
? this.renderDataCollectionWarning()
Expand Down

0 comments on commit f5aa530

Please sign in to comment.