FE(UI):Channels test (#417)

* bug(UI): default tab over setting is resolved

* feat(UI): channels test is updated
This commit is contained in:
pal-sig 2021-12-02 18:47:40 +05:30 committed by GitHub
parent 32750fa2af
commit 3ed4fb2b75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 11 deletions

View 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"
}

View 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,
);
});
});
});
});

View File

@ -15,6 +15,7 @@ const SettingsWrapper = ({
AlertChannels,
General,
toggleSettingsTab,
defaultRoute,
}: SettingsWrapperProps): JSX.Element => {
const { settingsActiveTab } = useSelector<AppState, AppReducer>(
(state) => state.app,
@ -38,7 +39,7 @@ const SettingsWrapper = ({
<Tabs
destroyInactiveTabPane
onChange={(value): void => onChangeHandler(value as SettingTab)}
activeKey={settingsActiveTab}
activeKey={defaultRoute || settingsActiveTab}
>
<TabPane tab="General" key="General">
<General />
@ -63,6 +64,7 @@ const mapDispatchToProps = (
interface SettingsWrapperProps extends DispatchProps {
General: () => JSX.Element;
AlertChannels: () => JSX.Element;
defaultRoute?: SettingTab;
}
export default connect(null, mapDispatchToProps)(SettingsWrapper);

View File

@ -3,15 +3,14 @@ import GeneralSettings from 'container/GeneralSettings';
import SettingsWrapper from 'container/SettingsWrapper';
import React from 'react';
const AllAlertChannels = (): JSX.Element => {
return (
const AllAlertChannels = (): JSX.Element => (
<SettingsWrapper
{...{
AlertChannels,
General: GeneralSettings,
defaultRoute: 'Alert Channels',
}}
/>
);
};
export default AllAlertChannels;