Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebrand staking page #474

Merged
merged 18 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/delegation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('delegation', () => {
cy.resetBlockchain().login();

// Approve, deposit and stake
cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets rather use the built in data-testid="..." and cy.findByTestId(...) for all of these cy.dataCy() usages that you've added.

Copy link
Collaborator Author

@Anboias Anboias Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Replaced both dataCy and findByRole with findByTestId.

If you meant to replace only dataCy with findByTestId, I'll quickly adjust.

cy.get('#modal').find('input').type('200');
cy.findByText('Approve').click();
cy.findByText('Deposit and Stake').click();
Expand Down
9 changes: 6 additions & 3 deletions cypress/e2e/keyboard-navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ describe('keyboard navigation and accessibility', () => {
pressTabAndAssertFocusOutline(() => cy.findAllByText('Api3 Market').filter(':visible').closest('a'));
pressTabAndAssertFocusOutline(() => cy.findAllByText('Docs').filter(':visible').closest('a'));

pressTabAndAssertFocusOutline(() =>
cy.dataCy('connect-wallet-staking').findByRole('button', { name: 'Connect Wallet' })
);
pressTabAndAssertFocusOutline(() => cy.findByText('About API3'));
pressTabAndAssertFocusOutline(() => cy.findByText('Error Reporting'));
pressTabAndAssertFocusOutline(() => cy.findByText('Github'));
Expand All @@ -36,7 +39,7 @@ describe('keyboard navigation and accessibility', () => {
});

it('uses focus lock (cannot tab outside modal)', () => {
cy.findByText('+ Deposit').click();
cy.findByText('Deposit').click();

cy.get('#modal').find('input').should('have.focus');
cy.get('#modal').find('input').type('123');
Expand All @@ -52,12 +55,12 @@ describe('keyboard navigation and accessibility', () => {

it('can use keyboard to "press" the buttons', () => {
// Can close the modal by pressing ESC
cy.findByText('+ Deposit').click();
cy.findByText('Deposit').click();
cy.get('body').type('{esc}');
cy.get('#modal').find('input').should('not.exist');

// Can deposit by pressing ENTER when button has focus
cy.findByText('+ Deposit').click();
cy.findByText('Deposit').click();
cy.get('#modal').find('input').type('123').tab(); // Tab over "Max" button
pressTabAndAssertFocusOutline(() => cy.findByText('Approve'));

Expand Down
13 changes: 7 additions & 6 deletions cypress/e2e/staking.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ describe('staking', () => {
cy.resetBlockchain().login();

// Approve and deposit
cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
cy.get('#modal').find('input').type('500');
cy.findByText('Approve').click();
cy.findByText('Deposit').should('be.visible');
cy.get('#modal').findByRole('button', { name: 'Deposit' }).should('be.visible');
cy.percySnapshot('Staking: Deposit modal');
cy.findByText('Deposit').click();
cy.get('#modal').findByRole('button', { name: 'Deposit' }).click();
cy.dataCy('balance').should('have.text', '500.0');

// Stake
cy.findByText('+ Stake').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Stake' }).click();
cy.get('#modal').find('input').type('100');
cy.findByText('Stake').click();
cy.get('#modal').findByRole('button', { name: 'Stake' }).click();
cy.dataCy('unstaked').should('have.text', '400.0');
cy.dataCy('withdrawable').should('have.text', '400.0');
cy.dataCy('staked').should('have.text', '100.0');
Expand All @@ -31,7 +32,7 @@ describe('staking', () => {
it('can deposit and stake', () => {
cy.useChainSnapshot('user-staked');

cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
cy.get('#modal').find('input').type('200');
cy.findByText('Deposit and Stake').click();

Expand Down Expand Up @@ -86,7 +87,7 @@ it.skip('user can unstake & withdraw', () => {
cy.resetBlockchain().login();

// Approve and deposit
cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
cy.get('#modal').find('input').type('1000');
cy.findByText('Approve').click();
cy.findByText('Deposit and Stake').click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Cypress.Commands.add('login', () => {
});

// Login
cy.findByRole('button', { name: 'Connect Wallet' }).click();
cy.findAllByRole('button', { name: 'Connect Wallet' }).first().click();

// Web3 Modal
cy.get('w3m-modal')
Expand Down
4 changes: 2 additions & 2 deletions src/pages/dashboard/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const Dashboard = () => {
{!provider && (
<>
{/* Connect Wallet */}
<div className={styles.connectWalletBox}>
<div className={styles.connectWalletBox} data-cy="connect-wallet-staking">
<div className={styles.connectWalletBoxContent}>
<img src={images.infoCircle} alt="connect wallet info" />
<div className={styles.connectWalletBoxText}>
Expand Down Expand Up @@ -81,7 +81,7 @@ const Dashboard = () => {
{/* Staking Pool */}
<p className={classNames(styles.dashboardHeader, provider && styles.extraTopSpacing)}>Staking Pool</p>
<StakingPool />
<div className={styles.cardsWrapper}>
<div className={styles.cardsWrapper} data-cy="staking-cards">
<Card
header={
<CardHeader>
Expand Down
Loading