Skip to content

Commit

Permalink
CU-86dtm13dg
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoDizConde committed Jun 20, 2024
1 parent 416cd9b commit a043ca8
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 61 deletions.
11 changes: 11 additions & 0 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
"safeForSimultaneousRushProcesses": true,
"autoinstallerName": "rush-format",
"shellCommand": "prettier . --write --config .prettierrc && npm run format -p --prefix ./packages/wallet-connect-sdk-core && npm run format -p --prefix ./packages/wallet-connect-sdk-react && npm run format -p --prefix ./packages/wallet-connect-sdk-wallet-core && npm run format -p --prefix ./packages/wallet-connect-sdk-wallet-react && npm run format -p --prefix ./e2e"
},
{
"commandKind": "bulk",
"name": "build",
"summary": "Build all projects that haven't been built, or have changed since they were last built",
"description": "It's the rush build, but overriding the `allowWarningsInSuccessfulBuild`option",
"safeForSimultaneousRushProcesses": false,
"enableParallelism": true,
"ignoreDependencyOrder": false,
"ignoreMissingScript": false,
"allowWarningsInSuccessfulBuild": true
}
]
}
21 changes: 15 additions & 6 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion e2e/src/constants/DevConstants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { DAPP_REACT, DAPP_VITE_VANILLA, WALLET_REACT } from './ProjectsDefinitions'
import { DAPP_REACT, DAPP_VITE_SVELTEKIT, DAPP_VITE_VANILLA, WALLET_REACT } from './ProjectsDefinitions'

export const RUN_CONCURRENTLY_COMMAND: string = `concurrently ${[
DAPP_REACT.runCommand,
WALLET_REACT.runCommand,
DAPP_VITE_VANILLA.runCommand,
DAPP_VITE_SVELTEKIT.runCommand,
].join(' ')}`

export const HTML_ENTITIES = {
Expand Down
1 change: 1 addition & 0 deletions e2e/src/constants/ProjectsDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import ExampleProject from '../models/ExampleProject'
export const DAPP_REACT: ExampleProject = new ExampleProject('wc-dapp-react', 3000)
export const WALLET_REACT: ExampleProject = new ExampleProject('wc-wallet-react', 3001)
export const DAPP_VITE_VANILLA: ExampleProject = new ExampleProject('wc-dapp-vite-vanilla', 3002)
export const DAPP_VITE_SVELTEKIT: ExampleProject = new ExampleProject('wc-dapp-vite-sveltekit', 3003)
25 changes: 22 additions & 3 deletions e2e/src/helpers/CommonStepsHelper.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BrowserContext } from '@playwright/test'
import ExampleProject from '../models/ExampleProject'
import { connectDappToReactWallet, createNewReactWallet } from '../pageCommonSteps/WalletReactSteps'
import { getReactDappUri } from '../pageCommonSteps/DappReactSteps'
import { getDappUri } from '../pageCommonSteps/DappReactSteps'

