Skip to content

Commit

Permalink
Tests: Add message test (safe-global#4389)
Browse files Browse the repository at this point in the history
* Add message test
  • Loading branch information
mike10ca authored Oct 17, 2024
1 parent d4a352d commit 6e5250c
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 32 deletions.
30 changes: 30 additions & 0 deletions cypress/e2e/pages/safeapps.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const deleteBatchBtn = 'button[title="Delete Batch"]'
const appModal = '[data-testid="app-info-modal"]'
export const safeAppsList = '[data-testid="apps-list"]'
const openSafeAppBtn = '[data-testid="open-safe-app-btn"]'
const appMessageInput = 'input[placeholder="Message"]'

const addBtnStr = /add/i
const noAppsStr = /no Safe Apps found/i
Expand Down Expand Up @@ -90,6 +91,10 @@ export const warningStr = 'Warning'
export const transferStr = 'Transfer'
export const successStr = 'Success'
export const failedStr = 'Failed'
const blindSigningStr = 'This request involves blind signing'
const enableBlindSigningStr = 'Enable blind signing'
const blindSigningStr2 = 'blind signing'
const signBtnStr = 'Sign'

export const dummyTxStr = 'Trigger dummy tx (safe.txs.send)'
export const signOnchainMsgStr = 'Sign message (on-chain)'
Expand Down Expand Up @@ -135,6 +140,31 @@ export function triggetOffChainTx() {
cy.contains(dummyTxStr).click()
}

export function verifyBlindSigningEnabled(option) {
if (option) {
cy.contains(blindSigningStr).should('be.visible')
} else {
cy.contains(blindSigningStr).should('not.exist')
}
}

export function clickOnBlindSigningOption() {
cy.contains(blindSigningStr2).click()
cy.contains(enableBlindSigningStr).click()
}

export function triggetSignMsg() {
cy.contains(signOnchainMsgStr).click()
}

export function enterMessage(msg) {
cy.get(appMessageInput).type(msg)
}

export function verifySignBtnDisabled() {
cy.get('button').contains(signBtnStr).should('be.disabled')
}

export function triggetOnChainTx() {
cy.contains(signOnchainMsgStr).click()
}
Expand Down
16 changes: 0 additions & 16 deletions cypress/e2e/prodhealthcheck/swaps_tokens.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,4 @@ describe('[PROD] Swaps token tests', () => {
})
},
)

it('Verify swap button are displayed in assets table and dashboard', () => {
assets.selectTokenList(assets.tokenListOptions.allTokens)
cy.wait(3000)
main.verifyElementsCount(swaps.assetsSwapBtn, 4)
cy.window().then((window) => {
window.localStorage.setItem(
constants.localStorageKeys.SAFE_v2__settings,
JSON.stringify(ls.safeSettings.slimitSettings),
)
})
cy.visit(constants.homeUrl + staticSafes.SEP_STATIC_SAFE_1)
cy.wait(3000)
main.verifyElementsCount(swaps.assetsSwapBtn, 4)
main.verifyElementsCount(swaps.dashboardSwapBtn, 1)
})
})
30 changes: 30 additions & 0 deletions cypress/e2e/regression/messages_popup.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,34 @@ describe('Messages popup window tests', () => {
msg_confirmation_modal.verifySafeAppInPopupWindow(safeApp)
msg_confirmation_modal.verifyMessagePresent(onchainMessage)
})

