Skip to content

Commit

Permalink
fix: cypress request intercept
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtiti committed Sep 3, 2024
1 parent a144a67 commit 0bc0cfb
Show file tree
Hide file tree
Showing 6 changed files with 10,000 additions and 6,973 deletions.
3 changes: 3 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ export default defineConfig({
e2e: {
baseUrl: 'http://localhost:5173',
},
env: {
NEXT_PUBLIC_API_BASE_URL: 'http://mock-api:3000',
},
});
12 changes: 12 additions & 0 deletions cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
describe('Navigation tests', () => {
beforeEach(() => {
Cypress.env('NEXT_PUBLIC_API_BASE_URL');

// Intercept the API requests and provide mock responses
cy.intercept('GET', '**/metrics/ecosystem', { fixture: 'ecosystemMockData.json' }).as('getEcosystemData');
cy.intercept('GET', '**/metrics/zkchain/*', { fixture: 'chainMockData.json' }).as('getChainData');

cy.visit('/');
});

Expand All @@ -18,6 +24,10 @@ describe('Navigation tests', () => {
cy.getByTestId('chain-row').should('be.visible').click();
cy.url().should('include', '/324');

// Wait for the mock data to be loaded
cy.wait('@getChainData');
cy.getByTestId('chain-id').should('be.visible').and('contain', '324');

cy.getByTestId('home-breadcrumb').click();
cy.url().should('eq', 'http://localhost:5173/');
cy.getByTestId('search-bar').find('input').should('have.value', '');
Expand All @@ -36,6 +46,8 @@ describe('Navigation tests', () => {
cy.getByTestId('chain-row').first().click();
cy.url().should('include', '/324');

// Wait for the mock data to be loaded
cy.wait('@getChainData');
cy.getByTestId('chain-id').should('be.visible').and('contain', '324');
});
});
Loading

0 comments on commit 0bc0cfb

Please sign in to comment.