export async function connectReactDappToNewReactAccount(
async function connectGenericDappToNewReactAccount(
context: BrowserContext,
dappPage: ExampleProject,
dappComponentTestId: string,
walletPage: ExampleProject,
actionBeforeConnectWallet?: (dappPage: ExampleProject, walletPage: ExampleProject) => Promise<void> | void,
) {
Expand All @@ -18,9 +19,27 @@ export async function connectReactDappToNewReactAccount(
if (actionBeforeConnectWallet) await actionBeforeConnectWallet(dappPage, walletPage)

// Get the URI of the dapp
dappUri = await getReactDappUri(dappPage)
dappUri = await getDappUri(dappPage, dappComponentTestId)
// Create a wallet
await createNewReactWallet(walletPage)
// Connect to the dapp
await connectDappToReactWallet(walletPage, dappUri)
}

export async function connectReactDappToNewReactAccount(
context: BrowserContext,
dappPage: ExampleProject,
walletPage: ExampleProject,
actionBeforeConnectWallet?: (dappPage: ExampleProject, walletPage: ExampleProject) => Promise<void> | void,
) {
await connectGenericDappToNewReactAccount(context, dappPage, 'hello-world', walletPage, actionBeforeConnectWallet)
}

export async function connectSvelteDappToNewReactAccount(
context: BrowserContext,
dappPage: ExampleProject,
walletPage: ExampleProject,
actionBeforeConnectWallet?: (dappPage: ExampleProject, walletPage: ExampleProject) => Promise<void> | void,
) {
await connectGenericDappToNewReactAccount(context, dappPage, 'page', walletPage, actionBeforeConnectWallet)
}
2 changes: 1 addition & 1 deletion e2e/src/models/ExampleProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class ExampleProject {
get runCommand(): string {
if (this.projectPathName.includes('react'))
return `"cd ${EXAMPLES_PATH}/${this.projectPathName} && cross-env PORT=${this.projectPort} npx serve -s build"`
else if (this.projectPathName.includes('vite'))
else if (this.projectPathName.includes('vite') || this.projectPathName.includes('sveltekit'))
return `"cd ${EXAMPLES_PATH}/${this.projectPathName} && pnpm vite preview --port ${this.projectPort}"`
else throw Error('Unknown project framework')
}
Expand Down
8 changes: 4 additions & 4 deletions e2e/src/pageCommonSteps/DappReactSteps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ExampleProject from '../models/ExampleProject'
import { getCleanInnerHTML } from '../helpers/CleanerHelper'

export async function getReactDappUri(dappPage: ExampleProject): Promise<string> {
await dappPage.awaitAndClickTestId('hello-world__get-uri-button') // Click the button to get the dapp URI
await dappPage.awaitAndClickTestId('hello-world__get-uri-button') // Click the button to get the dapp URI
return await getCleanInnerHTML(await dappPage.awaitAndGetTestId('hello-world__dapp-uri')) // Get and store the clean dapp URI
export async function getDappUri(dappPage: ExampleProject, componentTestId: string): Promise<string> {
await dappPage.awaitAndClickTestId(`${componentTestId}__get-uri-button`) // Click the button to get the dapp URI
await dappPage.awaitAndClickTestId(`${componentTestId}__get-uri-button`) // Click the button to get the dapp URI
return await getCleanInnerHTML(await dappPage.awaitAndGetTestId(`${componentTestId}__dapp-uri`)) // Get and store the clean dapp URI
}
29 changes: 27 additions & 2 deletions e2e/tests/DappMethods.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test'
import { DAPP_REACT, WALLET_REACT } from '../src/constants/ProjectsDefinitions'
import { connectReactDappToNewReactAccount } from '../src/helpers/CommonStepsHelper'
import { DAPP_REACT, WALLET_REACT, DAPP_VITE_SVELTEKIT } from '../src/constants/ProjectsDefinitions'
import { connectReactDappToNewReactAccount, connectSvelteDappToNewReactAccount } from '../src/helpers/CommonStepsHelper'
import { getAnyFromInnerHTML, getCleanInnerHTML } from '../src/helpers/CleanerHelper'
import { acceptPendingRequestToReactWallet } from '../src/pageCommonSteps/WalletReactSteps'
import { DAPP_METHOD_CONTEXT_MESSAGE } from '../src/constants/GenericData'
Expand Down Expand Up @@ -30,6 +30,31 @@ test('Create a new account and connect with a dapp (React)', async ({ context })
expect(hasSession).toBeTruthy()
})

test.only('Create a new account and connect with a dapp (Svelte)', async ({ context }) => {
// Define the dapp and wallet pages
const dappPage = DAPP_VITE_SVELTEKIT
const walletPage = WALLET_REACT

await connectSvelteDappToNewReactAccount(
context,
dappPage,
walletPage,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async (dappPageBeforeConnection, walletPageBeforeConnection) => {
const hasSession = await getAnyFromInnerHTML(
await dappPageBeforeConnection.awaitAndGetTestId('page__has-session'),
)
expect(hasSession).toBeFalsy()
},
)
const disconnectButton = await walletPage.awaitAndGetTestId('page__get-disconnect') // Get the dapp card element

const hasSession = await getAnyFromInnerHTML(await dappPage.awaitAndGetTestId('page__has-session'))
// Check if the dapp card element is defined, indicating successful connection
expect(disconnectButton).toBeDefined()
expect(hasSession).toBeTruthy()
})

test('Test Disconnect on dapp (React)', async ({ context }) => {
// Define the dapp and wallet pages
const dappPage = DAPP_REACT
Expand Down
3 changes: 2 additions & 1 deletion examples/wc-dapp-sveltekit/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "wc-dapp-sveltekit",
"name": "wc-dapp-vite-sveltekit",
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
Expand All @@ -17,6 +17,7 @@
"lokijs": "^1.5.12",
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"toastify-js": "^1.12.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.4.2"
Expand Down
Loading

0 comments on commit a043ca8

Please sign in to comment.