From a07b8999c0f0c745678dec42d9000772e2995cd8 Mon Sep 17 00:00:00 2001 From: Palash gupta Date: Wed, 16 Feb 2022 09:27:06 +0530 Subject: [PATCH] test: initial test is updated --- .../cypress/integration/trace/index.spec.ts | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 frontend/cypress/integration/trace/index.spec.ts diff --git a/frontend/cypress/integration/trace/index.spec.ts b/frontend/cypress/integration/trace/index.spec.ts new file mode 100644 index 0000000000..82ac93f104 --- /dev/null +++ b/frontend/cypress/integration/trace/index.spec.ts @@ -0,0 +1,126 @@ +import ROUTES from 'constants/routes'; +import { TraceFilterEnum } from 'types/reducer/trace'; +import TableInitialResponse from '../../fixtures/trace/initialSpans.json'; +import FilterInitialResponse from '../../fixtures/trace/initialSpanFilter.json'; +import GraphInitialResponse from '../../fixtures/trace/initialAggregates.json'; +import { AppState } from 'store/reducers'; + +describe('Trace', () => { + beforeEach(() => { + window.localStorage.setItem('isLoggedIn', 'yes'); + + cy + .intercept('POST', '**/aggregates', { + fixture: 'trace/initialAggregates', + }) + .as('Graph'); + + cy + .intercept('POST', '**/getFilteredSpans', { + fixture: 'trace/initialSpans', + }) + .as('Table'); + + cy + .intercept('POST', '**/api/v1/getSpanFilters', { + fixture: 'trace/initialSpanFilter', + }) + .as('Filters'); + + 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; + + // 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(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.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; + + // 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(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); + // }); + + // it('Clear All', () => { + // cy.wait(['@Filters', '@Graph', '@Table']); + + // 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.findAllByText('Clear All').then((e) => { + // const [firstStatusClear] = e; + + // firstStatusClear.click(); + + // 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); + + // 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); + // }); + // }); + // }); + + it('Un Selecting one option from status', () => { + cy.wait(['@Filters', '@Graph', '@Table']); + }); +});