Skip to content

Commit

Permalink
Update tests (#2651)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca authored Oct 19, 2023
1 parent 8189cd7 commit d81ee92
Show file tree
Hide file tree
Showing 24 changed files with 482 additions and 528 deletions.
96 changes: 45 additions & 51 deletions cypress/e2e/safe-apps/apps_list.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,67 @@ import * as safeapps from '../pages/safeapps.pages'
const myCustomAppTitle = 'Cypress Test App'
const myCustomAppDescrAdded = 'Cypress Test App Description'

describe('The Safe Apps list', () => {
describe('Safe Apps tests', () => {
before(() => {
cy.clearLocalStorage()
cy.visit(constants.TEST_SAFE_2 + constants.appsUrl, { failOnStatusCode: false })
main.acceptCookies()
})

describe('When searching apps', () => {
it('should filter the list by app name', () => {
// Wait for /safe-apps response
cy.intercept('GET', constants.appsEndpoint).then(() => {
safeapps.typeAppName(constants.appNames.walletConnect)
safeapps.verifyLinkName(safeapps.linkNames.logo)
})
})

it('should filter the list by app description', () => {
safeapps.typeAppName(constants.appNames.customContract)
it('Verify app list can be filtered by app name [C56130]', () => {
// Wait for /safe-apps response
cy.intercept('GET', constants.appsEndpoint).then(() => {
safeapps.typeAppName(constants.appNames.walletConnect)
safeapps.verifyLinkName(safeapps.linkNames.logo)
})
})

it('should show a not found text when no match', () => {
safeapps.typeAppName(constants.appNames.noResults)
safeapps.verifyNoAppsTextPresent()
})
it('Verify app list can be filtered by app description [C56131]', () => {
safeapps.typeAppName(constants.appNames.customContract)
safeapps.verifyLinkName(safeapps.linkNames.logo)
})

describe('When browsing the apps list', () => {
it('should allow to pin apps', () => {
safeapps.clearSearchAppInput()
safeapps.pinApp(safeapps.pinWalletConnectStr)
safeapps.pinApp(safeapps.transactionBuilderStr)
safeapps.clickOnBookmarkedAppsTab()
safeapps.verifyAppCount(2)
})
it('Verify error message is displayed when no app found [C56132]', () => {
safeapps.typeAppName(constants.appNames.noResults)
safeapps.verifyNoAppsTextPresent()
})

it('should allow to unpin apps', () => {
safeapps.pinApp(safeapps.pinWalletConnectStr)
safeapps.pinApp(safeapps.transactionBuilderStr)
safeapps.verifyAppCount(0)
})
it('Verify apps can be pinned [C56133]', () => {
safeapps.clearSearchAppInput()
safeapps.pinApp(safeapps.pinWalletConnectStr)
safeapps.pinApp(safeapps.transactionBuilderStr)
safeapps.clickOnBookmarkedAppsTab()
safeapps.verifyAppCount(2)
})

describe('When adding a custom app', () => {
it('should show an error when the app manifest is invalid', () => {
cy.intercept('GET', constants.invalidAppUrl, {
name: constants.testAppData.name,
})
safeapps.clickOnCustomAppsTab()
safeapps.clickOnAddCustomApp()
safeapps.typeCustomAppUrl(constants.invalidAppUrl)
safeapps.verifyAppNotSupportedMsg()
})
it('Verify apps can be unpinned [C56134]', () => {
safeapps.pinApp(safeapps.pinWalletConnectStr)
safeapps.pinApp(safeapps.transactionBuilderStr)
safeapps.verifyAppCount(0)
})

it('should be added to the list within the custom apps section', () => {
cy.intercept('GET', constants.validAppUrlJson, {
name: constants.testAppData.name,
description: constants.testAppData.descr,
icons: [{ src: 'logo.svg', sizes: 'any', type: 'image/svg+xml' }],
})
it('Verify there is an error when the app manifest is invalid [C56135]', () => {
cy.intercept('GET', constants.invalidAppUrl, {
name: constants.testAppData.name,
})
safeapps.clickOnCustomAppsTab()
safeapps.clickOnAddCustomApp()
safeapps.typeCustomAppUrl(constants.invalidAppUrl)
safeapps.verifyAppNotSupportedMsg()
})

safeapps.typeCustomAppUrl(constants.validAppUrl)
safeapps.verifyAppTitle(myCustomAppTitle)
safeapps.acceptTC()
safeapps.clickOnAddBtn()
safeapps.verifyAppCount(1)
safeapps.verifyAppDescription(myCustomAppDescrAdded)
it('Verify an app can be added to the list within the custom apps section [C56136]', () => {
cy.intercept('GET', constants.validAppUrlJson, {
name: constants.testAppData.name,
description: constants.testAppData.descr,
icons: [{ src: 'logo.svg', sizes: 'any', type: 'image/svg+xml' }],
})

safeapps.typeCustomAppUrl(constants.validAppUrl)
safeapps.verifyAppTitle(myCustomAppTitle)
safeapps.acceptTC()
safeapps.clickOnAddBtn()
safeapps.verifyAppCount(1)
safeapps.verifyAppDescription(myCustomAppDescrAdded)
})
})
44 changes: 21 additions & 23 deletions cypress/e2e/safe-apps/browser_permissions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,32 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safeapps from '../pages/safeapps.pages'

describe('The Browser permissions system', () => {
describe('When the safe app requires permissions', () => {
beforeEach(() => {
cy.clearLocalStorage()
cy.fixture('safe-app').then((html) => {
cy.intercept('GET', `${constants.testAppUrl}/*`, html)
cy.intercept('GET', `*/manifest.json`, {
name: constants.testAppData.name,
description: constants.testAppData.descr,
icons: [{ src: 'logo.svg', sizes: 'any', type: 'image/svg+xml' }],
safe_apps_permissions: ['camera', 'microphone'],
})
describe('Browser permissions tests', () => {
beforeEach(() => {
cy.clearLocalStorage()
cy.fixture('safe-app').then((html) => {
cy.intercept('GET', `${constants.testAppUrl}/*`, html)
cy.intercept('GET', `*/manifest.json`, {
name: constants.testAppData.name,
description: constants.testAppData.descr,
icons: [{ src: 'logo.svg', sizes: 'any', type: 'image/svg+xml' }],
safe_apps_permissions: ['camera', 'microphone'],
})
})
})

it('should show a permissions slide to the user', () => {
cy.visitSafeApp(`${constants.testAppUrl}/app`)
safeapps.verifyCameraCheckBoxExists()
safeapps.verifyMicrofoneCheckBoxExists()
})
it('Verify a permissions slide to the user is displayed [C56137]', () => {
cy.visitSafeApp(`${constants.testAppUrl}/app`)
safeapps.verifyCameraCheckBoxExists()
safeapps.verifyMicrofoneCheckBoxExists()
})

it('should allow to change, accept and store the selection', () => {
main.acceptCookies()
safeapps.verifyMicrofoneCheckBoxExists().click()
it('Verify the selection can be changed, accepted and stored [C56138]', () => {
main.acceptCookies()
safeapps.verifyMicrofoneCheckBoxExists().click()

safeapps.clickOnContinueBtn().should(() => {
expect(window.localStorage.getItem(constants.BROWSER_PERMISSIONS_KEY)).to.eq(safeapps.localStorageItem)
})
safeapps.clickOnContinueBtn().should(() => {
expect(window.localStorage.getItem(constants.BROWSER_PERMISSIONS_KEY)).to.eq(safeapps.localStorageItem)
})
})
})
26 changes: 12 additions & 14 deletions cypress/e2e/safe-apps/info_modal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safeapps from '../pages/safeapps.pages'

describe('The Safe Apps info modal', () => {
describe('Safe Apps info modal tests', () => {
before(() => {
cy.clearLocalStorage()
cy.visit(constants.TEST_SAFE_2 + constants.appsUrl, { failOnStatusCode: false })
main.acceptCookies()
})

describe('when opening a Safe App', () => {
it('should show the disclaimer', () => {
safeapps.clickOnApp(safeapps.logoWalletConnect)
safeapps.clickOnOpenSafeAppBtn()
})
it('Verify the disclaimer is displayed when a Safe App is opened [C56139]', () => {
safeapps.clickOnApp(safeapps.logoWalletConnect)
safeapps.clickOnOpenSafeAppBtn()
})

it('should show the permissions slide if the app require permissions', () => {
safeapps.clickOnContinueBtn()
cy.wait(500) // wait for the animation to finish
safeapps.verifyCameraCheckBoxExists()
})
it('Verify the permissions slide is shown if the app require permissions [C56140]', () => {
safeapps.clickOnContinueBtn()
cy.wait(500) // wait for the animation to finish
safeapps.verifyCameraCheckBoxExists()
})

it('should store the permissions and consents decision when accepted', () => {
safeapps.storeAndVerifyPermissions()
})
it('Verify the permissions and consents decision are stored when accepted [C56141]', () => {
safeapps.storeAndVerifyPermissions()
})
})
18 changes: 9 additions & 9 deletions cypress/e2e/safe-apps/permissions_settings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let $dapps = []
const app1 = 'https://app1.com'
const app3 = 'https://app3.com'

describe('The Safe Apps permissions settings section', () => {
describe('Safe Apps permissions settings tests', () => {
before(() => {
cy.clearLocalStorage()
cy.on('window:before:load', (window) => {
Expand Down Expand Up @@ -49,18 +49,18 @@ describe('The Safe Apps permissions settings section', () => {
main.acceptCookies()
})

it('should show the permissions configuration for each stored app', () => {
it('Verify for each stored app the permissions configuration is shown [C56142]', () => {
cy.findAllByRole('heading', { level: 5 }).should('have.length', 4)
})

describe('For each app', () => {
describe('Permissions for each app', () => {
before(() => {
cy.get(safeapps.gridItem).then((items) => {
$dapps = items
})
})

it('app1 should have camera, full screen and geo permissions', () => {
it('Verify that app1 has camera, full screen and geo permissions [C56143]', () => {
const app1Data = [
'app1',
safeapps.permissionCheckboxNames.camera,
Expand All @@ -74,7 +74,7 @@ describe('The Safe Apps permissions settings section', () => {
main.verifyCheckboxeState(safeapps.permissionCheckboxes.fullscreen, 0, constants.checkboxStates.checked)
})

it('app2 should have address book and microphone permissions', () => {
it('Verify that app2 has address book and microphone permissions [C56144]', () => {
const app2Data = [
'app2',
safeapps.permissionCheckboxNames.addressbook,
Expand All @@ -86,21 +86,21 @@ describe('The Safe Apps permissions settings section', () => {
main.verifyCheckboxeState(safeapps.permissionCheckboxes.addressbook, 0, constants.checkboxStates.checked)
})

it('app3 should have camera permissions', () => {
it('Verify that app3 has camera permissions [C56145]', () => {
const app3Data = ['app3', safeapps.permissionCheckboxNames.camera]

main.checkTextsExistWithinElement($dapps[2], app3Data)
main.verifyCheckboxeState(safeapps.permissionCheckboxes.camera, 1, constants.checkboxStates.unchecked)
})

it('app4 should have address book permissions', () => {
it('Verify that app4 has address book permissions [C56146]', () => {
const app4Data = ['app4', safeapps.permissionCheckboxNames.addressbook]

main.checkTextsExistWithinElement($dapps[3], app4Data)
main.verifyCheckboxeState(safeapps.permissionCheckboxes.addressbook, 1, constants.checkboxStates.checked)
})

it('should allow to allow all or clear all the checkboxes at once', () => {
it('Verify Allow all or Clear all the checkboxes at once is permitted [C56147]', () => {
safeapps.uncheckAllPermissions($dapps[1])
main.verifyCheckboxeState(safeapps.permissionCheckboxes.addressbook, 0, constants.checkboxStates.unchecked)
main.verifyCheckboxeState(safeapps.permissionCheckboxes.microphone, 0, constants.checkboxStates.unchecked)
Expand All @@ -110,7 +110,7 @@ describe('The Safe Apps permissions settings section', () => {
main.verifyCheckboxeState(safeapps.permissionCheckboxes.microphone, 0, constants.checkboxStates.checked)
})

it('should allow to remove apps and reflect it in the localStorage', () => {
it('Verify it is permitted to remove apps and reflect it in the localStorage [C56148]', () => {
cy.wrap($dapps[0]).find('svg').last().click()
cy.wrap($dapps[2])
.find('svg')
Expand Down
28 changes: 13 additions & 15 deletions cypress/e2e/safe-apps/preview_drawer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safeapps from '../pages/safeapps.pages'

describe('The Safe Apps info modal', () => {
describe('Safe Apps info modal tests', () => {
before(() => {
cy.clearLocalStorage()
cy.visit(`/${constants.TEST_SAFE_2}/apps`, { failOnStatusCode: false })
main.acceptCookies()
})

describe('when opening a Safe App from the app list', () => {
it('should show the preview drawer', () => {
safeapps.clickOnApp(safeapps.logoWalletConnect)
it('Verify the preview drawer is displayed when opening a Safe App from the app list [C56149]', () => {
safeapps.clickOnApp(safeapps.logoWalletConnect)

cy.findByRole('presentation').within(() => {
safeapps.verifyPreviewWindow(
safeapps.walletConnectHeadlinePreview,
safeapps.connecttextPreview,
safeapps.availableNetworksPreview,
)
safeapps.pinApp(safeapps.pinWalletConnectStr)
safeapps.pinApp(safeapps.pinWalletConnectStr, false)
safeapps.closePreviewWindow()
})
cy.findByRole('presentation').should('not.exist')
cy.findByRole('presentation').within(() => {
safeapps.verifyPreviewWindow(
safeapps.walletConnectHeadlinePreview,
safeapps.connecttextPreview,
safeapps.availableNetworksPreview,
)
safeapps.pinApp(safeapps.pinWalletConnectStr)
safeapps.pinApp(safeapps.pinWalletConnectStr, false)
safeapps.closePreviewWindow()
})
cy.findByRole('presentation').should('not.exist')
})
})
Loading

0 comments on commit d81ee92

Please sign in to comment.