Skip to content
7 changes: 3 additions & 4 deletions test/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@ export async function pasteIOSText(testId: string, text: string) {
export async function typeText(testId: string, text: string) {
const el = await elementById(testId);
await el.waitForDisplayed();
await sleep(500); // Allow time for the element to settle
await sleep(1000); // Allow time for the element to settle
await el.clearValue();
await sleep(500); // Allow time for the clear action to propagate
await sleep(1000); // Allow time for the clear action to propagate
await el.setValue(text);
}

Expand Down Expand Up @@ -1241,9 +1241,8 @@ export type ToastId =
| 'InsufficientSavingsToast'
| 'ProfilePubkyCopiedToast'
| 'ProfileUpdatedToast'
| 'ContactSavedToast'
| 'ContactUpdatedToast'
| 'ContactDeletedToast'
| 'ContactUpdatedToast'
| 'SendAmountExceededToast';

/** Wait for a toast by test id. Prefer `waitToDisappear` for iOS: success toasts live in a separate
Expand Down
2 changes: 0 additions & 2 deletions test/helpers/hardware-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export async function renameHardwareWalletFromSettings(currentLabel: string, new
});
await expectHardwareWalletInSettings(newLabel, { visible: true });
await expectHardwareWalletInSettings(currentLabel, { visible: false });

}

export async function expectHardwareSuggestion({ visible }: { visible: boolean }) {
Expand Down Expand Up @@ -333,4 +332,3 @@ async function dismissSpendingBalanceToastIfShown() {
console.info('→ SpendingBalanceReadyToast not shown after hardware transfer.');
}
}

19 changes: 9 additions & 10 deletions test/helpers/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function cleanupProfile(label: string) {
await deleteProfile();
console.info(`Cleaned up Pubky profile for ${label}`);
} catch (error) {
console.warn(`Could not cleanup Pubky profile for ${label}:`, error);
console.error(`Could not cleanup Pubky profile for ${label}:`, error);
}
}

Expand Down Expand Up @@ -151,12 +151,10 @@ export async function addContact({
pubky,
save = true,
firstContact = false,
waitToastToDisappear: waitToDisappear = driver.isIOS,
}: {
pubky: string;
save?: boolean;
firstContact?: boolean;
waitToastToDisappear?: boolean;
}): Promise<void> {
await openContacts();
await sleep(500);
Expand Down Expand Up @@ -186,8 +184,14 @@ export async function addContact({
await tap('AddContactAdd');
await elementById('AddContactSave').waitForDisplayed();
await tap('AddContactSave');
await waitForToast('ContactSavedToast', { waitToDisappear });
await elementById('ContactsAddButton').waitForDisplayed();
// Landing on contact details screen
await elementById('ContactViewName').waitForDisplayed();
await elementById('ContactPay').waitForDisplayed();
await elementById('ContactActivity').waitForDisplayed();
await elementById('ContactCopy').waitForDisplayed();
await elementById('ContactShare').waitForDisplayed();
await elementById('ContactDelete').waitForDisplayed();
await elementById('ContactAddTag').waitForDisplayed();
}

export async function verifyAddContactRoute(
Expand Down Expand Up @@ -221,11 +225,6 @@ export async function verifyAddContactRoute(
});
}

export async function discardAddContactRoute() {
await elementById('AddContactDiscard').waitForDisplayed();
await tap('AddContactDiscard');
}

/** Opens Contacts and waits for a row with test id `Contact_<publicKey>`. */
export async function verifyContactRowDisplayed(publicKey: string) {
await openContacts();
Expand Down
33 changes: 18 additions & 15 deletions test/specs/hardware-wallet.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,24 @@ describe('@hardware_wallet - Hardware Wallet', () => {
stopTrezorEmulator();
});

ciIt('@hardware_wallet_1 - Can connect, rename, show, and remove a Trezor emulator wallet', async () => {
await expectHardwareSuggestion({ visible: true });
await startHardwareWalletFlowFromSuggestion();
await completeHardwareWalletFlow(walletLabel);
await expectHardwareSuggestion({ visible: false });
await openHardwareWalletSettings();
await expectHardwareWalletInSettings(walletLabel, { visible: true });
await expectHardwareWalletOnHome(walletLabel, { visible: true });
await openHardwareWalletSettings();
await renameHardwareWalletFromSettings(walletLabel, renamedWalletLabel);
await expectHardwareWalletOnHome(renamedWalletLabel, { visible: true });
await removeHardwareWalletFromSettings(renamedWalletLabel);
await expectHardwareWalletInSettings(renamedWalletLabel, { visible: false });
await expectHardwareWalletOnHome(renamedWalletLabel, { visible: false });
});
ciIt(
'@hardware_wallet_1 - Can connect, rename, show, and remove a Trezor emulator wallet',
async () => {
await expectHardwareSuggestion({ visible: true });
await startHardwareWalletFlowFromSuggestion();
await completeHardwareWalletFlow(walletLabel);
await expectHardwareSuggestion({ visible: false });
await openHardwareWalletSettings();
await expectHardwareWalletInSettings(walletLabel, { visible: true });
await expectHardwareWalletOnHome(walletLabel, { visible: true });
await openHardwareWalletSettings();
await renameHardwareWalletFromSettings(walletLabel, renamedWalletLabel);
await expectHardwareWalletOnHome(renamedWalletLabel, { visible: true });
await removeHardwareWalletFromSettings(renamedWalletLabel);
await expectHardwareWalletInSettings(renamedWalletLabel, { visible: false });
await expectHardwareWalletOnHome(renamedWalletLabel, { visible: false });
}
);

ciIt('@hardware_wallet_2 - Can receive onchain funds to hardware wallet', async () => {
const sats = 15_000;
Expand Down
6 changes: 2 additions & 4 deletions test/specs/paykit.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
addContact,
cleanupProfile,
createProfile,
discardAddContactRoute,
verifyAddContactRoute,
verifyContactRowDisplayed,
} from '../helpers/profile';
Expand Down Expand Up @@ -81,20 +80,19 @@ describe('@pubky @paykit - Public payments', () => {
await verifyAddContactRoute(unsavedPaykitContact.pubky, {
ableToPay: unsavedPaykitContact.ableToPay,
});
await discardAddContactRoute();
await doNavigationClose();

await enterAddressViaScanPrompt(unsavedPaykitContact.pubky, {
acceptCameraPermission: false,
});
await verifyAddContactRoute(unsavedPaykitContact.pubky, {
ableToPay: unsavedPaykitContact.ableToPay,
});
await discardAddContactRoute();
await doNavigationClose();

await addContact({
pubky: savedPaykitContact.pubky,
firstContact: true,
waitToastToDisappear: true,
});
await verifyContactRowDisplayed(savedPaykitContact.pubky);
await tap(`Contact_${savedPaykitContact.pubky}`);
Expand Down
21 changes: 15 additions & 6 deletions test/specs/pubky-profile.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
cleanupProfile,
deleteContact,
deleteProfile,
discardAddContactRoute,
openEditProfile,
readPubkyFromProfileCopy,
removeEditProfileLinkAt,
Expand Down Expand Up @@ -199,7 +198,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => {
await verifyAddContactRoute(firstStagingContact.pubky, {
ableToPay: firstStagingContact.ableToPay,
});
await discardAddContactRoute();
await doNavigationClose();

// route unsaved pubky from QR scanner prompt
await enterAddressViaScanPrompt(firstStagingContact.pubky, {
Expand All @@ -208,7 +207,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => {
await verifyAddContactRoute(firstStagingContact.pubky, {
ableToPay: firstStagingContact.ableToPay,
});
await discardAddContactRoute();
await doNavigationClose();

// add valid contacts
for (const [i, stagingContact] of STAGING_TEST_CONTACTS.entries()) {
Expand Down Expand Up @@ -251,13 +250,17 @@ describe('@pubky @pubky_profile - Pubky profile', () => {

try {
// Wallet A: create and customize profile, then capture seed.
console.log('Wallet A: create and customize profile, then capture seed.');
const { pubky: pubkyA } = await createProfile({ name: 'Alice Wallet A' });
currentWallet = 'A';
await updateMyProfile(detailsA);
await verifyMyProfileDetails(detailsA);
seedA = await getSeed();

// Wallet B: fresh install + onboarding, create profile, then add wallet A as contact.
console.log(
'Wallet B: fresh install + onboarding, create profile, then add wallet A as contact.'
);
await reinstallApp();
currentWallet = null;
await completeOnboarding();
Expand All @@ -278,10 +281,16 @@ describe('@pubky @pubky_profile - Pubky profile', () => {
await updateContactProfile({ pubky: pubkyA, details: detailsAUpdated });
await verifyContactDetails({ pubky: pubkyA, details: detailsAUpdated });

await cleanupProfile('@pubky_profile_4 wallet B');
currentWallet = null;
// temp: turn on after fix
// https://github.com/synonymdev/bitkit-android/pull/1108
// https://github.com/synonymdev/bitkit-ios/pull/640
// await deleteProfile();
// currentWallet = null;

// Restore wallet A and verify wallet A profile is unchanged by wallet B contact edits.
console.log(
'Wallet A: restore wallet A and verify wallet A profile is unchanged by wallet B contact edits.'
);
await restoreWallet(seedA);
await enablePaykitUi();
currentWallet = 'A';
Expand All @@ -297,7 +306,7 @@ describe('@pubky @pubky_profile - Pubky profile', () => {
await enablePaykitUi();
await cleanupProfile('@pubky_profile_4 wallet A');
} catch (error) {
console.warn('Could not restore and cleanup wallet A profile:', error);
console.error('Could not restore and cleanup wallet A profile:', error);
}
}
}
Expand Down