signoz/frontend/cypress/CustomFunctions/checkRouteDefaultGlobalTimeOptions.ts
pal-sig ae4f75e54b
test(FE):Cypress global time test case (#348)
* chore: cypress version is updated

* chore: tsconfig is updated

* update: default fixture json for the api are added

* feat: redux-store is exposed to the Cypress

* test: Login test is updated

* test: global time test for default and metrics application is updated

* chore: removed duplicate test case and commented unused lines
2021-10-22 17:07:57 +05:30

50 lines
1.1 KiB
TypeScript

import {
getDefaultOption,
getOptions,
} from 'container/Header/DateTimeSelection/config';
// import { AppState } from 'store/reducers';
const CheckRouteDefaultGlobalTimeOptions = ({
route,
}: CheckRouteDefaultGlobalTimeOptionsProps): void => {
cy.visit(Cypress.env('baseUrl') + route);
const allOptions = getOptions(route);
const defaultValue = getDefaultOption(route);
const defaultSelectedOption = allOptions.find((e) => e.value === defaultValue);
expect(defaultSelectedOption).not.undefined;
cy
.findAllByTestId('dropDown')
.find('span')
.then((el) => {
const elements = el.get();
const item = elements[1];
expect(defaultSelectedOption?.label).to.be.equals(
item.innerText,
'Default option is not matching',
);
});
// cy
// .window()
// .its('store')
// .invoke('getState')
// .then((e: AppState) => {
// const { globalTime } = e;
// const { maxTime, minTime } = globalTime;
// // @TODO match the global min time and max time according to the selected option
// });
};
export interface CheckRouteDefaultGlobalTimeOptionsProps {
route: string;
}
export default CheckRouteDefaultGlobalTimeOptions;