Skip to content

Commit

Permalink
fix: remove unused things
Browse files Browse the repository at this point in the history
  • Loading branch information
davidecarpini committed Mar 26, 2024
1 parent 1e484d6 commit 796e6ad
Show file tree
Hide file tree
Showing 45 changed files with 542 additions and 1,969 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 @@ -59,4 +59,4 @@
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.9.5"
}
}
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"license": "MIT",
"workspaces": [
"examples/*",
"packages/*",
"tests/*"
"packages/*"
],
"scripts": {
"build": "turbo run build",
Expand Down Expand Up @@ -54,4 +53,4 @@
"typescript": "4.9.5"
},
"packageManager": "[email protected]"
}
}
2 changes: 2 additions & 0 deletions tests/e2e/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ module.exports = {
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'unicorn/filename-case': 'off',
'import/no-default-export': 'off',
'unicorn/prefer-node-protocol': 'off',
},
};
7 changes: 5 additions & 2 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"@vechain/repo-config": "https://github.com/vechain/repo-config",
"selenium-webdriver": "4.8.2",
"testcontainers": "^10.7.2",
"ts-node": "^10.9.2"
"ts-node": "^10.9.2",
"typescript": "4.9.5",
"async-mutex": "^0.2.6",
"thor-devkit": "2.0.5"
}
}
}
1 change: 0 additions & 1 deletion tests/e2e/src/extension/TestDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ export default {
ADDRESS: '0xf077b491b355E64048cE21E3A6Fc4751eEeA77fa',
TIMEOUT: 5_000,
TRANSACTION_TIMEOUT: 20_000,
DAPP_URL: 'http://localhost:5001',
};
41 changes: 14 additions & 27 deletions tests/e2e/src/extension/flows/AccessFlows.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,37 @@
import TestDefaults from '../TestDefaults';
import DashboardScreen from '../screens/DashboardScreen';
import UnlockScreen from '../screens/access/UnlockScreen';
import FirstAccessScreen from '../screens/onboarding/FirstAccessScreen';
import NavigationUtils from '../utils/NavigationUtils';
import TestDefaults from '../TestDefaults';
import DashboardScreen from './DashboardFlows';
import UnlockFlows from './UnlockFlows';
import FirstAccessFlows from './FirstAccessFlows';

/**
* Navigate to extension => Then we should be on one of the following screens:
* - DashboardScreen => Immediately returns as we are already unlocked
* - FirstAccessScreen => Immediately throws an error as we are not onboarded
* - UnlockScreen => Enters the password and submits
* @param password
*/
export const unlock = async (password?: string) => {
const pw = password || TestDefaults.PASSWORD;
const pw = password ?? TestDefaults.PASSWORD;

await NavigationUtils.goToExtension();

const isDashboardScreenActive = await DashboardScreen.isActive();
if (isDashboardScreenActive) return;

const isUnlockScreenActive = await UnlockScreen.isActive();
if (isUnlockScreenActive) return await UnlockScreen.submitPassword(pw);
const isUnlockFlowsActive = await UnlockFlows.isActive();
if (isUnlockFlowsActive) return UnlockFlows.submitPassword(pw);

const isFirstAccessScreenActive = await FirstAccessScreen.isActive();
if (isFirstAccessScreenActive) throw new Error('The user is not onboarded');
const isFirstAccessFlowsActive = await FirstAccessFlows.isActive();
if (isFirstAccessFlowsActive) throw new Error('The user is not onboarded');

throw new Error('The application is in an unknown state');
};

