Skip to content

Commit

Permalink
Merge pull request #197 from multiversx/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
arhtudormorar committed Mar 28, 2024
2 parents 6ac7a76 + 6aa7f98 commit 57408c7
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 977 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"@fortawesome/fontawesome-svg-core": "6.5.1",
"@fortawesome/free-solid-svg-icons": "6.5.1",
"@fortawesome/react-fontawesome": "0.2.0",
"@multiversx/sdk-core": "13.0.0-beta.4",
"@multiversx/sdk-dapp": "2.29.0-beta.6",
"@multiversx/sdk-core": "13.0.0-beta.9",
"@multiversx/sdk-dapp": "2.29.0-beta.20",
"@multiversx/sdk-network-providers": "2.2.1",
"axios": "1.6.5",
"classnames": "2.3.2",
Expand Down
28 changes: 27 additions & 1 deletion src/components/Layout/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ import { RouteNamesEnum } from 'localConstants';
import MultiversXLogo from '../../../assets/img/multiversx-logo.svg?react';
import { useMatch } from 'react-router-dom';

const callbackUrl = `${window.location.origin}/unlock`;
const onRedirect = undefined; // use this to redirect with useNavigate to a specific page after logout
const shouldAttemptReLogin = false; // use for special cases where you want to re-login after logout
const options = {
/*
* @param {boolean} [shouldBroadcastLogoutAcrossTabs=true]
* @description If your dApp supports multiple accounts on multiple tabs,
* this param will broadcast the logout event across all tabs.
*/
shouldBroadcastLogoutAcrossTabs: true,
/*
* @param {boolean} [hasConsentPopup=false]
* @description Set it to true if you want to perform async calls before logging out on Safari.
* It will open a consent popup for the user to confirm the action before leaving the page.
*/
hasConsentPopup: false
};

