forked from safe-global/safe-wallet-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: add tests for messages (safe-global#3677)
* tests: add tests for messages
- Loading branch information
Showing
8 changed files
with
208 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,74 @@ | ||
import * as constants from '../../support/constants.js' | ||
import * as main from '../pages/main.page.js' | ||
import * as createTx from '../pages/create_tx.pages.js' | ||
import * as msg_data from '../../fixtures/txmessages_data.json' | ||
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js' | ||
|
||
let staticSafes = [] | ||
|
||
const typeMessagesGeneral = msg_data.type.general | ||
const typeMessagesOffchain = msg_data.type.offChain | ||
|
||
describe('Offchain Messages tests', () => { | ||
before(async () => { | ||
staticSafes = await getSafes(CATEGORIES.static) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.clearLocalStorage() | ||
cy.visit(constants.transactionsMessagesUrl + staticSafes.SEP_STATIC_SAFE_10) | ||
main.acceptCookies() | ||
}) | ||
|
||
it('Verify summary for off-chain unsigned messages', () => { | ||
createTx.verifySummaryByIndex( | ||
0, | ||
[typeMessagesGeneral.sign, typeMessagesGeneral.oneOftwo, typeMessagesOffchain.walletConnect], | ||
typeMessagesOffchain.altTmage, | ||
) | ||
createTx.verifySummaryByIndex( | ||
2, | ||
[typeMessagesGeneral.sign, typeMessagesGeneral.oneOftwo, typeMessagesOffchain.walletConnect], | ||
typeMessagesOffchain.altTmage, | ||
) | ||
}) | ||
|
||
it('Verify summary for off-chain signed messages', () => { | ||
createTx.verifySummaryByIndex( | ||
1, | ||
[typeMessagesGeneral.confirmed, typeMessagesGeneral.twoOftwo, typeMessagesOffchain.walletConnect], | ||
typeMessagesOffchain.altTmage, | ||
) | ||
createTx.verifySummaryByIndex( | ||
3, | ||
[typeMessagesGeneral.confirmed, typeMessagesGeneral.twoOftwo, typeMessagesOffchain.walletConnect], | ||
typeMessagesOffchain.altTmage, | ||
) | ||
}) | ||
|
||
it('Verify exapanded details for simple off-chain message', () => { | ||
createTx.clickOnTransactionItemByIndex(2) | ||
cy.contains(typeMessagesOffchain.message2).should('be.visible') | ||
}) | ||
|
||
it('Verify exapanded details for EIP 712 off-chain message', () => { | ||
const jsonString = createTx.messageNestedStr | ||
const values = [ | ||
typeMessagesOffchain.name, | ||
typeMessagesOffchain.testStringNested, | ||
typeMessagesOffchain.EIP712Domain, | ||
typeMessagesOffchain.message3, | ||
] | ||
|
||
createTx.clickOnTransactionItemByIndex(1) | ||
cy.get(createTx.txRowTitle) | ||
.next() | ||
.then(($section) => { | ||
expect($section.text()).to.include(jsonString) | ||
const count = $section.text().split(jsonString).length - 1 | ||
expect(count).to.eq(3) | ||
}) | ||
|
||
main.verifyTextVisibility(values) | ||
}) | ||
}) |
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,57 @@ | ||
import * as constants from '../../support/constants.js' | ||
import * as main from '../pages/main.page.js' | ||
import * as createTx from '../pages/create_tx.pages.js' | ||
import * as msg_data from '../../fixtures/txmessages_data.json' | ||
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js' | ||
|
||
let staticSafes = [] | ||
|
||
const typeMessagesOnchain = msg_data.type.onChain | ||
|
||
describe('Onchain Messages tests', () => { | ||
before(async () => { | ||
staticSafes = await getSafes(CATEGORIES.static) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.clearLocalStorage() | ||
cy.visit(constants.transactionsHistoryUrl + staticSafes.SEP_STATIC_SAFE_10) | ||
main.acceptCookies() | ||
}) | ||
|
||
it('Verify exapanded details for signed on-chain message', () => { | ||
createTx.clickOnTransactionItemByName(typeMessagesOnchain.contractName) | ||
createTx.verifyExpandedDetails([ | ||
typeMessagesOnchain.contractName, | ||
typeMessagesOnchain.contractAddress, | ||
typeMessagesOnchain.delegateCall, | ||
]) | ||
}) | ||
|
||
it('Verify exapanded details for unsigned on-chain message', () => { | ||
cy.visit(constants.transactionQueueUrl + staticSafes.SEP_STATIC_SAFE_10) | ||
createTx.clickOnTransactionItemByName(typeMessagesOnchain.contractName) | ||
createTx.verifyExpandedDetails([ | ||
typeMessagesOnchain.contractName, | ||
typeMessagesOnchain.contractAddress, | ||
typeMessagesOnchain.delegateCall, | ||
]) | ||
}) | ||
|
||
it('Verify summary for unsigned on-chain message', () => { | ||
cy.visit(constants.transactionQueueUrl + staticSafes.SEP_STATIC_SAFE_10) | ||
createTx.verifySummaryByName( | ||
typeMessagesOnchain.contractName, | ||
[typeMessagesOnchain.oneOftwo, typeMessagesOnchain.signMessage], | ||
typeMessagesOnchain.altTmage, | ||
) | ||
}) | ||
|
||
it('Verify summary for signed on-chain message', () => { | ||
createTx.verifySummaryByName( | ||
typeMessagesOnchain.contractName, | ||
[typeMessagesOnchain.success, typeMessagesOnchain.signMessage], | ||
typeMessagesOnchain.altTmage, | ||
) | ||
}) | ||
}) |
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,33 @@ | ||
{ | ||
"type": { | ||
"general": { | ||
"confirmed": "Confirmed", | ||
"sign": "Sign", | ||
"oneOftwo": "1 out of 2", | ||
"twoOftwo": "2 out of 2" | ||
}, | ||
"offChain": { | ||
"walletConnect": "WalletConnect", | ||
"altTmage": "Message type", | ||
"sign": "Sign", | ||
"oneOftwo": "1 out of 2", | ||
"twoOftwo": "2 out of 2", | ||
"message2": "Test message 2 off-chain", | ||
"message3": "Test message 3 off-chain", | ||
"EIP712Domain": "EIP712Domain", | ||
"name": "EIP-1271 Example DApp", | ||
"testString": "Test message 3 off-chain", | ||
"testStringNested": "testNested(Nested)", | ||
"testNestedArray": "testNestedArray(Nested[])" | ||
}, | ||
"onChain": { | ||
"contractName": "Safe: SignMessageLib 1.3.0", | ||
"contractAddress": "sep:0x98FFBBF51bb33A056B08ddf711f289936AafF717", | ||
"delegateCall": "Delegate call", | ||
"signMessage": "signMessage", | ||
"oneOftwo": "1 out of 2", | ||
"altImage": "Safe: SignMessageLib 1.3.0", | ||
"success": "Success" | ||
} | ||
} | ||
} |
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