/**
* Navigate to extension => Then we should be on one of the following screens:
* - DashboardScreen => Locks the app
* - UnlockScreen => Immediately returns as we are already locked
* - FirstAccessScreen => Immediately throws an error as we are not onboarded
*/
export const lock = async () => {
await NavigationUtils.goToExtension();

const isDashboardScreenActive = await DashboardScreen.isActive();
if (isDashboardScreenActive) return await DashboardScreen.lockApp();
if (isDashboardScreenActive) return DashboardScreen.lockApp();

const isUnlockScreenActive = await UnlockScreen.isActive();
if (isUnlockScreenActive) return;
const isUnlockFlowsActive = await UnlockFlows.isActive();
if (isUnlockFlowsActive) return;

const isFirstAccessScreenActive = await FirstAccessScreen.isActive();
if (isFirstAccessScreenActive) throw new Error('The user is not onboarded');
const isFirstAccessFlowsActive = await FirstAccessFlows.isActive();
if (isFirstAccessFlowsActive) throw new Error('The user is not onboarded');

throw new Error('The application is in an unknown state');
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import NavigationUtils from '../../utils/NavigationUtils';
import PasswordPrompt from '../PasswordPrompt';
import TestDefaults from '../../TestDefaults';
import Locators from '../../selenium/Locators';
import { extension } from '../../selenium/WebDriver';
import NavigationUtils from '../utils/NavigationUtils';
import TestDefaults from '../TestDefaults';
import Locators from '../selenium/Locators';
import { extension } from '../selenium/WebDriver';
import PasswordFlows from './PasswordFlows';

const approveAndSign = async (password?: string) => {
await approve();
Expand All @@ -13,7 +13,7 @@ const sign = async (password?: string) => {
const pw = password || TestDefaults.PASSWORD;
//Click the "Sign Cert" button
await extension.driver.waitAndClick(Locators.byId('signCertificateButton'));
await PasswordPrompt.submitPassword(pw);
await PasswordFlows.submitPassword(pw);
};

const approve = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Locators from '../../selenium/Locators';
import { ROUTES } from '../../enums';
import ScreenUtils from '../../utils/ScreenUtils';
import { extension } from '../../selenium/WebDriver';
import Locators from '../selenium/Locators';
import { ROUTES } from '../enums';
import ScreenUtils from '../utils/ScreenUtils';
import { extension } from '../selenium/WebDriver';

const isActive = async () => {
const locator = Locators.byId('goToHomepage');
Expand Down
36 changes: 36 additions & 0 deletions tests/e2e/src/extension/flows/ConnectFlows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { By } from 'selenium-webdriver';
import { extension } from '../selenium/WebDriver';

const connectWallet = async () => {
// Click connect button
const vdkButtonShadowRoot = await extension.driver
.findElement(By.css('vdk-button'))
.getShadowRoot();
const connectButton = await vdkButtonShadowRoot.findElement(
By.css('vdk-connect-button'),
);
const connectButtonShadowRoot = await connectButton.getShadowRoot();
const button = await connectButtonShadowRoot.findElement(By.css('button'));
await button.click();

// // Click veworld source
const vdkModalShadowRoot = await extension.driver
.findElement(By.css('vdk-modal'))
.getShadowRoot();
const vdkConnectModal = await vdkModalShadowRoot.findElement(
By.css('vdk-connect-modal'),
);
const vdkBaseModalShadowRoot = await vdkConnectModal.getShadowRoot();
const vdkSourceCard = await vdkBaseModalShadowRoot.findElements(
By.css('vdk-source-card'),
);
const vdkSourceCardShadowRoot = await vdkSourceCard[0].getShadowRoot();
const cardButton = await vdkSourceCardShadowRoot.findElement(
By.css('button'),
);
await cardButton.click();
};

export default {
connectWallet,
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'assert';
import { ROUTES } from '../enums';
import ScreenUtils from '../utils/ScreenUtils';
import { extension } from '../selenium/WebDriver';
import Locators from '../selenium/Locators';
import NavigationUtils from '../utils/NavigationUtils';
import assert from 'assert';
import { ROUTES } from 'extension/enums';

const isActive = async () => {
const locator = Locators.byId('yourBalanceTitle');
Expand Down
60 changes: 0 additions & 60 deletions tests/e2e/src/extension/flows/DeviceManagementFlows.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Locators from '../../selenium/Locators';
import ScreenUtils from '../../utils/ScreenUtils';
import { extension } from '../../selenium/WebDriver';
import Locators from '../selenium/Locators';
import ScreenUtils from '../utils/ScreenUtils';
import { extension } from '../selenium/WebDriver';

const isActive = async () => {
const locator = Locators.byDataTestId('continueOnboardingButton');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Locators from '../../selenium/Locators';
import TestDefaults from '../../TestDefaults';
import { ROUTES } from '../../enums';
import ScreenUtils from '../../utils/ScreenUtils';
import { extension } from '../../selenium/WebDriver';
import Locators from '../selenium/Locators';
import TestDefaults from '../TestDefaults';
import { ROUTES } from '../enums';
import ScreenUtils from '../utils/ScreenUtils';
import { extension } from '../selenium/WebDriver';

const isActive = async () => {
const locator = Locators.byDataTestId('importLocalWalletMnemonicButton');
Expand Down
Loading

0 comments on commit 796e6ad

Please sign in to comment.