export const Header = () => {
const isLoggedIn = useGetIsLoggedIn();
const isUnlockRoute = Boolean(useMatch(RouteNamesEnum.unlock));
Expand All @@ -17,7 +35,15 @@ export const Header = () => {

const handleLogout = () => {
sessionStorage.clear();
logout(`${window.location.origin}/unlock`, undefined, false);
logout(
callbackUrl,
/*
* following are optional params. Feel free to remove them in your implementation
*/
onRedirect,
shouldAttemptReLogin,
options
);
};

return (
Expand Down
8 changes: 7 additions & 1 deletion src/helpers/signAndSendTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type SignAndSendTransactionsProps = {
transactionsDisplayInfo: TransactionsDisplayInfoType;
};

const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

export const signAndSendTransactions = async ({
transactions,
callbackRoute,
Expand All @@ -19,7 +21,11 @@ export const signAndSendTransactions = async ({
transactions,
transactionsDisplayInfo,
redirectAfterSign: false,
callbackRoute
callbackRoute,
// NOTE: performing async calls (eg: `await refreshAccount()`) before opening a new tab
// can cause the new tab to be blocked by Safari's popup blocker.
// To support this feature, we can set `hasConsentPopup` to `true`
hasConsentPopup: isSafari
});

return sessionId;
Expand Down
20 changes: 15 additions & 5 deletions wdio/test/specs/KeystoreScreen/Keystore.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,31 @@ describe('Sign with Keystore', () => {
await validateTransaction(TransactionIndexEnum.signBatch);
});

it('should close the wallet',async () => {
it('should close the wallet', async () => {
const loginData = {
selector: GlobalSelectorEnum.keystoreBtn,
file: GlobalDataEnum.keystoreFile,
adress: WalletAdressEnum.adress3
};
await login(loginData);
await $(GlobalSelectorEnum.batchBtn).click();
await browser.pause(500)
await browser.pause(2500);
await browser.switchWindow(GlobalDataEnum.walletWindow);
for(let i=0; i<3;i++) {
for (let i = 0; i < 3; i++) {
await $(GlobalSelectorEnum.accesPass).setValue(`invalid+${i}`);
await $(GlobalSelectorEnum.accesWalletBtn).click();
await browser.pause(2000)
await browser.pause(2000);
}
await checkOpenTabs()
await checkOpenTabs();
});

it('should sign transaction with PEM', async () => {
const loginData = {
selector: GlobalSelectorEnum.pemBtn,
file: GlobalDataEnum.invalidPem,
adress: WalletAdressEnum.adress3
};
await login(loginData);
await pingPongHandler(GlobalSelectorEnum.abiType);
});
});
1 change: 0 additions & 1 deletion wdio/test/specs/LedgerScreen/LedgerSpec.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('Check Ledger Modal', () => {
route: RoutesEnum.ledger
};
await openProviderModal(providerData);
await browser.pause(5000);
});
it('should properly open the ledger modal from dApp tab', async () => {
await $(GlobalSelectorEnum.ledgerBtn).click();
Expand Down
5 changes: 0 additions & 5 deletions wdio/test/specs/PemScreen/PemSpec.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('Sign transactions with PEM', () => {

it('should close the wallet window', async () => {
await closeWalletTab();
await browser.pause(60000);
});

it('should close the wallet window after refresh', async () => {
Expand All @@ -55,10 +54,6 @@ describe('Sign transactions with PEM', () => {
await notConfirmPem();
});

it('should sign transaction with PEM', async () => {
await pingPongHandler(GlobalSelectorEnum.abiType);
});

it('should sign msg with PEM', async () => {
await signMsg();
});
Expand Down
17 changes: 9 additions & 8 deletions wdio/test/utils/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export async function login(payload: {
const wallet = await $(`[data-testid*=${payload.adress}]`);

await $(GlobalSelectorEnum.crossWindowLoginBtn).click();
await browser.pause(1500);
await browser.pause(4500);
await browser.switchWindow(GlobalDataEnum.walletWindow);
await $(payload.selector).click();
await browser.pause(1500);
await browser.pause(2500);
await uploadFile(payload.file);
if (payload.selector === GlobalSelectorEnum.keystoreBtn) {
await confirmPass();
Expand Down Expand Up @@ -92,7 +92,7 @@ export async function openProviderModal(payload: {
route: string;
}) {
await $(GlobalSelectorEnum.crossWindowLoginBtn).click();
await browser.pause(2500);
await browser.pause(3500);
await browser.switchWindow(GlobalDataEnum.walletWindow);
await $(payload.selector).click();
await browser.pause(1000);
Expand All @@ -117,7 +117,7 @@ export async function validateTransaction(svgIndex: number) {
await svgElement[svgIndex].click();
await browser.switchWindow(GlobalDataEnum.explorerWindow);
const succesMsg = await $('span*=Succes');
await succesMsg.waitForDisplayed({ timeout: 60000 });
await succesMsg.waitForDisplayed({ timeout: 85000 });
}

export const checkWidgetMsg = async (msgArr: string[]) => {
Expand Down Expand Up @@ -153,11 +153,12 @@ export const scTransaction = async (type: string) => {
await browser.pause(3000);
await browser.switchWindow(GlobalDataEnum.walletWindow);
if (!(await $(GlobalSelectorEnum.accesPass).isDisplayed())) {
await confimPem(GlobalDataEnum.pemFile);
await $(GlobalSelectorEnum.accesWalletBtn).click();
await confimPem(GlobalDataEnum.invalidPem);
await $(GlobalSelectorEnum.signBtn).click();
} else {
await confirmPass();
await $(GlobalSelectorEnum.signBtn).click();
}
await confirmPass();
await $(GlobalSelectorEnum.signBtn).click();
await browser.pause(1500);
await browser.switchWindow(GlobalDataEnum.daapWindow);
await validateToast(GlobalSelectorEnum.toastSelector);
Expand Down
14 changes: 10 additions & 4 deletions wdio/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ export const config: Options.Testrunner = {

specs: ['./test/specs/**/*.ts'],
suites: {
smoke: ['./test/specs/PemScreen/PemSpec.e2e.ts']
smoke: [
// './test/specs/PemScreen/PemSpec.e2e.ts'
'./test/specs/KeystoreScreen/Keystore.e2e.ts'
]
},
// Patterns to exclude.
exclude: [],

maxInstances: 5,
maxInstances: 4,
specFileRetries: 1,
specFileRetriesDeferred: true,

Expand All @@ -30,15 +33,18 @@ export const config: Options.Testrunner = {
args: [
'--disable-infobars',
'--start-maximized',
'--no-sandbox',
'--headless=new'
'--no-sandbox'
// '--headless=new'
]
},
acceptInsecureCerts: true
},
{
browserName: 'safari'
}
// {
// browserName: 'firefox'
// }
],

logLevel: 'error',
Expand Down
Loading

0 comments on commit 57408c7

Please sign in to comment.