Skip to content

Commit

Permalink
Merge branch 'dev' into recovery-epic
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Nov 13, 2023
2 parents c785f26 + ced3211 commit 542391d
Show file tree
Hide file tree
Showing 170 changed files with 6,675 additions and 959 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
coverage
.DS_Store
.idea
dist

build/
coverage/
cypress/
out/
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING=
NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING=

# Redefine
NEXT_PUBLIC_REDEFINE_API=
NEXT_PUBLIC_REDEFINE_API=

# Social Login
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING=
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION=

2 changes: 2 additions & 0 deletions .github/workflows/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ runs:
NEXT_PUBLIC_SAFE_RELAY_SERVICE_URL_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SAFE_GELATO_RELAY_SERVICE_URL_STAGING }}
NEXT_PUBLIC_IS_OFFICIAL_HOST: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_IS_OFFICIAL_HOST }}
NEXT_PUBLIC_REDEFINE_API: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_REDEFINE_API }}
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING }}
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION }}
NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION }}
NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING }}
NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION }}
Expand Down
35 changes: 24 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
FROM node:18-alpine
FROM node:18-alpine AS base
ENV NEXT_TELEMETRY_DISABLED 1

FROM base AS builder

RUN apk add --no-cache libc6-compat git python3 py3-pip make g++ libusb-dev eudev-dev linux-headers
WORKDIR /app

# Install dependencies
COPY package.json yarn.lock* ./
RUN yarn --frozen-lockfile
COPY . .
RUN yarn run after-install

# install deps
RUN yarn install --frozen-lockfile
RUN yarn after-install
RUN yarn build

# Production image
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV REVERSE_PROXY_UI_PORT 8080

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs
COPY --from=builder /app/out ./out

# Set the correct permission for prerender cache
RUN mkdir .next && chown nextjs:nodejs .next

EXPOSE 3000
USER nextjs

ENV PORT 3000
EXPOSE ${REVERSE_PROXY_UI_PORT}

CMD ["yarn", "static-serve"]
CMD npx -y serve out -p ${REVERSE_PROXY_UI_PORT}
25 changes: 19 additions & 6 deletions cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import * as constants from '../../support/constants'

const welcomeLoginScreen = '[data-testid="welcome-login"]'
const expandMoreIcon = 'svg[data-testid="ExpandMoreIcon"]'
const nameInput = 'input[name="name"]'
const selectNetworkBtn = '[data-cy="create-safe-select-network"]'
const ownerInput = 'input[name^="owners"][name$="name"]'
const ownerAddress = 'input[name^="owners"][name$="address"]'
const thresholdInput = 'input[name="threshold"]'
export const removeOwnerBtn = 'button[aria-label="Remove owner"]'
const connectingContainer = 'div[class*="connecting-container"]'
const createNewSafeBtn = 'span[data-track="create-safe: Open stepper"]'
const createNewSafeBtn = 'span[data-track="create-safe: Continue to creation"]'
const connectWalletBtn = 'Connect wallet'

const changeNetworkWarningStr = 'Change your wallet network'
const safeAccountSetupStr = 'Safe Account setup'
const policy1_1 = '1/1 policy'
const policy1_2 = '1/1 policy'
export const walletName = 'test1-sepolia-safe'
export const defaltSepoliaPlaceholder = 'sepolia-safe'
export const defaltSepoliaPlaceholder = 'Sepolia Safe'

export function verifyPolicy1_1() {
cy.contains(policy1_1).should('exist')
cy.contains(policy1_2).should('exist')
// TOD: Need data-cy for containers
}

Expand Down Expand Up @@ -49,13 +52,23 @@ export function clickOnCreateNewSafeBtn() {
cy.get(createNewSafeBtn).click().wait(1000)
}

export function clickOnConnectWalletBtn() {
cy.get(welcomeLoginScreen).within(() => {
cy.get('button').contains(connectWalletBtn).should('be.visible').should('be.enabled').click().wait(1000)
})
}

export function typeWalletName(name) {
cy.get(nameInput).type(name).should('have.value', name)
}

export function clearWalletName() {
cy.get(nameInput).clear()
}

