diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index 68f302a..982e6af 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -1166,6 +1166,8 @@ export type ToastId = | 'ExpiredLightningToast' | 'DevModeEnabledToast' | 'DevModeDisabledToast' + | 'PaykitUiEnabledToast' + | 'PaykitUiDisabledToast' | 'InsufficientSpendingToast' | 'InsufficientSavingsToast' | 'ProfilePubkyCopiedToast' diff --git a/test/helpers/navigation.ts b/test/helpers/navigation.ts index 1466dac..585a61d 100644 --- a/test/helpers/navigation.ts +++ b/test/helpers/navigation.ts @@ -25,6 +25,16 @@ export async function openSupport() { await sleep(500); } +/** + * Opens Dev Settings from the Advanced settings tab. + */ +export async function openDevSettings() { + await openSettings('advanced'); + await elementById('DevSettings').waitForDisplayed(); + await tap('DevSettings'); + await sleep(500); +} + /** * Opens the Contacts entry from the drawer menu. */ diff --git a/test/helpers/paykit.ts b/test/helpers/paykit.ts new file mode 100644 index 0000000..e8f8fe8 --- /dev/null +++ b/test/helpers/paykit.ts @@ -0,0 +1,56 @@ +import { elementById, elementByText, sleep, swipeFullScreen, tap, waitForToast } from './actions'; +import { doNavigationClose, openDevSettings } from './navigation'; + +const PAYKIT_UI_TOGGLE_ID = 'PaykitUiToggle'; + +async function scrollToPaykitToggle() { + for (let attempt = 0; attempt < 4; attempt++) { + if (await elementById(PAYKIT_UI_TOGGLE_ID).isDisplayed().catch(() => false)) { + return; + } + await swipeFullScreen('up'); + await sleep(300); + } + await elementById(PAYKIT_UI_TOGGLE_ID).waitForDisplayed(); +} + +async function tapPaykitUiToggle() { + await scrollToPaykitToggle(); + await tap(PAYKIT_UI_TOGGLE_ID); +} + +async function confirmPaykitUiEnableDialogIfPresent() { + const enableButton = elementByText('Enable', 'exact'); + if (await enableButton.isDisplayed().catch(() => false)) { + await enableButton.click(); + await sleep(500); + } +} + +async function leaveDevSettings() { + await tap('NavigationBack'); + await doNavigationClose(); +} + +export async function enablePaykitUi() { + await openDevSettings(); + await tapPaykitUiToggle(); + await confirmPaykitUiEnableDialogIfPresent(); + await waitForToast('PaykitUiEnabledToast', { waitToDisappear: driver.isIOS }); + await leaveDevSettings(); +} + +export async function disablePaykitUi() { + await openDevSettings(); + await tapPaykitUiToggle(); + await waitForToast('PaykitUiDisabledToast', { waitToDisappear: driver.isIOS }); + await leaveDevSettings(); +} + +export async function setPaykitUiEnabled(enabled: boolean) { + if (enabled) { + await enablePaykitUi(); + } else { + await disablePaykitUi(); + } +} diff --git a/test/specs/paykit.e2e.ts b/test/specs/paykit.e2e.ts index 7251338..d107acf 100644 --- a/test/specs/paykit.e2e.ts +++ b/test/specs/paykit.e2e.ts @@ -12,6 +12,7 @@ import { } from '../helpers/actions'; import { STAGING_PAYKIT_CONTACTS } from '../helpers/fixtures'; import { doNavigationClose, openContacts } from '../helpers/navigation'; +import { enablePaykitUi } from '../helpers/paykit'; import { addContact, cleanupProfile, @@ -60,6 +61,7 @@ describe('@pubky @paykit - Public payments', () => { beforeEach(async () => { await reinstallApp(); await completeOnboarding(); + await enablePaykitUi(); }); ciIt('@paykit_1 - Can pay saved contact via public on-chain endpoint', async () => { diff --git a/test/specs/pubky-profile.e2e.ts b/test/specs/pubky-profile.e2e.ts index 871114d..7775104 100644 --- a/test/specs/pubky-profile.e2e.ts +++ b/test/specs/pubky-profile.e2e.ts @@ -14,6 +14,7 @@ import { } from '../helpers/actions'; import { STAGING_TEST_CONTACTS } from '../helpers/fixtures'; import { openContacts, openProfile } from '../helpers/navigation'; +import { enablePaykitUi } from '../helpers/paykit'; import { addContact, ADD_CONTACT_INVALID_KEY_MESSAGE_SNIPPET, @@ -48,6 +49,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => { beforeEach(async () => { await reinstallApp(); await completeOnboarding(); + await enablePaykitUi(); }); // Section A: with no profile, every entry point must funnel into the choice screen. @@ -122,6 +124,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => { const seed = await getSeed(); await waitForBackup(); await restoreWallet(seed); + await enablePaykitUi(); await verifyMyProfileDetails(details); const pubkyAfterRestore = await readPubkyFromProfileCopy(); await expect(pubkyAfterRestore).toBe(pubky.trim()); @@ -251,6 +254,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => { await reinstallApp(); currentWallet = null; await completeOnboarding(); + await enablePaykitUi(); await createProfile({ name: 'Bob Wallet B' }); currentWallet = 'B'; @@ -272,6 +276,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => { // Restore wallet A and verify wallet A profile is unchanged by wallet B contact edits. await restoreWallet(seedA); + await enablePaykitUi(); currentWallet = 'A'; await verifyMyProfileDetails(detailsA); } finally { @@ -282,6 +287,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => { if (seedA !== undefined && currentWallet !== 'A') { try { await restoreWallet(seedA); + await enablePaykitUi(); await cleanupProfile('@pubky_profile_4 wallet A'); } catch (error) { console.warn('Could not restore and cleanup wallet A profile:', error);