it('Verify warning message is displayed when 0x0000000 is used as a message', () => {
const msgHash = '0x0000000'
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,
)
cy.reload()
apps.clickOnApp(safeApp)
apps.clickOnOpenSafeAppBtn()
main.getIframeBody(iframeSelector).within(() => {
apps.enterMessage(msgHash)
apps.triggetSignMsg()
})
apps.verifyBlindSigningEnabled(true)
apps.clickOnBlindSigningOption()
cy.visit(constants.appsCustomUrl + staticSafes.SEP_STATIC_SAFE_10)
apps.clickOnApp(safeApp)
apps.clickOnOpenSafeAppBtn()
main.getIframeBody(iframeSelector).within(() => {
apps.enterMessage(msgHash)
apps.triggetSignMsg()
})
apps.verifyBlindSigningEnabled(false)
apps.verifySignBtnDisabled()
})
})
1 change: 1 addition & 0 deletions cypress/e2e/regression/swaps.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ describe('Swaps tests', () => {
navigation.clickOnDisconnectBtn()
wallet.connectSigner(signer3)

cy.wait(5000)
create_tx.verifyConfirmTransactionBtnIsVisible()
create_tx.clickOnConfirmTransactionBtn()
create_tx.clickOnNoLaterOption()
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/regression/swaps_tokens.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe('[SMOKE] Swaps token tests', () => {
},
)

// Added to prod
it('Verify swap button are displayed in assets table and dashboard', () => {
assets.selectTokenList(assets.tokenListOptions.allTokens)
main.verifyElementsCount(swaps.assetsSwapBtn, 4)
Expand Down
10 changes: 0 additions & 10 deletions cypress/e2e/safe-apps/info_modal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,4 @@ describe('Info modal tests', () => {
safeapps.clickOnOpenSafeAppBtn()
safeapps.verifyDisclaimerIsDisplayed()
})

it('Verify info modal consent is stored when accepted', { defaultCommandTimeout: 20000 }, () => {
// Required to show disclaimer
cy.clearLocalStorage()
main.acceptCookies()
safeapps.clickOnApp(safeapps.transactionBuilderStr)
safeapps.clickOnOpenSafeAppBtn()
safeapps.verifyDisclaimerIsDisplayed()
safeapps.verifyInfoModalAcceptance()
})
})
9 changes: 5 additions & 4 deletions cypress/e2e/smoke/messages_offchain.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const typeMessagesOffchain = msg_data.type.offChain

const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY
const signer2 = walletCredentials.OWNER_1_PRIVATE_KEY

describe('[SMOKE] Offchain Messages tests', () => {
before(async () => {
Expand Down Expand Up @@ -78,10 +79,10 @@ describe('[SMOKE] Offchain Messages tests', () => {
main.verifyTextVisibility(values)
})

// TODO: Clarify changes
it.skip('[SMOKE] Verify confirmation window is displayed for unsigned message', () => {
wallet.connectSigner(signer)
messages.clickOnMessageSignBtn(2)
it('[SMOKE] Verify confirmation window is displayed for unsigned message', () => {
cy.visit(constants.transactionsMessagesUrl + staticSafes.SEP_STATIC_SAFE_26)
wallet.connectSigner(signer2)
messages.clickOnMessageSignBtn(0)
msg_confirmation_modal.verifyConfirmationWindowTitle(modal.modalTitiles.confirmMsg)
msg_confirmation_modal.verifyMessagePresent(offchainMessage)
msg_confirmation_modal.clickOnMessageDetails()
Expand Down
3 changes: 2 additions & 1 deletion cypress/fixtures/safes/static.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"ZKSYNC_STATIC_SAFE_22": "zksync:0x49136c0270c5682FFbb38Cb29Ecf0563b2E1F9f6",
"SEP_STATIC_SAFE_23": "sep:0x589d862CE2d519d5A862066bB923da0564c3D2EA",
"SEP_STATIC_SAFE_24": "sep:0x49DC5764961DA4864DC5469f16BC68a0F765f2F2",
"SEP_STATIC_SAFE_25": "sep:0x4ECFAa2E8cb4697bCD27bdC9Ce3E16f03F73124F"
"SEP_STATIC_SAFE_25": "sep:0x4ECFAa2E8cb4697bCD27bdC9Ce3E16f03F73124F",
"SEP_STATIC_SAFE_26": "sep:0x755428b02A458eD17fa93c86F6C3a2046F2c4C3C"
}

0 comments on commit 6e5250c

Please sign in to comment.