palash-signoz 66b423588e
Feature(FE): cypress base test case are updated (#275)
* chore: video config is updated as it will not generate any video while running cypress

* chore: cypress.env.json is added in the env file

* chore: tsConfig is updated

* feature: Cypress is updated with some of the test cases

* chore: default test case is removed

* chore: convertToNanoSecondsToSecond function is updated

* chore: lock files, node_modules are ignored in git

* test: metric are updated

Co-authored-by: Ankit Nayan <ankit@signoz.io>
2021-08-27 12:21:24 +05:30

63 lines
1.6 KiB
TypeScript

/// <reference types="cypress" />
import defaultApps from "../../fixtures/defaultApp.json";
import convertToNanoSecondsToSecond from "lib/convertToNanoSecondsToSecond";
describe("Metrics", () => {
beforeEach(() => {
cy.visit(Cypress.env("baseUrl"));
const testEmail = "test@test.com";
const firstName = "Test";
cy
.intercept("GET", "/api/v1//services?start*", { fixture: "defaultApp.json" })
.as("defaultApps");
cy.login({
email: testEmail,
name: firstName,
});
});
it("Default Apps", () => {
cy.wait("@defaultApps");
cy.get("tbody").then((elements) => {
const trElements = elements.children();
expect(trElements.length).to.be.equal(defaultApps.length);
const getChildren = (row: Element): Element => {
if (row.children.length === 0) {
return row;
}
return getChildren(row.children[0]);
};
// this is row element
trElements.map((index, element) => {
const [
applicationElement,
p99Element,
errorRateElement,
rpsElement,
] = element.children;
const applicationName = getChildren(applicationElement).innerHTML;
const p99Name = getChildren(p99Element).innerHTML;
const errorRateName = getChildren(errorRateElement).innerHTML;
const rpsName = getChildren(rpsElement).innerHTML;
const { serviceName, p99, errorRate, callRate } = defaultApps[index];
expect(applicationName).to.be.equal(serviceName);
expect(p99Name).to.be.equal(convertToNanoSecondsToSecond(p99).toString());
expect(errorRateName).to.be.equals(
parseFloat(errorRate.toString()).toFixed(2),
);
expect(rpsName).to.be.equals(callRate.toString());
});
});
});
});
export {};