chore(cypress): remove cypress project id (#3739)

This commit is contained in:
Joe Tsang 2023-05-12 13:44:22 +01:00 committed by GitHub
parent fcd4541625
commit fae61c28ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 130 additions and 100 deletions

View File

@ -33,5 +33,4 @@ jobs:
config: baseUrl=${{ github.event.inputs.url }} config: baseUrl=${{ github.event.inputs.url }}
env: grepTags=@live env: grepTags=@live
env: env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -66,7 +66,7 @@ jobs:
###### ######
- name: Run Cypress tests - name: Run Cypress tests
run: yarn nx run ${{ matrix.project }}:e2e ${{ env.SKIP_CACHE }} --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome --env.grepTags="${{ inputs.tags }}" run: yarn nx run ${{ matrix.project }}:e2e ${{ env.SKIP_CACHE }} --browser chrome --env.grepTags="${{ inputs.tags }}"
working-directory: frontend-monorepo working-directory: frontend-monorepo
env: env:
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }} CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}

View File

@ -57,7 +57,6 @@ context(
// 2001-STKE-002, 2001-STKE-032 // 2001-STKE-002, 2001-STKE-032
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.visit('/'); cy.visit('/');
cy.validatorsSelfDelegate();
ethereumWalletConnect(); ethereumWalletConnect();
// this is a workaround for #2422 which can be removed once issue is resolved // this is a workaround for #2422 which can be removed once issue is resolved
cy.associateTokensToVegaWallet('4'); cy.associateTokensToVegaWallet('4');

View File

@ -31,9 +31,6 @@ const totalPenaltyToolTip = '[data-testid="total-penalty-tooltip"]';
const epochCountDown = '[data-testid="epoch-countdown"]'; const epochCountDown = '[data-testid="epoch-countdown"]';
const stakeNumberRegex = /^\d{1,3}(,\d{3})*(\.\d+)?$/; const stakeNumberRegex = /^\d{1,3}(,\d{3})*(\.\d+)?$/;
// If running locally, validators need to have self-stake to be displayed
// Run cy.validatorsSelfDelegate() in before hook
context('Validators Page - verify elements on page', function () { context('Validators Page - verify elements on page', function () {
before('navigate to validators page', function () { before('navigate to validators page', function () {
cy.visit('/validators'); cy.visit('/validators');

View File

@ -33,4 +33,6 @@ before(() => {
aliasGQLQuery(req, 'ChainId', chainIdQuery()); aliasGQLQuery(req, 'ChainId', chainIdQuery());
aliasGQLQuery(req, 'Statistics', statisticsQuery()); aliasGQLQuery(req, 'Statistics', statisticsQuery());
}); });
// Self stake validators so they are displayed
cy.validatorsSelfDelegate();
}); });

View File

@ -1,4 +1,6 @@
import { gql } from 'graphql-request';
import { selfDelegate } from '../capsule/self-delegate'; import { selfDelegate } from '../capsule/self-delegate';
import { requestGQL, setGraphQLEndpoint } from '../capsule/request';
declare global { declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace // eslint-disable-next-line @typescript-eslint/no-namespace
@ -19,112 +21,143 @@ export const addValidatorsSelfDelegate = () => {
vegaUrl: Cypress.env('VEGA_URL'), vegaUrl: Cypress.env('VEGA_URL'),
faucetUrl: Cypress.env('FAUCET_URL'), faucetUrl: Cypress.env('FAUCET_URL'),
}; };
setGraphQLEndpoint(config.vegaUrl);
cy.wrap(getStakedByOperator()).as('selfStakeAmount');
cy.get('@selfStakeAmount').then((selfStakeAmount) => {
if (String(selfStakeAmount) == '0') {
// Get node wallet recovery phrases
cy.exec('vegacapsule nodes ls --home-path ~/.vegacapsule/testnet/')
.its('stdout')
.then((result) => {
const obj = JSON.parse(result);
console.log(obj);
cy.writeFile(
'./src/fixtures/wallet/node0RecoveryPhrase',
obj['testnet-nodeset-validators-0-validator'].Vega.NodeWalletInfo
.VegaWalletRecoveryPhrase
);
cy.writeFile(
'./src/fixtures/wallet/node1RecoveryPhrase',
obj['testnet-nodeset-validators-1-validator'].Vega.NodeWalletInfo
.VegaWalletRecoveryPhrase
);
cy.wrap(
obj['testnet-nodeset-validators-0-validator'].Vega.NodeWalletInfo
.VegaWalletPublicKey
).as('node0PubKey');
cy.wrap(
obj['testnet-nodeset-validators-1-validator'].Vega.NodeWalletInfo
.VegaWalletPublicKey
).as('node1PubKey');
// Get node wallet recovery phrases cy.wrap(
cy.exec('vegacapsule nodes ls --home-path ~/.vegacapsule/testnet/') obj['testnet-nodeset-validators-0-validator'].Vega.NodeWalletInfo
.its('stdout') .VegaWalletID
.then((result) => { ).as('node0Id');
const obj = JSON.parse(result); cy.wrap(
console.log(obj); obj['testnet-nodeset-validators-1-validator'].Vega.NodeWalletInfo
cy.writeFile( .VegaWalletID
'./src/fixtures/wallet/node0RecoveryPhrase', ).as('node1Id');
obj['testnet-nodeset-validators-0-validator'].Vega.NodeWalletInfo });
.VegaWalletRecoveryPhrase
// Import node wallets
cy.exec(
'vega wallet import -w node0_wallet --recovery-phrase-file ./src/fixtures/wallet/node0RecoveryPhrase -p ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet'
); );
cy.writeFile( cy.exec(
'./src/fixtures/wallet/node1RecoveryPhrase', 'vega wallet import -w node1_wallet --recovery-phrase-file ./src/fixtures/wallet/node1RecoveryPhrase -p ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet'
obj['testnet-nodeset-validators-1-validator'].Vega.NodeWalletInfo
.VegaWalletRecoveryPhrase
); );
cy.wrap(
obj['testnet-nodeset-validators-0-validator'].Vega.NodeWalletInfo
.VegaWalletPublicKey
).as('node0PubKey');
cy.wrap(
obj['testnet-nodeset-validators-1-validator'].Vega.NodeWalletInfo
.VegaWalletPublicKey
).as('node1PubKey');
cy.wrap( // Initialise api token
obj['testnet-nodeset-validators-0-validator'].Vega.NodeWalletInfo cy.exec(
.VegaWalletID 'vega wallet api-token init --home ~/.vegacapsule/testnet/wallet --passphrase-file ./src/fixtures/wallet/passphrase'
).as('node0Id'); );
cy.wrap(
obj['testnet-nodeset-validators-1-validator'].Vega.NodeWalletInfo
.VegaWalletID
).as('node1Id');
});
// Import node wallets // Generate api tokens for wallets
cy.exec( cy.exec(
'vega wallet import -w node0_wallet --recovery-phrase-file ./src/fixtures/wallet/node0RecoveryPhrase -p ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet' 'vega wallet api-token generate --wallet-name node0_wallet --tokens-passphrase-file ./src/fixtures/wallet/passphrase --wallet-passphrase-file ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet'
); )
cy.exec( .its('stdout')
'vega wallet import -w node1_wallet --recovery-phrase-file ./src/fixtures/wallet/node1RecoveryPhrase -p ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet' .then((result) => {
); const apiToken = result.match('[a-zA-Z0-9]{64}');
if (apiToken) {
cy.wrap(apiToken[0]).as('node0ApiToken');
}
});
// Initialise api token cy.exec(
cy.exec( 'vega wallet api-token generate --wallet-name node1_wallet --tokens-passphrase-file ./src/fixtures/wallet/passphrase --wallet-passphrase-file ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet'
'vega wallet api-token init --home ~/.vegacapsule/testnet/wallet --passphrase-file ./src/fixtures/wallet/passphrase' )
); .its('stdout')
.then((result) => {
const apiToken = result.match('[a-zA-Z0-9]{64}');
if (apiToken) {
cy.wrap(apiToken[0]).as('node1ApiToken');
}
});
// Generate api tokens for wallets cy.updateCapsuleMultiSig();
cy.exec( cy.highlight('Validators self-delegating');
'vega wallet api-token generate --wallet-name node0_wallet --tokens-passphrase-file ./src/fixtures/wallet/passphrase --wallet-passphrase-file ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet'
)
.its('stdout')
.then((result) => {
const apiToken = result.match('[a-zA-Z0-9]{64}');
if (apiToken) {
cy.wrap(apiToken[0]).as('node0ApiToken');
}
});
cy.exec( // Self delegating Node 0 wallet
'vega wallet api-token generate --wallet-name node1_wallet --tokens-passphrase-file ./src/fixtures/wallet/passphrase --wallet-passphrase-file ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet' cy.get('@node0PubKey').then((node0PubKey) => {
) cy.get('@node0ApiToken').then((node0ApiToken) => {
.its('stdout') cy.get('@node0Id').then((node0Id) => {
.then((result) => { cy.wrap(
const apiToken = result.match('[a-zA-Z0-9]{64}'); selfDelegate(
if (apiToken) { config,
cy.wrap(apiToken[0]).as('node1ApiToken'); String(node0PubKey),
} String(node0ApiToken),
}); String(node0Id)
),
cy.updateCapsuleMultiSig(); { timeout: 60000 }
cy.highlight('Validators self-delegating'); );
// Self delegating Node 1 wallet
// Self delegating Node 0 wallet cy.get('@node1PubKey').then((node1PubKey) => {
cy.get('@node0PubKey').then((node0PubKey) => { cy.get('@node1ApiToken').then((node1ApiToken) => {
cy.get('@node0ApiToken').then((node0ApiToken) => { cy.get('@node1Id').then((node1Id) => {
cy.get('@node0Id').then((node0Id) => { cy.wrap(
cy.wrap( selfDelegate(
selfDelegate( config,
config, String(node1PubKey),
String(node0PubKey), String(node1ApiToken),
String(node0ApiToken), String(node1Id)
String(node0Id) ),
), { timeout: 60000 }
{ timeout: 60000 } );
); });
// Self delegating Node 1 wallet });
cy.get('@node1PubKey').then((node1PubKey) => {
cy.get('@node1ApiToken').then((node1ApiToken) => {
cy.get('@node1Id').then((node1Id) => {
cy.wrap(
selfDelegate(
config,
String(node1PubKey),
String(node1ApiToken),
String(node1Id)
),
{ timeout: 60000 }
);
}); });
}); });
}); });
}); });
}); }
}); });
}); });
}; };
async function getStakedByOperator() {
const query = gql`
query ExplorerNodes {
nodesConnection {
edges {
node {
stakedByOperator
}
}
}
}
`;
const res = await requestGQL<{
nodesConnection: {
edges: Array<{
node: {
stakedByOperator: string;
};
}>;
};
}>(query);
return res.nodesConnection.edges[0].node.stakedByOperator;
}