Test/234 switch public key (#254)

* Test for switching public key

* Add missing variable

* Add background step

* Fix yaml error

* Increase timeout for cy.wait

* Assert pub key using Cypress env variable

* Fix module error

* Add string

* Remove timeout

* Removed react-helper import and added Cypress env variable
This commit is contained in:
Joe Tsang 2022-04-19 12:12:08 +01:00 committed by GitHub
parent 09e4603eec
commit f0fdecb490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 7 deletions

View File

@ -50,6 +50,8 @@ jobs:
run: ./vegawallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase
- name: Import config
run: ./vegawallet network import --from-url https://raw.githubusercontent.com/vegaprotocol/networks/master/fairground/fairground.toml
- name: Create public key 2
run: ./vegawallet key generate -w UI_Trading_Test -p ./passphrase
- name: Start service
run: ./vegawallet service run --network fairground &
@ -95,6 +97,8 @@ jobs:
run: ./vegawallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase
- name: Import config
run: ./vegawallet network import --from-url https://raw.githubusercontent.com/vegaprotocol/networks/master/fairground/fairground.toml
- name: Create public key 2
run: ./vegawallet key generate -w UI_Trading_Test -p ./passphrase
- name: Start service
run: ./vegawallet service run --network fairground &

View File

@ -15,6 +15,9 @@
"projectId": "et4snf",
"env": {
"vegaPublicKey": "47836c253520d2661bf5bed6339c0de08fd02cf5d4db0efee3b4373f20c7d278",
"vegaPublicKey2": "1a18cdcaaa4f44a57b35a4e9b77e0701c17a476f2b407620f8c17371740cf2e4",
"truncatedVegaPubKey": "47836c…c7d278",
"truncatedVegaPubKey2": "1a18cd…0cf2e4",
"tsConfig": "tsconfig.json",
"TAGS": "not @todo and not @ignore and not @manual"
}

View File

@ -1,22 +1,24 @@
Feature: Home page
Scenario: Visit Home page
Background:
Given I am on the homepage
Scenario: Visit Portfolio page
Given I am on the homepage
And I navigate to portfolio page
Scenario: Visit Markets page
Given I am on the homepage
And I navigate to markets page
Scenario: Able to switch public key for connected Vega wallet
Given I connect to Vega Wallet
When I open wallet dialog
And select a different public key
Then public key is switched
Scenario: Unable to connect Vega wallet with incorrect credentials
Given I am on the homepage
When I try to connect Vega wallet with incorrect details
Then wallet not running error message is displayed
Scenario: Unable to connect Vega wallet with blank fields
Given I am on the homepage
When I try to connect Vega wallet with blank fields
Then wallet field validation errors are shown

View File

@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps';
import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import VegaWallet from '../vega-wallet';
const vegaWallet = new VegaWallet();
@ -28,3 +28,16 @@ When('I connect to Vega Wallet', () => {
);
vegaWallet.clickConnectVegaWallet();
});
When('I open wallet dialog', () => {
vegaWallet.validatePublicKeyDisplayed(Cypress.env('truncatedVegaPubKey')); // Default Test wallet pub key
vegaWallet.clickOnWalletConnectDialog();
});
When('select a different public key', () => {
vegaWallet.selectPublicKey();
});
Then('public key is switched', () => {
vegaWallet.validatePublicKeyDisplayed(Cypress.env('truncatedVegaPubKey2')); // Second public key for test wallet
});

View File

@ -2,12 +2,13 @@ export default class VegaWallet {
connectVegaBtn = 'connect-vega-wallet';
walletConnectors = 'connectors-list';
walletForm = 'rest-connector-form';
selectPublicKeyBtn = 'select-keypair-button';
walletInputError = 'input-wallet-error';
walletFormError = 'form-error';
inputError = 'input-error-text';
openVegaWalletConnectDialog() {
cy.getByTestId(this.connectVegaBtn).click();
this.clickOnWalletConnectDialog();
cy.contains('Connects using REST to a running Vega wallet service');
cy.getByTestId(this.walletConnectors).find('button').click();
}
@ -40,4 +41,19 @@ export default class VegaWallet {
cy.getByTestId(this.walletInputError).should('have.text', 'Required');
cy.getByTestId(this.inputError).should('have.text', 'Required');
}
validatePublicKeyDisplayed(expectedTruncatedKey: string) {
cy.getByTestId(this.connectVegaBtn).should(
'have.text',
expectedTruncatedKey
);
}
selectPublicKey() {
cy.getByTestId(this.selectPublicKeyBtn).click();
}
clickOnWalletConnectDialog() {
cy.getByTestId(this.connectVegaBtn).click();
}
}