diff --git a/tests/api-mocking/mock-responses/defaults/polymarket-apis.ts b/tests/api-mocking/mock-responses/defaults/polymarket-apis.ts index f16e490e344..c9dfe605915 100644 --- a/tests/api-mocking/mock-responses/defaults/polymarket-apis.ts +++ b/tests/api-mocking/mock-responses/defaults/polymarket-apis.ts @@ -38,6 +38,23 @@ export const POLYMARKET_API_MOCKS = { responseCode: 200, response: { events: [] }, }, + { + urlEndpoint: /^https:\/\/gamma-api\.polymarket\.com\/events\/\d+(\?.*)?$/, + responseCode: 200, + response: { + id: '1', + slug: 'mock-prediction-event', + title: 'Mock prediction event', + description: 'E2E mock event', + icon: 'https://polymarket.com/icon.png', + closed: false, + series: [], + markets: [], + tags: [], + liquidity: 0, + volume: 0, + }, + }, // gamma-api: markets list { urlEndpoint: /^https:\/\/gamma-api\.polymarket\.com\/markets(\?.*)?$/, diff --git a/tests/api-mocking/mock-responses/trending-api-mocks.ts b/tests/api-mocking/mock-responses/trending-api-mocks.ts index 71d54eb4229..cccbd116323 100644 --- a/tests/api-mocking/mock-responses/trending-api-mocks.ts +++ b/tests/api-mocking/mock-responses/trending-api-mocks.ts @@ -164,8 +164,9 @@ export const TRENDING_API_MOCKS: MockEventsObject = { { // Event details fetched when user taps a prediction row in the trending feed. // Returns the same Bitcoin event payload as /events/pagination so the detail - // screen renders without crashing. - urlEndpoint: /https:\/\/gamma-api\.polymarket\.com\/events\/1(\?.*)?$/, + // screen renders without crashing. Matches any numeric event id (highlights, + // prefetch) — not only id "1". + urlEndpoint: /https:\/\/gamma-api\.polymarket\.com\/events\/\d+(\?.*)?$/, responseCode: 200, response: { id: '1', diff --git a/tests/flows/wallet.flow.ts b/tests/flows/wallet.flow.ts index e6a7a53ff90..554e6c83e9e 100644 --- a/tests/flows/wallet.flow.ts +++ b/tests/flows/wallet.flow.ts @@ -40,7 +40,7 @@ import PlaywrightUtilities from '../framework/PlaywrightUtilities'; import AccountListBottomSheet from '../page-objects/wallet/AccountListBottomSheet'; import MetaMetricsOptInView from '../page-objects/Onboarding/MetaMetricsOptInView'; import PredictModalView from '../page-objects/Predict/PredictModalView'; - +import OnboardingInterestQuestionnaireView from '../page-objects/Onboarding/OnboardingInterestQuestionnaireView'; const logger = createLogger({ name: 'WalletFlow', }); @@ -231,6 +231,9 @@ export const importWalletWithRecoveryPhrase = async ({ await MetaMetricsOptInView.tapAgreeButton(); } + if (optInToMetrics) { + await OnboardingInterestQuestionnaireView.tapContinueButton(); + } //'Should dismiss Enable device Notifications checks alert' await Assertions.expectElementToBeVisible(OnboardingSuccessView.container, { description: 'Onboarding Success View should be visible', @@ -342,6 +345,10 @@ export const CreateNewWallet = async ({ await MetaMetricsOptInView.tapAgreeButton(); await device.disableSynchronization(); // Detox is hanging after wallet creation + if (optInToMetrics) { + await OnboardingInterestQuestionnaireView.tapContinueButton(); + } + await Assertions.expectElementToBeVisible(OnboardingSuccessView.container, { description: 'Onboarding Success View should be visible', }); diff --git a/tests/framework/fixtures/json/onboarding-fixture.json b/tests/framework/fixtures/json/onboarding-fixture.json index 995fc13ee26..1acca867b3b 100644 --- a/tests/framework/fixtures/json/onboarding-fixture.json +++ b/tests/framework/fixtures/json/onboarding-fixture.json @@ -1,3 +1,5 @@ { - "asyncState": {} + "asyncState": { + "@MetaMask:AnalyticsId": "00000000-0000-4000-8000-000000000000" + } } diff --git a/tests/page-objects/Onboarding/OnboardingInterestQuestionnaireView.ts b/tests/page-objects/Onboarding/OnboardingInterestQuestionnaireView.ts new file mode 100644 index 00000000000..7f32ba51570 --- /dev/null +++ b/tests/page-objects/Onboarding/OnboardingInterestQuestionnaireView.ts @@ -0,0 +1,66 @@ +import { OnboardingInterestQuestionnaireTestIds } from '../../../app/components/Views/OnboardingInterestQuestionnaire/OnboardingInterestQuestionnaire.testIds'; +import Matchers from '../../framework/Matchers'; +import { + encapsulated, + EncapsulatedElementType, +} from '../../framework/EncapsulatedElement'; +import PlaywrightMatchers from '../../framework/PlaywrightMatchers'; +import UnifiedGestures from '../../framework/UnifiedGestures'; + +type InterestOptionId = + | 'buy_and_sell_crypto' + | 'consolidate_wallets' + | 'advanced_trades' + | 'predict_sports_events' + | 'crypto_as_money' + | 'connect_apps_sites'; + +class OnboardingInterestQuestionnaireView { + get container(): EncapsulatedElementType { + return encapsulated({ + detox: () => + Matchers.getElementByID(OnboardingInterestQuestionnaireTestIds.SCREEN), + appium: () => + PlaywrightMatchers.getElementById( + OnboardingInterestQuestionnaireTestIds.SCREEN, + { exact: true }, + ), + }); + } + + get continueButton(): EncapsulatedElementType { + return encapsulated({ + detox: () => + Matchers.getElementByID( + OnboardingInterestQuestionnaireTestIds.CONTINUE_BUTTON, + ), + appium: () => + PlaywrightMatchers.getElementById( + OnboardingInterestQuestionnaireTestIds.CONTINUE_BUTTON, + { exact: true }, + ), + }); + } + + getOptionById(id: InterestOptionId): EncapsulatedElementType { + const testID = `${OnboardingInterestQuestionnaireTestIds.OPTION_PREFIX}${id}`; + return encapsulated({ + detox: () => Matchers.getElementByID(testID), + appium: () => PlaywrightMatchers.getElementById(testID, { exact: true }), + }); + } + + async tapContinueButton(): Promise { + await UnifiedGestures.waitAndTap(this.continueButton, { + description: 'Onboarding Interest Questionnaire Continue Button', + }); + } + + async tapOption(id: InterestOptionId): Promise { + await UnifiedGestures.waitAndTap(this.getOptionById(id), { + description: `Onboarding Interest Questionnaire Option: ${id}`, + }); + } +} + +export default new OnboardingInterestQuestionnaireView();