-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathpredict-geo-restriction.spec.ts
More file actions
169 lines (159 loc) · 6.38 KB
/
predict-geo-restriction.spec.ts
File metadata and controls
169 lines (159 loc) · 6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import { withFixtures } from '../../framework/fixtures/FixtureHelper';
import FixtureBuilder from '../../framework/fixtures/FixtureBuilder';
import { SmokePredictions } from '../../tags';
import { loginToApp } from '../../flows/wallet.flow';
import TabBarComponent from '../../page-objects/wallet/TabBarComponent';
import WalletActionsBottomSheet from '../../page-objects/wallet/WalletActionsBottomSheet';
import PredictMarketList from '../../page-objects/Predict/PredictMarketList';
import PredictUnavailableView from '../../page-objects/Predict/PredictUnavailableView';
import Assertions from '../../framework/Assertions';
import WalletView from '../../page-objects/wallet/WalletView';
import PredictDetailsPage from '../../page-objects/Predict/PredictDetailsPage';
import {
remoteFeatureFlagHomepageSectionsV1Enabled,
remoteFeatureFlagPredictEnabled,
} from '../../api-mocking/mock-responses/feature-flags-mocks';
import { Mockttp } from 'mockttp';
import { device } from 'detox';
import { setupRemoteFeatureFlagsMock } from '../../api-mocking/helpers/remoteFeatureFlagsHelper';
import {
POLYMARKET_MARKET_FEEDS_MOCKS,
POLYMARKET_COMPLETE_MOCKS,
POLYMARKET_GEO_BLOCKED_MOCKS,
} from '../../api-mocking/mock-responses/polymarket/polymarket-mocks';
import PredictAddFunds from '../../page-objects/Predict/PredictAddFunds';
import { getEventsPayloads } from '../../helpers/analytics/helpers';
import SoftAssert from '../../framework/SoftAssert';
import { SPURS_PELICANS_POSITION_ID } from '../../api-mocking/mock-responses/polymarket/polymarket-constants';
import {
geoBlockedPredictActionExpectations,
geoBlockedCashoutExpectations,
geoBlockedDepositExpectations,
} from '../../helpers/analytics/expectations/predict-geo-restriction.analytics';
//Enable the Predictions feature flag and force Polymarket geoblock
const setupGeoBlockedBase = async (mockServer: Mockttp) => {
await setupRemoteFeatureFlagsMock(mockServer, {
...remoteFeatureFlagPredictEnabled(true),
...remoteFeatureFlagHomepageSectionsV1Enabled(),
carouselBanners: false,
exploreSectionsOrder: {},
});
await POLYMARKET_MARKET_FEEDS_MOCKS(mockServer);
await POLYMARKET_GEO_BLOCKED_MOCKS(mockServer);
};
const PredictionGeoBlockedFeature = async (mockServer: Mockttp) => {
await setupGeoBlockedBase(mockServer);
};
const PredictionGeoBlockedWithPositionsFeature = async (
mockServer: Mockttp,
) => {
await setupGeoBlockedBase(mockServer);
await POLYMARKET_COMPLETE_MOCKS(mockServer);
};
describe(
SmokePredictions('Predictions - Geo Restriction modal displays '),
() => {
it('when clicking Yes/No to the feeds', async () => {
await withFixtures(
{
fixture: new FixtureBuilder().withMetaMetricsOptIn().build(),
restartDevice: true,
testSpecificMock: PredictionGeoBlockedFeature,
analyticsExpectations: geoBlockedPredictActionExpectations,
},
async () => {
await loginToApp();
await TabBarComponent.tapActions();
await WalletActionsBottomSheet.tapPredictButton();
await Assertions.expectElementToBeVisible(
PredictMarketList.container,
{
description: 'Predict market list container should be visible',
},
);
await device.disableSynchronization();
await PredictMarketList.tapCategoryTab('new');
await Assertions.expectElementToBeVisible(
PredictMarketList.container,
{
description:
'Market list is visible prior to attempting a trade from feed',
},
);
await PredictMarketList.tapYesBasedOnCategoryAndIndex('new', 1);
await PredictUnavailableView.expectVisible();
await PredictUnavailableView.tapGotIt();
await Assertions.expectElementToBeVisible(
PredictMarketList.container,
{
description:
'Returned to market list; modal was displayed over feed interaction',
},
);
// Dismissing the geo modal can leave the feed scrolled or de-synced; re-select New
// so the first card's Yes/No row is back in view for Detox.
await PredictMarketList.tapCategoryTab('new');
await PredictMarketList.tapNoBasedOnCategoryAndIndex('new', 1);
await PredictUnavailableView.expectVisible();
await PredictUnavailableView.tapGotIt();
await device.enableSynchronization();
},
);
});
it('when clicking on cash out under positions', async () => {
await withFixtures(
{
fixture: new FixtureBuilder()
.withPolygon()
.withMetaMetricsOptIn()
.build(),
restartDevice: true,
testSpecificMock: PredictionGeoBlockedWithPositionsFeature,
analyticsExpectations: geoBlockedCashoutExpectations,
},
async () => {
await loginToApp();
await WalletView.scrollAndTapPredictionsPosition(
'Spurs vs. Pelicans',
);
await PredictDetailsPage.tapGameCashOutButton(
SPURS_PELICANS_POSITION_ID,
);
await PredictUnavailableView.expectVisible();
await PredictUnavailableView.tapGotIt();
},
);
});
it('when clicking Add funds from the Predictions balance', async () => {
await withFixtures(
{
fixture: new FixtureBuilder().withMetaMetricsOptIn().build(),
restartDevice: true,
testSpecificMock: PredictionGeoBlockedFeature,
analyticsExpectations: geoBlockedDepositExpectations,
},
async () => {
await loginToApp();
await TabBarComponent.tapActions();
await WalletActionsBottomSheet.tapPredictButton();
await Assertions.expectElementToBeVisible(
PredictDetailsPage.balanceCard,
{
description: 'Predict balance card is visible',
},
);
await PredictAddFunds.tapAddFunds();
await PredictUnavailableView.expectVisible();
await PredictUnavailableView.tapGotIt();
await Assertions.expectElementToBeVisible(
PredictDetailsPage.balanceCard,
{
description:
'Returned to Predictions tab; Unavailable modal dismissed after clicking Add funds',
},
);
},
);
});
},
);