Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ export const ProfileMetricsControllerInit: ControllerInitFunction<
'RemoteFeatureFlagController',
);
const metaMetricsController = getController('MetaMetricsController');
const appStateController = getController('AppStateController');
const assertUserOptedIn = () =>
remoteFeatureFlagController.state.remoteFeatureFlags.extensionUxPna25 ===
true && metaMetricsController.state.participateInMetaMetrics === true;
true &&
appStateController.state.pna25Acknowledged === true &&
metaMetricsController.state.participateInMetaMetrics === true;

const controller = new ProfileMetricsController({
messenger: controllerMessenger,
Expand Down
142 changes: 69 additions & 73 deletions test/e2e/tests/profile-metrics/profile-metrics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ async function waitForEndpointToBeCalled(
}

describe('Profile Metrics', function () {
describe('when MetaMetrics is enabled and the feature flag is on', function () {
describe('when MetaMetrics is enabled, the feature flag is on, and the user acknoledged the privacy change', function () {
it('sends exising accounts to the API on wallet unlock after activating MetaMetrics', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder()
.withMetaMetricsController({
participateInMetaMetrics: true,
})
.withAppStateController({
pna25Acknowledged: true,
})
.build(),
testSpecificMock: async (server: Mockttp) => [
await mockAuthService(server),
Expand Down Expand Up @@ -121,6 +124,9 @@ describe('Profile Metrics', function () {
.withMetaMetricsController({
participateInMetaMetrics: true,
})
.withAppStateController({
pna25Acknowledged: true,
})
.build(),
testSpecificMock: async (server: Mockttp) => [
await mockAuthService(server),
Expand Down Expand Up @@ -159,77 +165,67 @@ describe('Profile Metrics', function () {
});
});

describe('when MetaMetrics is disabled or the feature flag is off', function () {
it('does not send existing accounts to the API on wallet unlock if MetaMetrics is disabled', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder()
.withMetaMetricsController({
participateInMetaMetrics: false,
})
.build(),
testSpecificMock: async (server: Mockttp) => [
await mockAuthService(server),
await mockSendFeatureFlag(true)(server),
],
title: this.test?.fullTitle(),
},
async ({
driver,
mockedEndpoint,
}: {
driver: Driver;
mockedEndpoint: MockedEndpoint[];
}) => {
await loginWithBalanceValidation(driver);

await driver.delay(5000);

const [authCall] = mockedEndpoint;
const requests = await authCall.getSeenRequests();
assert.equal(
requests.length,
0,
'Expected no requests to the auth API.',
[
{
title: 'when MetaMetrics is disabled',
participateInMetaMetrics: false,
featureFlag: true,
pna25Acknowledged: true,
},
{
title: 'when the relevant feature flag is off',
participateInMetaMetrics: true,
featureFlag: false,
pna25Acknowledged: true,
},
{
title: 'when the user has not acknowledged the privacy change',
participateInMetaMetrics: true,
featureFlag: true,
pna25Acknowledged: false,
},
].forEach(
({ title, participateInMetaMetrics, featureFlag, pna25Acknowledged }) => {
describe(title, function () {
it('does not send existing accounts to the API on wallet unlock', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder()
.withMetaMetricsController({
participateInMetaMetrics,
})
.withAppStateController({
pna25Acknowledged,
})
.build(),
testSpecificMock: async (server: Mockttp) => [
await mockAuthService(server),
await mockSendFeatureFlag(featureFlag)(server),
],
title: this.test?.fullTitle(),
},
async ({
driver,
mockedEndpoint,
}: {
driver: Driver;
mockedEndpoint: MockedEndpoint[];
}) => {
await loginWithBalanceValidation(driver);

await driver.delay(5000);

const [authCall] = mockedEndpoint;
const requests = await authCall.getSeenRequests();
assert.equal(
requests.length,
0,
'Expected no requests to the auth API.',
);
},
);
},
);
});

it('does not send existing accounts to the API on wallet unlock if feature flag is disabled', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder()
.withMetaMetricsController({
participateInMetaMetrics: true,
})
.build(),
testSpecificMock: async (server: Mockttp) => [
await mockAuthService(server),
await mockSendFeatureFlag(false)(server),
],
title: this.test?.fullTitle(),
},
async ({
driver,
mockedEndpoint,
}: {
driver: Driver;
mockedEndpoint: MockedEndpoint[];
}) => {
await loginWithBalanceValidation(driver);

await driver.delay(5000);

const [authCall] = mockedEndpoint;
const requests = await authCall.getSeenRequests();
assert.equal(
requests.length,
0,
'Expected no requests to the auth API.',
);
},
);
});
});
});
});
},
);
});
Loading