From 0514c5035e1f278090515f5604ff0e10ea511e39 Mon Sep 17 00:00:00 2001 From: Palash gupta Date: Wed, 16 Feb 2022 14:20:48 +0530 Subject: [PATCH] test: trace test is updated --- .../cypress/integration/trace/index.spec.ts | 168 ++++++++++-------- 1 file changed, 98 insertions(+), 70 deletions(-) diff --git a/frontend/cypress/integration/trace/index.spec.ts b/frontend/cypress/integration/trace/index.spec.ts index 82ac93f104..3ca79ecdce 100644 --- a/frontend/cypress/integration/trace/index.spec.ts +++ b/frontend/cypress/integration/trace/index.spec.ts @@ -30,97 +30,125 @@ describe('Trace', () => { cy.visit(Cypress.env('baseUrl') + `${ROUTES.TRACE}`); }); - // it('First Initial Load should go with 3 AJAX request', () => { - // cy.wait(['@Filters', '@Graph', '@Table']).then((e) => { - // const [filter, graph, table] = e; + it('First Initial Load should go with 3 AJAX request', () => { + cy.wait(['@Filters', '@Graph', '@Table']).then((e) => { + const [filter, graph, table] = e; - // const { body: filterBody } = filter.request; - // const { body: graphBody } = graph.request; - // const { body: tableBody } = table.request; + const { body: filterBody } = filter.request; + const { body: graphBody } = graph.request; + const { body: tableBody } = table.request; - // expect(filterBody.exclude.length).to.equal(0); - // expect(filterBody.getFilters.length).to.equal(3); - // filterBody.getFilters.forEach((filter: TraceFilterEnum) => { - // expect(filter).to.be.oneOf(['duration', 'status', 'serviceName']); - // }); + expect(filterBody.exclude.length).to.equal(0); + expect(filterBody.getFilters.length).to.equal(3); + filterBody.getFilters.forEach((filter: TraceFilterEnum) => { + expect(filter).to.be.oneOf(['duration', 'status', 'serviceName']); + }); - // expect(graphBody.function).to.be.equal('count'); - // expect(graphBody.exclude.length).to.be.equal(0); - // expect(typeof graphBody.exclude).to.be.equal('object'); + expect(graphBody.function).to.be.equal('count'); + expect(graphBody.exclude.length).to.be.equal(0); + expect(typeof graphBody.exclude).to.be.equal('object'); - // expect(tableBody.tags.length).to.be.equal(0); - // expect(typeof tableBody.tags).equal('object'); + expect(tableBody.tags.length).to.be.equal(0); + expect(typeof tableBody.tags).equal('object'); - // expect(tableBody.exclude.length).equals(0); - // }); - // }); + expect(tableBody.exclude.length).equals(0); + }); + }); - // it('Render Time Request Response In All 3 Request', () => { - // cy.wait(['@Filters', '@Graph', '@Table']).then((e) => { - // const [filter, graph, table] = e; + it('Render Time Request Response In All 3 Request', () => { + cy.wait(['@Filters', '@Graph', '@Table']).then((e) => { + const [filter, graph, table] = e; - // expect(filter.response?.body).to.be.not.undefined; - // expect(filter.response?.body).to.be.not.NaN; + expect(filter.response?.body).to.be.not.undefined; + expect(filter.response?.body).to.be.not.NaN; - // expect(JSON.stringify(filter.response?.body)).to.be.equals( - // JSON.stringify(FilterInitialResponse), - // ); + expect(JSON.stringify(filter.response?.body)).to.be.equals( + JSON.stringify(FilterInitialResponse), + ); - // expect(JSON.stringify(graph.response?.body)).to.be.equals( - // JSON.stringify(GraphInitialResponse), - // ); + expect(JSON.stringify(graph.response?.body)).to.be.equals( + JSON.stringify(GraphInitialResponse), + ); - // expect(JSON.stringify(table.response?.body)).to.be.equals( - // JSON.stringify(TableInitialResponse), - // ); - // }); - // cy.get('@Filters.all').should('have.length', 1); - // cy.get('@Graph.all').should('have.length', 1); - // cy.get('@Table.all').should('have.length', 1); - // }); + expect(JSON.stringify(table.response?.body)).to.be.equals( + JSON.stringify(TableInitialResponse), + ); + }); + cy.get('@Filters.all').should('have.length', 1); + cy.get('@Graph.all').should('have.length', 1); + cy.get('@Table.all').should('have.length', 1); + }); - // it('Clear All', () => { - // cy.wait(['@Filters', '@Graph', '@Table']); + it('Clear All', () => { + cy.wait(['@Filters', '@Graph', '@Table']); - // expect(cy.findAllByText('Clear All')).not.to.be.undefined; + expect(cy.findAllByText('Clear All')).not.to.be.undefined; - // cy - // .window() - // .its('store') - // .invoke('getState') - // .then((e: AppState) => { - // const { traces } = e; - // expect(traces.isFilterExclude.get('status')).to.be.undefined; - // expect(traces.selectedFilter.size).to.be.equals(0); - // }); + cy + .window() + .its('store') + .invoke('getState') + .then((e: AppState) => { + const { traces } = e; + expect(traces.isFilterExclude.get('status')).to.be.undefined; + expect(traces.selectedFilter.size).to.be.equals(0); + }); - // cy.findAllByText('Clear All').then((e) => { - // const [firstStatusClear] = e; + cy.findAllByText('Clear All').then((e) => { + const [firstStatusClear] = e; - // firstStatusClear.click(); + firstStatusClear.click(); - // cy.wait(['@Filters', '@Graph', '@Table']); + cy.wait(['@Filters', '@Graph', '@Table']); - // // insuring the api get call - // cy.get('@Filters.all').should('have.length', 2); - // cy.get('@Graph.all').should('have.length', 2); - // cy.get('@Table.all').should('have.length', 2); + // insuring the api get call + cy.get('@Filters.all').should('have.length', 2); + cy.get('@Graph.all').should('have.length', 2); + cy.get('@Table.all').should('have.length', 2); - // cy - // .window() - // .its('store') - // .invoke('getState') - // .then((e: AppState) => { - // const { traces } = e; + cy + .window() + .its('store') + .invoke('getState') + .then((e: AppState) => { + const { traces } = e; - // expect(traces.isFilterExclude.get('status')).to.be.equals(false); - // expect(traces.userSelectedFilter.get('status')).to.be.undefined; - // expect(traces.selectedFilter.size).to.be.equals(0); - // }); - // }); - // }); + expect(traces.isFilterExclude.get('status')).to.be.equals(false); + expect(traces.userSelectedFilter.get('status')).to.be.undefined; + expect(traces.selectedFilter.size).to.be.equals(0); + }); + }); + }); it('Un Selecting one option from status', () => { cy.wait(['@Filters', '@Graph', '@Table']); + + cy.get('input[type="checkbox"]').then((e) => { + const [errorCheckbox] = e; + errorCheckbox.click(); + + cy.wait(['@Filters', '@Graph', '@Table']).then((e) => { + const [filter, graph, table] = e; + const filterBody = filter.request.body; + const graphBody = graph.request.body; + const tableBody = table.request.body; + + expect(filterBody.exclude).not.to.be.undefined; + expect(filterBody.exclude.length).not.to.be.equal(0); + expect(filterBody.exclude[0] === 'status').to.be.true; + + expect(graphBody.exclude).not.to.be.undefined; + expect(graphBody.exclude.length).not.to.be.equal(0); + expect(graphBody.exclude[0] === 'status').to.be.true; + + expect(tableBody.exclude).not.to.be.undefined; + expect(tableBody.exclude.length).not.to.be.equal(0); + expect(tableBody.exclude[0] === 'status').to.be.true; + }); + + cy.get('@Filters.all').should('have.length', 2); + cy.get('@Graph.all').should('have.length', 2); + cy.get('@Table.all').should('have.length', 2); + }); }); });