Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions test/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,8 @@ export type ToastId =
| 'ExpiredLightningToast'
| 'DevModeEnabledToast'
| 'DevModeDisabledToast'
| 'PaykitUiEnabledToast'
| 'PaykitUiDisabledToast'
| 'InsufficientSpendingToast'
| 'InsufficientSavingsToast'
| 'ProfilePubkyCopiedToast'
Expand Down
10 changes: 10 additions & 0 deletions test/helpers/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
56 changes: 56 additions & 0 deletions test/helpers/paykit.ts
Original file line number Diff line number Diff line change
@@ -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();
}
}
2 changes: 2 additions & 0 deletions test/specs/paykit.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () => {
Expand Down
3 changes: 3 additions & 0 deletions test/specs/pubky-profile.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -251,6 +253,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => {
await reinstallApp();
currentWallet = null;
await completeOnboarding();
await enablePaykitUi();
await createProfile({ name: 'Bob Wallet B' });
currentWallet = 'B';

Expand Down