Merge branch '18028-all-procs-context-menu'. Closes #18028
[arvados-workbench2.git] / src / views / inactive-panel / inactive-panel.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import { mount, configure } from 'enzyme';
7 import Adapter from "enzyme-adapter-react-16";
8 import { CustomTheme } from 'common/custom-theme';
9 import { InactivePanelStateProps, CssRules, InactivePanelRoot } from './inactive-panel';
10 import { MuiThemeProvider, StyledComponentProps } from '@material-ui/core';
11
12 configure({ adapter: new Adapter() });
13
14 describe('InactivePanel', () => {
15     let props: InactivePanelStateProps & StyledComponentProps<CssRules>;
16
17     beforeEach(() => {
18         props = {
19             classes: {
20                 root: 'root',
21                 title: 'title',
22                 ontop: 'ontop',
23             },
24             isLoginClusterFederation: false,
25             inactivePageText: 'Inactive page content',
26         };
27     });
28
29     it('should render content and link account option', () => {
30         // given
31         const expectedMessage = "Inactive page content";
32         const expectedLinkAccountText = 'If you would like to use this login to access another account click "Link Account"';
33
34         // when
35         const wrapper = mount(
36             <MuiThemeProvider theme={CustomTheme}>
37                 <InactivePanelRoot {...props} />
38             </MuiThemeProvider>
39             );
40
41         // then
42         expect(wrapper.find('p').first().text()).toContain(expectedMessage);
43         expect(wrapper.find('p').at(1).text()).toContain(expectedLinkAccountText);
44     })
45
46     it('should render content and link account warning on LoginCluster federations', () => {
47         // given
48         props.isLoginClusterFederation = true;
49         const expectedMessage = "Inactive page content";
50         const expectedLinkAccountText = 'If you would like to use this login to access another account, please contact your administrator';
51
52         // when
53         const wrapper = mount(
54             <MuiThemeProvider theme={CustomTheme}>
55                 <InactivePanelRoot {...props} />
56             </MuiThemeProvider>
57             );
58
59         // then
60         expect(wrapper.find('p').first().text()).toContain(expectedMessage);
61         expect(wrapper.find('p').at(1).text()).toContain(expectedLinkAccountText);
62     })
63 });