Skip to content

Commit

Permalink
fix: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Jun 5, 2024
1 parent 13e7858 commit 47913b4
Show file tree
Hide file tree
Showing 21 changed files with 252 additions and 235 deletions.
2 changes: 1 addition & 1 deletion examples/sample-angular-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.9.5"
"typescript": "5.1.6"
}
}
6 changes: 3 additions & 3 deletions examples/sample-angular-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Angular modules
import { CUSTOM_ELEMENTS_SCHEMA, Component, type OnInit } from '@angular/core';
import { DAppKitUI, DAppKitUIOptions } from '@vechain/dapp-kit-ui';
import { Component, CUSTOM_ELEMENTS_SCHEMA, type OnInit } from '@angular/core';
import type { DAppKitUIOptions } from '@vechain/dapp-kit-ui';
import { DAppKitUI } from '@vechain/dapp-kit-ui';

@Component({
selector: 'app-root',
Expand All @@ -26,7 +27,6 @@ export class AppComponent implements OnInit {

const vechainDAppKitOptions: DAppKitUIOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test',
walletConnectOptions,
usePersistence: true,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.1.4",
"typescript": "5.3.3"
"typescript": "5.1.6"
}
}
1 change: 0 additions & 1 deletion examples/sample-next-app/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default function RootLayout({
</head>
<body className={inter.className}>
<DAppKitProvider
genesis="test"
logLevel="DEBUG"
nodeUrl="https://testnet.vechain.org/"
usePersistence
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"react-test-renderer": "^18.2.0",
"typescript": "^5.2.2",
"typescript": "5.1.6",
"vite-plugin-node-polyfills": "^0.17.0",
"vitest": "1.5.3"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// vite.config.ts
import { defineConfig } from "file:///Users/darren/workspace/vechain/vechain-dapp-kit/node_modules/vite/dist/node/index.js";
import react from "file:///Users/darren/workspace/vechain/vechain-dapp-kit/node_modules/@vitejs/plugin-react/dist/index.mjs";
import { nodePolyfills } from "file:///Users/darren/workspace/vechain/vechain-dapp-kit/node_modules/vite-plugin-node-polyfills/dist/index.js";
import { resolve } from "path";
var __vite_injected_original_dirname = "/Users/darren/workspace/vechain/vechain-dapp-kit/examples/sample-react-app";
var vite_config_default = defineConfig(({ mode }) => {
return {
plugins: [nodePolyfills(), react()],
build: {
commonjsOptions: {
transformMixedEsModules: true
}
},
preview: {
port: 5001,
strictPort: true
},
server: {
port: 5001,
strictPort: true,
host: true,
origin: "http://0.0.0.0:5001"
},
//vitest
test: {
globals: true,
environment: "jsdom",
setupFiles: [
resolve(__vite_injected_original_dirname, "test/setup/setup.ts"),
resolve(__vite_injected_original_dirname, "test/setup/resizeObserverMock.ts")
]
},
base: mode === "production" ? "/vechain-dapp-kit/react/" : "/"
};
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvZGFycmVuL3dvcmtzcGFjZS92ZWNoYWluL3ZlY2hhaW4tZGFwcC1raXQvZXhhbXBsZXMvc2FtcGxlLXJlYWN0LWFwcFwiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF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FBQUEsSUFDaEI7QUFBQSxJQUNBLFFBQVE7QUFBQSxNQUNKLE1BQU07QUFBQSxNQUNOLFlBQVk7QUFBQSxNQUNaLE1BQU07QUFBQSxNQUNOLFFBQVE7QUFBQSxJQUNaO0FBQUE7QUFBQSxJQUVBLE1BQU07QUFBQSxNQUNGLFNBQVM7QUFBQSxNQUNULGFBQWE7QUFBQSxNQUNiLFlBQVk7QUFBQSxRQUNSLFFBQVEsa0NBQVcscUJBQXFCO0FBQUEsUUFDeEMsUUFBUSxrQ0FBVyxrQ0FBa0M7QUFBQSxNQUN6RDtBQUFBLElBQ0o7QUFBQSxJQUNBLE1BQU0sU0FBUyxlQUFlLDZCQUE2QjtBQUFBLEVBQy9EO0FBQ0osQ0FBQzsiLAogICJuYW1lcyI6IFtdCn0K
2 changes: 1 addition & 1 deletion examples/sample-remix-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"typescript": "^5.1.6",
"typescript": "5.1.6",
"vite": "^5.1.0",
"vite-plugin-node-polyfills": "^0.21.0",
"vite-tsconfig-paths": "^4.2.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-svelte-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"svelte": "^4.0.5",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"typescript": "5.1.6",
"vite": "^4.5.2",
"vite-plugin-node-polyfills": "^0.16.0"
}
Expand Down
1 change: 0 additions & 1 deletion examples/sample-svelte-app/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const walletConnectOptions = {

const vechainDAppKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test',
walletConnectOptions,
usePersistence: true,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-vanilla-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@vechain/dapp-kit-ui": "*"
},
"devDependencies": {
"typescript": "^5.2.2",
"typescript": "5.1.6",
"vite": "^5.2.0"
}
}
1 change: 0 additions & 1 deletion examples/sample-vanilla-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const walletConnectOptions = {

const vechainDAppKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test',
walletConnectOptions,
usePersistence: true,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-vue-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"typescript": "^5.2.2",
"typescript": "5.1.6",
"vite": "^5.0.12",
"vite-plugin-node-polyfills": "^0.17.0",
"vue-tsc": "^2.0.6"
Expand Down
5 changes: 3 additions & 2 deletions examples/sample-vue-app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { DAppKitUI } from '@vechain/dapp-kit-ui';
import { Genesis } from '@vechain/dapp-kit';
const walletConnectOptions = {
projectId: 'a0b855ceaf109dbc8426479a4c3d38d8',
Expand All @@ -27,7 +26,6 @@ const walletConnectOptions = {
const vechainDAppKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test' as Genesis,
walletConnectOptions,
usePersistence: true,
};
Expand Down Expand Up @@ -78,9 +76,11 @@ body {
align-items: center;
justify-content: center;
}
h2 {
margin: 0;
}
.container {
display: flex;
flex-direction: column;
Expand All @@ -90,6 +90,7 @@ h2 {
border-radius: 20px;
padding: 20px;
}
.label {
margin-top: 20px;
margin-bottom: 10px;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"lint-staged": "^15.0.2",
"prettier": "^2.5.1",
"punycode": "^1.4.1",
"turbo": "latest",
"typescript": "4.9.5"
"turbo": "1.13.4",
"typescript": "5.1.6"
},
"packageManager": "[email protected]"
}
6 changes: 4 additions & 2 deletions packages/dapp-kit-ui/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# `@vechain/dapp-kit-ui`

The Vechain DApp Kit serves as a sophisticated layer built upon @vechain/connex, providing a simplified and efficient avenue for engaging with a multitude of Vechain wallets. This innovative toolkit enhances the ease of interaction, offering developers a seamless bridge to connect with diverse Vechain wallet functionalities. For more information, please refer to the official [Vechain Docs](https://docs.vechain.org/developer-resources/sdks-and-providers/dapp-kit)
The Vechain DApp Kit serves as a sophisticated layer built upon @vechain/connex, providing a simplified and efficient
avenue for engaging with a multitude of Vechain wallets. This innovative toolkit enhances the ease of interaction,
offering developers a seamless bridge to connect with diverse Vechain wallet functionalities. For more information,
please refer to the official [Vechain Docs](https://docs.vechain.org/developer-resources/sdks-and-providers/dapp-kit)

## Usage

Expand All @@ -26,7 +29,6 @@ const walletConnectOptions: WalletConnectOptions = {

const options: DAppKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test',
walletConnectOptions,
usePersistence: true,
};
Expand Down
1 change: 0 additions & 1 deletion packages/dapp-kit-ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const walletConnectOptions = {

const vechainDAppKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test',
walletConnectOptions,
usePersistence: true,
};
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"selenium-webdriver": "4.8.2",
"testcontainers": "^10.7.2",
"ts-node": "^10.9.2",
"typescript": "4.9.5"
"typescript": "5.1.6"
}
}
6 changes: 3 additions & 3 deletions tests/e2e/src/config/hooks/ContainerHooks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import path from 'path';
import { AfterAll, BeforeAll, setDefaultTimeout } from '@cucumber/cucumber';
import {
DockerComposeEnvironment,
StartedDockerComposeEnvironment,
Wait,
} from 'testcontainers';
import path from 'path';
import { DappUrl } from '../../constants/dapp';
import axios from 'axios';
import { DappUrl } from '../../constants/dapp';

setDefaultTimeout(180_000);

Expand All @@ -28,7 +28,7 @@ const appHealthCheck = async () => {
break;
} catch (e) {
if (e instanceof axios.AxiosError) {
console.log(app, e.message, e.code);
console.log(app, e.message, e.code, url);
} else {
console.log(`Waiting for ${app} to be ready...`);
}
Expand Down
50 changes: 14 additions & 36 deletions tests/e2e/src/extension/selenium/WebDriver.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import * as chrome from 'selenium-webdriver/chrome';
import util from 'util';
import { exec as execSync } from 'child_process';
import * as path from 'path';
import * as console from 'console';
import { By } from 'selenium-webdriver/lib/by';
import wd, {
Key,
Session,
until,
WebDriver,
WebElement,
} from 'selenium-webdriver';
import * as http from 'selenium-webdriver/http';
import Locators from './Locators';
import { By } from 'selenium-webdriver/lib/by';
import * as path from 'path';
import * as console from 'console';
import * as chrome from 'selenium-webdriver/chrome';
import { Mutex } from 'async-mutex';
import TestDefaults from '../TestDefaults';
import { ShadowRoot } from 'selenium-webdriver/lib/webdriver';
import { Executor } from 'selenium-webdriver/lib/command';
import { ROUTES } from '../enums';
import TestDefaults from '../TestDefaults';
import Locators from './Locators';

const exec = util.promisify(execSync);

Expand Down Expand Up @@ -84,7 +84,7 @@ export const buildWebDriver = async (
await driver.manage().setTimeouts({ implicit: TestDefaults.TIMEOUT });

const session = await driver.getSession();
const executor = driver.getExecutor();
const executor: Executor = driver.getExecutor();
const extensionDriver = new ExtensionDriver(session, executor);

globalWebDriver = extensionDriver;
Expand All @@ -102,7 +102,7 @@ export const buildWebDriver = async (
export class ExtensionDriver extends WebDriver {
private extensionUrl: string | undefined;

constructor(session: Session | Promise<Session>, executor: http.Executor) {
constructor(session: Session | Promise<Session>, executor: Executor) {
super(session, executor);
}

Expand Down Expand Up @@ -143,7 +143,7 @@ export class ExtensionDriver extends WebDriver {
}
const id = await element.getId();
throw Error(
'Timed out searching for shadow root on element with ID: ' + id,
`Timed out searching for shadow root on element with ID: ${id}`,
);
};

Expand All @@ -160,8 +160,7 @@ export class ExtensionDriver extends WebDriver {
}
}
throw Error(
'Timed out searching for shadow root on locator: ' +
locator.toString(),
`Timed out searching for shadow root on locator: ${locator.toString()}`,
);
};

Expand Down Expand Up @@ -189,7 +188,7 @@ export class ExtensionDriver extends WebDriver {
);
} catch (e) {
console.error(
'Failed to scroll into view for element ID: ' + elementId,
`Failed to scroll into view for element ID: ${elementId}`,
e,
);
throw e;
Expand All @@ -208,7 +207,7 @@ export class ExtensionDriver extends WebDriver {
await this.sleep(sleepTime);
}
}
throw Error('Could not find the shadow root element: ' + locator.value);
throw Error(`Could not find the shadow root element: ${locator.value}`);
};

public waitAndClick = async (locator: By) => {
Expand Down Expand Up @@ -243,7 +242,7 @@ export class ExtensionDriver extends WebDriver {
await this.sleep(sleepTime);
}
throw Error(
'Timed out waiting for element to be removed: ' + locator.value,
`Timed out waiting for element to be removed: ${locator.value}`,
);
};

Expand Down Expand Up @@ -286,27 +285,6 @@ export class ExtensionDriver extends WebDriver {
}
};

public waitUntilElements = async (
locator: By,
timeout = TestDefaults.TIMEOUT,
debug = false,
): Promise<WebElement[]> => {
try {
return await this.wait(
until.elementsLocated(locator),
timeout,
`Timed out waiting until elements located by: ${
locator.value
} on page: ${
debug ? await this.getPageSource() : 'NOT LOGGED'
}`,
);
} catch (e) {
console.log(`Timed out waiting for element ${locator.value}`);
throw e;
}
};

public isElementPresent = async (locator: By): Promise<boolean> => {
try {
await extension.driver.waitUntilElement(locator);
Expand Down
6 changes: 2 additions & 4 deletions tests/e2e/src/extension/utils/AddressUtils/AddressUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ export const compareAddresses = (
if (address2 === address1) return true;

try {
address1 = addPrefix(address1);
address2 = addPrefix(address2);
return (
addressUtils.toChecksummed(address1 as string) ===
addressUtils.toChecksummed(address2 as string)
addressUtils.toERC55Checksum(addPrefix(address1)) ===
addressUtils.toERC55Checksum(addPrefix(address2))
);
} catch (e) {
return false;
Expand Down
Loading

0 comments on commit 47913b4

Please sign in to comment.