Merge branch 'main' into 21720-material-ui-upgrade
[arvados.git] / services / workbench2 / src / views / not-found-panel / not-found-panel-root.cy.js
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 { ThemeProvider, StyledEngineProvider } from '@mui/material';
7 import { CustomTheme } from 'common/custom-theme';
8 import { NotFoundPanelRoot } from './not-found-panel-root';
9
10 describe('NotFoundPanelRoot', () => {
11     let props;
12
13     beforeEach(() => {
14         props = {
15             classes: {
16                 root: 'root',
17                 title: 'title',
18                 active: 'active',
19             },
20             clusterConfig: {
21                 Users: {
22                     SupportEmailAddress: 'support@example.com'
23                 }
24             },
25             location: null,
26         };
27     });
28
29     it('should render component', () => {
30         // given
31         const expectedMessage = "The page you requested was not found";
32
33         // when
34         cy.mount(
35             <StyledEngineProvider injectFirst>
36                 <ThemeProvider theme={CustomTheme}>
37                     <NotFoundPanelRoot {...props} />
38                 </ThemeProvider>
39             </StyledEngineProvider>
40             );
41
42         // then
43         cy.get('p').contains(expectedMessage);
44     });
45
46     it('should render component without email url when no email', () => {
47         // setup
48         props.clusterConfig.Users.SupportEmailAddress = '';
49
50         // when
51         cy.mount(
52             <StyledEngineProvider injectFirst>
53                 <ThemeProvider theme={CustomTheme}>
54                     <NotFoundPanelRoot {...props} />
55                 </ThemeProvider>
56             </StyledEngineProvider>
57             );
58
59         // then
60         cy.get('a').should('not.exist');
61     });
62
63     it('should render component with additional message and email url', () => {
64         // given
65         const hash = '123hash123';
66         const pathname = `/collections/${hash}`;
67
68         // setup
69         props.location = {
70             pathname,
71         };
72
73         // when
74         cy.mount(
75             <StyledEngineProvider injectFirst>
76                 <ThemeProvider theme={CustomTheme}>
77                     <NotFoundPanelRoot {...props} />
78                 </ThemeProvider>
79             </StyledEngineProvider>
80             );
81
82         // then
83         cy.get('p').eq(0).contains(hash);
84
85         // and
86         cy.get('a').should('have.length', 1);
87     });
88 });