Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/epic/multichain-safes' into mult…
Browse files Browse the repository at this point in the history
…ichain-analytics

# Conflicts:
#	src/features/multichain/components/CreateSafeOnNewChain/index.tsx
  • Loading branch information
usame-algan committed Sep 24, 2024
2 parents 9f1896b + 916318f commit 83399cd
Show file tree
Hide file tree
Showing 111 changed files with 2,746 additions and 1,204 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: 'CLA Assistant'
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release
uses: contributor-assistant/[email protected].1
uses: contributor-assistant/[email protected].2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ concurrency:

jobs:
eslint:
permissions:
checks: write
pull-requests: read
statuses: write

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/workflows/yarn

- uses: Maggi64/eslint-plus-action@master
- uses: CatChen/eslint-suggestion-action@v2
with:
npmInstall: false
request-changes: true # optional
fail-check: true # optional
github-token: ${{ secrets.GITHUB_TOKEN }} # optional
directory: './' # optional
targets: 'src' # optional
22 changes: 21 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { defineConfig } from 'cypress'
import 'dotenv/config'
import * as fs from 'fs'

import path, { dirname } from 'path'
import { fileURLToPath } from 'url'
import matter from 'gray-matter'
import { configureVisualRegression } from 'cypress-visual-regression'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
projectId: 'exhdra',
trashAssetsBeforeRuns: true,
Expand All @@ -18,6 +22,20 @@ export default defineConfig({
e2e: {
screenshotsFolder: './cypress/snapshots/actual',
setupNodeEvents(on, config) {
// Read and parse the terms Markdown file
try {
const filePath = path.resolve(__dirname, './src/markdown/terms/terms.md')

const content = fs.readFileSync(filePath, 'utf8')
const parsed = matter(content)
const frontmatter = parsed.data

// Set Cookie term version on the cypress env - this way we can access it in the tests
config.env.CURRENT_COOKIE_TERMS_VERSION = frontmatter.version
} catch (error) {
console.error('Error reading or parsing terms.md file:', error)
}

configureVisualRegression(on),
on('task', {
log(message) {
Expand All @@ -34,6 +52,8 @@ export default defineConfig({
}
}
})

return config
},
env: {
...process.env,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/happypath/sendfunds_connected_wallet.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function visit(url) {
describe('Send funds with connected signer happy path tests', { defaultCommandTimeout: 60000 }, () => {
before(async () => {
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__tokenlist_onboarding,
ls.cookies.acceptedTokenListOnboarding,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/happypath/sendfunds_queue_1.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function executeTransactionFlow(fromSafe) {
describe('Send funds from queue happy path tests 1', () => {
before(async () => {
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__tokenlist_onboarding,
ls.cookies.acceptedTokenListOnboarding,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/happypath/sendfunds_relay.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function visit(url) {
describe('Send funds with relay happy path tests', { defaultCommandTimeout: 300000 }, () => {
before(async () => {
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__tokenlist_onboarding,
ls.cookies.acceptedTokenListOnboarding,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/happypath/tx_history_filter_hp_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let staticSafes = []
describe('Tx history happy path tests 2', () => {
before(async () => {
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__tokenlist_onboarding,
ls.cookies.acceptedTokenListOnboarding,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/add_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let staticSafes = []
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY

describe('Add Owners tests', () => {
describe('[PROD] Add Owners tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/create_tx.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function happyPathToStepTwo() {
createtx.clickOnNextBtn()
}

describe.skip('Create transactions tests', () => {
describe.skip('[PROD] Create transactions tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/messages_onchain.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let staticSafes = []

const typeMessagesOnchain = msg_data.type.onChain

describe('Onchain Messages tests', () => {
describe('[PROD] Onchain Messages tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/nfts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let nftsSafes,
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY

describe.skip('NFTs tests', () => {
describe.skip('[PROD] NFTs tests', () => {
before(() => {
getSafes(CATEGORIES.nfts)
.then((nfts) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/recovery.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
let recoverySafes,
staticSafes = []

describe('Production recovery health check tests', { defaultCommandTimeout: 50000 }, () => {
describe('[PROD] Production recovery health check tests', { defaultCommandTimeout: 50000 }, () => {
before(() => {
getSafes(CATEGORIES.recovery)
.then((recoveries) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/remove_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let staticSafes = []
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY

describe('Remove Owners tests', () => {
describe('[PROD] Remove Owners tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/sidebar.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let staticSafes = []
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY

describe('Sidebar tests', () => {
describe('[PROD] Sidebar tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/sidebar_3.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const signer = walletCredentials.OWNER_4_PRIVATE_KEY
const signer1 = walletCredentials.OWNER_1_PRIVATE_KEY
const signer2 = walletCredentials.OWNER_3_PRIVATE_KEY

describe.skip('Sidebar tests 3', () => {
describe.skip('[PROD] Sidebar tests 3', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/spending_limits.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const tokenAmount = 0.1
const newTokenAmount = 0.001
const spendingLimitBalance = '(0.15 ETH)'

describe('Spending limits tests', () => {
describe('[PROD] Spending limits tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/swaps_history_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let staticSafes = []

const swapsHistory = swaps_data.type.history

describe('Swaps history tests 2', () => {
describe('[PROD] Swaps history tests 2', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/swaps_tokens.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const signer = walletCredentials.OWNER_4_PRIVATE_KEY

let iframeSelector = `iframe[src*="${constants.swapWidget}"]`

describe('[SMOKE] Swaps token tests', () => {
describe('[PROD] Swaps token tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/tokens.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const FIAT_AMOUNT_COLUMN = 2

let staticSafes = []

describe('Prod tokens tests', () => {
describe('[PROD] Prod tokens tests', () => {
const fiatRegex = assets.fiatRegex

before(async () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/tx_history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const typeDeleteAllowance = data.type.deleteSpendingLimit
const typeSideActions = data.type.sideActions
const typeGeneral = data.type.general

describe('Tx history tests 1', () => {
describe('[PROD] Tx history tests 1', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/tx_history_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const typeSideActions = data.type.sideActions
const typeGeneral = data.type.general
const typeUntrustedToken = data.type.untrustedReceivedToken

describe('Tx history tests 2', () => {
describe('[PROD] Tx history tests 2', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/regression/tokens.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Tokens tests', () => {
beforeEach(() => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_2)
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__tokenlist_onboarding,
ls.cookies.acceptedTokenListOnboarding,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/apps_list.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Safe Apps list tests', () => {

beforeEach(() => {
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
})
cy.visit(`${constants.appsUrl}?safe=${staticSafes.SEP_STATIC_SAFE_1}`, {
failOnStatusCode: false,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/drain_account.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Drain Account tests', () => {
before(async () => {
safeAppSafes = await getSafes(CATEGORIES.safeapps)
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__SafeApps__infoModal,
ls.appPermissions(constants.safeTestAppurl).infoModalAccepted,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/preview_drawer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Preview drawer tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
})
})

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/safe_permissions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as ls from '../../support/localstorage_data.js'
describe('Safe permissions system tests', () => {
before(async () => {
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
})
})

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/tx-builder.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe.skip('Transaction Builder tests', { defaultCommandTimeout: 20000 }, ()
cy.clearLocalStorage()
cy.clearCookies()
cy.window().then((win) => {
win.localStorage.setItem(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
win.localStorage.setItem(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
win.localStorage.setItem(
constants.localStorageKeys.SAFE_v2__SafeApps__infoModal,
ls.appPermissions(constants.safeTestAppurl).infoModalAccepted,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/tx_modal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const confirmTx = 'Confirm transaction'
describe('Transaction modal tests', () => {
before(async () => {
cy.clearLocalStorage().then(() => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies_1_1, ls.cookies.acceptedCookies)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__SafeApps__infoModal,
ls.appPermissions(constants.safeTestAppurl).infoModalAccepted,
Expand Down
4 changes: 3 additions & 1 deletion cypress/support/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,15 @@ export const addresBookContacts = {
},
}

export const CURRENT_COOKIE_TERMS_VERSION = Cypress.env('CURRENT_COOKIE_TERMS_VERSION')

export const localStorageKeys = {
SAFE_v2__addressBook: 'SAFE_v2__addressBook',
SAFE_v2__batch: 'SAFE_v2__batch',
SAFE_v2__settings: 'SAFE_v2__settings',
SAFE_v2__addedSafes: 'SAFE_v2__addedSafes',
SAFE_v2__safeApps: 'SAFE_v2__safeApps',
SAFE_v2_cookies_1_1: 'SAFE_v2__cookies_terms_v1.1',
SAFE_v2_cookies: 'SAFE_v2__cookies_terms',
SAFE_v2__tokenlist_onboarding: 'SAFE_v2__tokenlist_onboarding',
SAFE_v2__customSafeApps_11155111: 'SAFE_v2__customSafeApps-11155111',
SAFE_v2__SafeApps__browserPermissions: 'SAFE_v2__SafeApps__browserPermissions',
Expand Down
15 changes: 13 additions & 2 deletions cypress/support/localstorage_data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
/* eslint-disable */

import { CURRENT_COOKIE_TERMS_VERSION } from './constants.js'

const cookieState = {
necessary: true,
updates: true,
analytics: true,
terms: true,
termsVersion: CURRENT_COOKIE_TERMS_VERSION
}

export const batchData = {
entry0: {
11155111: {
Expand Down Expand Up @@ -379,7 +390,7 @@ export const addressBookData = {
'0xc2F3645bfd395516d1a18CA6ad9298299d328C01': 'Safe 27',
},
},
cookies: { necessary: true, updates: true, analytics: true },
cookies: cookieState,
}

export const safeSettings = {
Expand Down Expand Up @@ -673,7 +684,7 @@ export const appPermissions = (url) => ({
})

export const cookies = {
acceptedCookies: { necessary: true, updates: true, analytics: true },
acceptedCookies: cookieState,
acceptedTokenListOnboarding: true,
}

Expand Down
28 changes: 28 additions & 0 deletions docs/update-terms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How to update Terms & Conditions

To update the terms and conditions, follow these steps:

1. Export the terms and conditions from Google Docs as a Markdown file.
2. Replace the content of the src/markdown/terms/terms.md file with the exported content.
3. Update the frontmatter of the file with the new version number and date.

That’s it!

The updated terms and conditions will be displayed in the app with the correct version number and date. A popup banner
will automatically appear for users who haven’t accepted the new terms.

## How does this work?

We rely on the version number from the frontmatter. When the Redux store is rehydrated, we check the version stored in
the store against the version in the frontmatter. If they differ, we reset the accepted terms, forcing the user to
accept the new version.

The Markdown file is automatically converted to HTML and displayed in the app. Note that because the Markdown was
generated
from Google Docs, we require the remark-heading-id plugin. Additionally, since Google Docs uses {# ...} syntax, it will
fail in an MDX file.

For Cypress, we follow a similar process. We read the version from the frontmatter and pass it as an environment
variable.

For Jest tests, we mock the file and read the version from the mock.
1 change: 1 addition & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const customJestConfig = {
// Handle module aliases (this will be automatically configured for you soon)
'^@/(.*)$': '<rootDir>/src/$1',
'^.+\\.(svg)$': '<rootDir>/mocks/svg.js',
'^.+/markdown/terms/terms\\.md$': '<rootDir>/mocks/terms.md.js',
isows: '<rootDir>/node_modules/isows/_cjs/index.js',
},
testEnvironment: 'jest-environment-jsdom',
Expand Down
6 changes: 6 additions & 0 deletions mocks/terms.md.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const metadata = {
version: 'test-version',
last_update_date: 'test-date',
}

export default metadata
Loading

0 comments on commit 83399cd

Please sign in to comment.