export function selectNetwork(network, regex = false) {
cy.wait(1000)
cy.get(selectNetworkBtn).should('be.visible').click()
cy.get(expandMoreIcon).eq(1).parents('div').eq(1).click()
cy.wait(1000)
cy.get('li').contains(network).click()
cy.get('body').click()
Expand Down Expand Up @@ -91,7 +104,7 @@ export function typeOwnerAddress(address, index, clearOnly = false) {
}

export function clickOnAddNewOwnerBtn() {
cy.contains('button', 'Add new owner').click()
cy.contains('button', 'Add new owner').click().wait(700)
}

export function addNewOwner(name, address, index) {
Expand Down
9 changes: 5 additions & 4 deletions cypress/e2e/pages/dashboard.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const transactionQueueStr = 'Pending transactions'
const noTransactionStr = 'This Safe has no queued transactions'
const overviewStr = 'Overview'
const viewAssetsStr = 'View assets'
const sendStr = 'Send'
const receiveStr = 'Receive'
const tokensStr = 'Tokens'
const nftStr = 'NFTs'
const viewAllStr = 'View all'
Expand All @@ -27,11 +29,10 @@ export function verifyOverviewWidgetData() {

cy.get('@overviewSection').within(() => {
// Prefix is separated across elements in EthHashInfo
cy.contains(constants.SEPOLIA_TEST_SAFE_5).should('exist')
cy.get('h2').contains('Overview')
cy.get(`a[href="${constants.BALANCE_URL}${encodeURIComponent(constants.SEPOLIA_TEST_SAFE_5)}"]`).contains(
viewAssetsStr,
)
cy.get(`a[href="${constants.BALANCE_URL}${encodeURIComponent(constants.SEPOLIA_TEST_SAFE_5)}"]`).contains('Tokens')
cy.get('button').contains(sendStr)
cy.get('button').contains(receiveStr)
})
}

Expand Down
6 changes: 5 additions & 1 deletion cypress/e2e/pages/import_export.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function clickOnImportBtn() {
}

export function clickOnImportBtnDataImportModal() {
cy.contains(dataImportModalStr).parent().contains('button', 'Import').click()
cy.contains('button', 'Import').click()
}

export function uploadFile(filePath) {
Expand All @@ -44,6 +44,10 @@ export function clickOnImportedSafe(safe) {
cy.contains(safe).click()
}

export function clickOnOpenSafeListSidebar() {
cy.contains('My Safe Accounts').click()
}

export function clickOnClosePushNotificationsBanner() {
cy.waitForSelector(() => {
return cy.get('h6').contains(enablePushNotificationsStr).siblings('.MuiButtonBase-root').click({ force: true })
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/pages/load_safe.pages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as constants from '../../support/constants'

const addExistingAccountBtnStr = 'Add existing Account'
const addExistingAccountBtnStr = 'Add existing one'
const contactStr = 'Name, address & network'
const invalidAddressFormatErrorMsg = 'Invalid address format'

Expand All @@ -16,7 +16,7 @@ const ownersConfirmationsStr = 'Owners and confirmations'
const transactionStr = 'Transactions'

export function openLoadSafeForm() {
cy.contains('button', addExistingAccountBtnStr).click()
cy.contains('a', addExistingAccountBtnStr).click()
cy.contains(contactStr)
}

Expand Down
7 changes: 4 additions & 3 deletions cypress/e2e/pages/owners.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const thresholdDropdown = 'div[aria-haspopup="listbox"]'
const thresholdOption = 'li[role="option"]'
const existingOwnerAddressInput = (index) => `input[name="owners.${index}.address"]`
const existingOwnerNameInput = (index) => `input[name="owners.${index}.name"]`
const singleOwnerNameInput = 'input[name="name"]'

const disconnectBtnStr = 'Disconnect'
const notConnectedStatus = 'Connect'
Expand Down Expand Up @@ -57,9 +58,9 @@ export function verifyExistingOwnerName(index, name) {
cy.get(existingOwnerNameInput(index)).should('have.value', name)
}

export function typeExistingOwnerName(index, name) {
cy.get(existingOwnerNameInput(index)).clear().type(name)
main.verifyInputValue(existingOwnerNameInput(index), name)
export function typeExistingOwnerName(name) {
cy.get(singleOwnerNameInput).clear().type(name)
main.verifyInputValue(singleOwnerNameInput, name)
}

export function verifyOwnerDeletionWindowDisplayed() {
Expand Down
18 changes: 9 additions & 9 deletions cypress/e2e/safe-apps/apps_list.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,44 @@ import * as safeapps from '../pages/safeapps.pages'
const myCustomAppTitle = 'Cypress Test App'
const myCustomAppDescrAdded = 'Cypress Test App Description'

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

it('Verify app list can be filtered by app name [C56130]', () => {
it('Verify app list can be filtered 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('Verify app list can be filtered by app description [C56131]', () => {
it('Verify app list can be filtered by app description', () => {
safeapps.typeAppName(constants.appNames.customContract)
safeapps.verifyLinkName(safeapps.linkNames.logo)
})

it('Verify error message is displayed when no app found [C56132]', () => {
it('Verify error message is displayed when no app found', () => {
safeapps.typeAppName(constants.appNames.noResults)
safeapps.verifyNoAppsTextPresent()
})

it('Verify apps can be pinned [C56133]', () => {
it('Verify apps can be pinned', () => {
safeapps.clearSearchAppInput()
safeapps.pinApp(safeapps.transactionBuilderStr)
safeapps.verifyPinnedAppCount(1)
})

it('Verify apps can be unpinned [C56134]', () => {
it('Verify apps can be unpinned', () => {
safeapps.pinApp(safeapps.transactionBuilderStr)
safeapps.pinApp(safeapps.transactionBuilderStr, false)
safeapps.verifyPinnedAppCount(0)
})

it('Verify there is an error when the app manifest is invalid [C56135]', () => {
it('Verify there is an error when the app manifest is invalid', () => {
cy.intercept('GET', constants.invalidAppUrl, {
name: constants.testAppData.name,
})
Expand All @@ -52,7 +52,7 @@ describe('Safe Apps tests', () => {
safeapps.verifyAppNotSupportedMsg()
})

it('Verify an app can be added to the list within the custom apps section [C56136]', () => {
it('Verify an app can be added to the list within the custom apps section', () => {
cy.intercept('GET', constants.validAppUrlJson, {
name: constants.testAppData.name,
description: constants.testAppData.descr,
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/safe-apps/browser_permissions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ describe('Browser permissions tests', () => {
})
})
cy.visitSafeApp(`${constants.testAppUrl}/app`)
main.acceptCookies(1)
main.acceptCookies()
})

it('Verify a permissions slide to the user is displayed [C56137]', () => {
it('Verify a permissions slide to the user is displayed', () => {
safeapps.clickOnContinueBtn()
safeapps.verifyCameraCheckBoxExists()
safeapps.verifyMicrofoneCheckBoxExists()
})

it('Verify the selection can be changed, accepted and stored [C56138]', () => {
it('Verify the selection can be changed, accepted and stored', () => {
safeapps.verifyMicrofoneCheckBoxExists().click()
safeapps.clickOnContinueBtn()
safeapps.verifyWarningDefaultAppMsgIsDisplayed()
Expand Down
20 changes: 10 additions & 10 deletions cypress/e2e/safe-apps/drain_account.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safeapps from '../pages/safeapps.pages'

describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () => {
describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
const appUrl = constants.drainAccount_url
const iframeSelector = `iframe[id="iframe-${appUrl}"]`
const visitUrl = `/apps/open?safe=${constants.GOERLI_SAFE_APPS_SAFE}&appUrl=${encodeURIComponent(appUrl)}`
Expand All @@ -15,11 +15,11 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>

cy.clearLocalStorage()
cy.visit(visitUrl)
main.acceptCookies(1)
main.acceptCookies()
safeapps.clickOnContinueBtn()
})

it('Verify drain can be created [C56627]', () => {
it('Verify drain can be created', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText(safeapps.transferEverythingStr).click()
Expand All @@ -28,7 +28,7 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
cy.findByRole('button', { name: safeapps.testNativeTransfer2 })
})

it('Verify partial drain can be created [C56628]', () => {
it('Verify partial drain can be created', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByLabelText(safeapps.selectRowChbxStr).eq(1).click()
Expand All @@ -40,7 +40,7 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
cy.findByRole('button', { name: safeapps.testNativeTransfer1 })
})

it('Verify a drain can be created when a ENS is specified [C56629]', () => {
it('Verify a drain can be created when a ENS is specified', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type('goerli-test-safe.eth').wait(2000)
getBody().findAllByText(safeapps.transferEverythingStr).click()
Expand All @@ -50,7 +50,7 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
})

// TODO: Adjust safe - owner
it.skip('Verify when cancelling a drain, previous data is preserved [C56630]', () => {
it.skip('Verify when cancelling a drain, previous data is preserved', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText(safeapps.transferEverythingStr).click()
Expand All @@ -61,30 +61,30 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
})
})

it('Verify a drain cannot be created with no recipient selected [C56631]', () => {
it('Verify a drain cannot be created with no recipient selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it('Verify a drain cannot be created with invalid recipient selected [C56632]', () => {
it('Verify a drain cannot be created with invalid recipient selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2.substring(1))
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it('Verify a drain cannot be created when no assets are selected [C56633]', () => {
it('Verify a drain cannot be created when no assets are selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
})
})

it('should not allow to perform a drain when no assets and recipient are selected', () => {
it('Verify a drain cannot be created when no assets and recipient are selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
Expand Down
Loading

0 comments on commit 542391d

Please sign in to comment.