-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tests: update message tests * tests: disable eslint for localstorage file * tests: update test titles
- Loading branch information
Showing
13 changed files
with
200 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { messageItem } from './create_tx.pages' | ||
const onchainMsgInput = 'input[placeholder*="Message"]' | ||
|
||
export function enterOnchainMessage(msg) { | ||
cy.get(onchainMsgInput).type(msg) | ||
} | ||
|
||
export function clickOnMessageSignBtn(index) { | ||
cy.get(messageItem) | ||
.eq(index) | ||
.within(() => { | ||
cy.get('button').contains('Sign').click() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as modal from '../modals.page' | ||
import * as checkers from '../../../support/utils/checkers' | ||
import * as main from '../main.page' | ||
|
||
const messageHash = '[data-testid="message-hash"]' | ||
const messageDetails = '[data-testid="message-details"]' | ||
const messageInfobox = '[data-testid="message-infobox"]' | ||
|
||
const messageInfoBoxData = [ | ||
'Collect all the confirmations', | ||
'Confirmations (1 of 2)', | ||
'The signature will be submitted to the Safe App when the message is fully signed', | ||
] | ||
|
||
export function verifyConfirmationWindowTitle(title) { | ||
cy.get(modal.modalTitle).should('contain', title) | ||
} | ||
|
||
export function verifyMessagePresent(msg) { | ||
cy.get('textarea').should('contain', msg) | ||
} | ||
|
||
export function verifySafeAppInPopupWindow(safeApp) { | ||
cy.contains(safeApp) | ||
} | ||
|
||
export function verifyOffchainMessageHash(index) { | ||
cy.get(messageHash) | ||
.eq(index) | ||
.invoke('text') | ||
.then((text) => { | ||
if (!checkers.startsWith0x(text)) { | ||
throw new Error(`Message at index ${index} does not start with '0x': ${text}`) | ||
} | ||
}) | ||
} | ||
|
||
export function checkMessageInfobox() { | ||
cy.get(messageInfobox).within(() => { | ||
main.verifyTextVisibility(messageInfoBoxData) | ||
}) | ||
} | ||
|
||
export function clickOnMessageDetails() { | ||
cy.get(messageDetails).click() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import * as constants from '../../support/constants.js' | ||
import * as main from '../pages/main.page.js' | ||
import * as modal from '../pages/modals.page.js' | ||
import * as apps from '../pages/safeapps.pages.js' | ||
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js' | ||
import * as ls from '../../support/localstorage_data.js' | ||
import * as messages from '../pages/messages.pages.js' | ||
import * as msg_confirmation_modal from '../pages/modals/message_confirmation.pages.js' | ||
|
||
let staticSafes = [] | ||
const safeApp = 'Safe Test App' | ||
const onchainMessage = 'Message 1' | ||
let iframeSelector | ||
|
||
describe('Messages popup window tests', () => { | ||
before(async () => { | ||
staticSafes = await getSafes(CATEGORIES.static) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.clearLocalStorage() | ||
cy.visit(constants.appsCustomUrl + staticSafes.SEP_STATIC_SAFE_10) | ||
main.acceptCookies() | ||
iframeSelector = `iframe[id="iframe-${constants.safeTestAppurl}"]` | ||
}) | ||
|
||
it('Verify off-chain message popup window can be triggered', () => { | ||
main.addToLocalStorage( | ||
constants.localStorageKeys.SAFE_v2__customSafeApps_11155111, | ||
ls.customApps(constants.safeTestAppurl).safeTestApp, | ||
) | ||
main.addToLocalStorage( | ||
constants.localStorageKeys.SAFE_v2__SafeApps__browserPermissions, | ||
ls.appPermissions(constants.safeTestAppurl).grantedPermissions, | ||
) | ||
main.addToLocalStorage( | ||
constants.localStorageKeys.SAFE_v2__SafeApps__infoModal, | ||
ls.appPermissions(constants.safeTestAppurl).infoModalAccepted, | ||
) | ||
cy.reload() | ||
apps.clickOnApp(safeApp) | ||
main.getIframeBody(iframeSelector).within(() => { | ||
apps.triggetOffChainTx() | ||
}) | ||
msg_confirmation_modal.verifyConfirmationWindowTitle(modal.modalTitiles.confirmTx) | ||
msg_confirmation_modal.verifySafeAppInPopupWindow(safeApp) | ||
}) | ||
|
||
it('Verify on-chain message popup window can be triggered', () => { | ||
main.addToLocalStorage( | ||
constants.localStorageKeys.SAFE_v2__customSafeApps_11155111, | ||
ls.customApps(constants.safeTestAppurl).safeTestApp, | ||
) | ||
main.addToLocalStorage( | ||
constants.localStorageKeys.SAFE_v2__SafeApps__browserPermissions, | ||
ls.appPermissions(constants.safeTestAppurl).grantedPermissions, | ||
) | ||
main.addToLocalStorage( | ||
constants.localStorageKeys.SAFE_v2__SafeApps__infoModal, | ||
ls.appPermissions(constants.safeTestAppurl).infoModalAccepted, | ||
) | ||
cy.reload() | ||
apps.clickOnApp(safeApp) | ||
main.getIframeBody(iframeSelector).within(() => { | ||
messages.enterOnchainMessage(onchainMessage) | ||
apps.triggetOnChainTx() | ||
}) | ||
msg_confirmation_modal.verifyConfirmationWindowTitle(modal.modalTitiles.confirmMsg) | ||
msg_confirmation_modal.verifySafeAppInPopupWindow(safeApp) | ||
msg_confirmation_modal.verifyMessagePresent(onchainMessage) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export function startsWith0x(str) { | ||
const pattern = /^0x/ | ||
return pattern.test(str) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters