mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 19:45:54 +08:00
FE(UI):Channels test (#417)
* bug(UI): default tab over setting is resolved * feat(UI): channels test is updated
This commit is contained in:
parent
32750fa2af
commit
3ed4fb2b75
21
frontend/cypress/fixtures/defaultAllChannels.json
Normal file
21
frontend/cypress/fixtures/defaultAllChannels.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"created_at": 1638083159246,
|
||||||
|
"data": "{}",
|
||||||
|
"id": 1,
|
||||||
|
"name": "First Channels",
|
||||||
|
"type": "slack",
|
||||||
|
"updated_at": 1638083159246
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"created_at": 1638083159246,
|
||||||
|
"data": "{}",
|
||||||
|
"id": 2,
|
||||||
|
"name": "Second Channels",
|
||||||
|
"type": "Slack",
|
||||||
|
"updated_at": 1638083159246
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"message": "Success"
|
||||||
|
}
|
52
frontend/cypress/integration/channels/index.spec.ts
Normal file
52
frontend/cypress/integration/channels/index.spec.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import ROUTES from 'constants/routes';
|
||||||
|
|
||||||
|
import defaultAllChannels from '../../fixtures/defaultAllChannels.json';
|
||||||
|
|
||||||
|
describe('Channels', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
window.localStorage.setItem('isLoggedIn', 'yes');
|
||||||
|
|
||||||
|
cy.visit(Cypress.env('baseUrl') + ROUTES.ALL_CHANNELS);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Channels', () => {
|
||||||
|
cy
|
||||||
|
.intercept('**channels**', {
|
||||||
|
statusCode: 200,
|
||||||
|
fixture: 'defaultAllChannels',
|
||||||
|
})
|
||||||
|
.as('All Channels');
|
||||||
|
|
||||||
|
cy.wait('@All Channels');
|
||||||
|
|
||||||
|
cy
|
||||||
|
.get('.ant-tabs-tab')
|
||||||
|
.children()
|
||||||
|
.then((e) => {
|
||||||
|
const child = e.get();
|
||||||
|
|
||||||
|
const secondChild = child[1];
|
||||||
|
|
||||||
|
expect(secondChild.outerText).to.be.equals('Alert Channels');
|
||||||
|
|
||||||
|
expect(secondChild.ariaSelected).to.be.equals('true');
|
||||||
|
});
|
||||||
|
|
||||||
|
cy
|
||||||
|
.get('tbody')
|
||||||
|
.should('be.visible')
|
||||||
|
.then((e) => {
|
||||||
|
const allChildren = e.children().get();
|
||||||
|
expect(allChildren.length).to.be.equals(defaultAllChannels.data.length);
|
||||||
|
|
||||||
|
allChildren.forEach((e, index) => {
|
||||||
|
expect(e.firstChild?.textContent).not.null;
|
||||||
|
expect(e.firstChild?.textContent).to.be.equals(
|
||||||
|
defaultAllChannels.data[index].name,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -15,6 +15,7 @@ const SettingsWrapper = ({
|
|||||||
AlertChannels,
|
AlertChannels,
|
||||||
General,
|
General,
|
||||||
toggleSettingsTab,
|
toggleSettingsTab,
|
||||||
|
defaultRoute,
|
||||||
}: SettingsWrapperProps): JSX.Element => {
|
}: SettingsWrapperProps): JSX.Element => {
|
||||||
const { settingsActiveTab } = useSelector<AppState, AppReducer>(
|
const { settingsActiveTab } = useSelector<AppState, AppReducer>(
|
||||||
(state) => state.app,
|
(state) => state.app,
|
||||||
@ -38,7 +39,7 @@ const SettingsWrapper = ({
|
|||||||
<Tabs
|
<Tabs
|
||||||
destroyInactiveTabPane
|
destroyInactiveTabPane
|
||||||
onChange={(value): void => onChangeHandler(value as SettingTab)}
|
onChange={(value): void => onChangeHandler(value as SettingTab)}
|
||||||
activeKey={settingsActiveTab}
|
activeKey={defaultRoute || settingsActiveTab}
|
||||||
>
|
>
|
||||||
<TabPane tab="General" key="General">
|
<TabPane tab="General" key="General">
|
||||||
<General />
|
<General />
|
||||||
@ -63,6 +64,7 @@ const mapDispatchToProps = (
|
|||||||
interface SettingsWrapperProps extends DispatchProps {
|
interface SettingsWrapperProps extends DispatchProps {
|
||||||
General: () => JSX.Element;
|
General: () => JSX.Element;
|
||||||
AlertChannels: () => JSX.Element;
|
AlertChannels: () => JSX.Element;
|
||||||
|
defaultRoute?: SettingTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps)(SettingsWrapper);
|
export default connect(null, mapDispatchToProps)(SettingsWrapper);
|
||||||
|
@ -3,15 +3,14 @@ import GeneralSettings from 'container/GeneralSettings';
|
|||||||
import SettingsWrapper from 'container/SettingsWrapper';
|
import SettingsWrapper from 'container/SettingsWrapper';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const AllAlertChannels = (): JSX.Element => {
|
const AllAlertChannels = (): JSX.Element => (
|
||||||
return (
|
<SettingsWrapper
|
||||||
<SettingsWrapper
|
{...{
|
||||||
{...{
|
AlertChannels,
|
||||||
AlertChannels,
|
General: GeneralSettings,
|
||||||
General: GeneralSettings,
|
defaultRoute: 'Alert Channels',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
export default AllAlertChannels;
|
export default AllAlertChannels;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user