22083: Store "failedToLoadOutputCollection" state
[arvados.git] / services / workbench2 / src / views-components / webdav-s3-dialog / webdav-s3-dialog.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 { WebDavS3InfoDialog } from './webdav-s3-dialog';
9 import { COLLECTION_WEBDAV_S3_DIALOG_NAME } from 'store/collections/collection-info-actions';
10 import { Provider } from "react-redux";
11 import { createStore, combineReducers } from 'redux';
12
13 describe('WebDavS3InfoDialog', () => {
14     let props;
15     let store;
16
17     beforeEach(() => {
18         const initialDialogState = {
19             [COLLECTION_WEBDAV_S3_DIALOG_NAME]: {
20                 open: true,
21                 data: {
22                     uuid: "zzzzz-4zz18-b1f8tbldjrm8885",
23                     token: "v2/zzzzb-jjjjj-123123/xxxtokenxxx",
24                     downloadUrl: "https://download.example.com",
25                     collectionsUrl: "https://collections.example.com",
26                     localCluster: "zzzzz",
27                     username: "bobby",
28                     activeTab: 0,
29                     setActiveTab: (event, tabNr) => { }
30                 }
31             }
32         };
33         const initialAuthState = {
34             localCluster: "zzzzz",
35             remoteHostsConfig: {},
36             sessions: {},
37         };
38         store = createStore(combineReducers({
39             dialog: (state = initialDialogState, action) => state,
40             auth: (state = initialAuthState, action) => state,
41         }));
42
43         props = {
44             classes: {
45                 details: 'details',
46             }
47         };
48     });
49
50     it('render cyberduck tab', () => {
51         store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 0;
52         // when
53         cy.mount(
54             <StyledEngineProvider injectFirst>
55                 <ThemeProvider theme={CustomTheme}>
56                     <Provider store={store}>
57                         <WebDavS3InfoDialog {...props} />
58                     </Provider>
59                 </ThemeProvider>
60             </StyledEngineProvider>
61         );
62
63         // then
64         cy.contains("davs://bobby@download.example.com/c=zzzzz-4zz18-b1f8tbldjrm8885").should('exist');
65     });
66
67     it('render win/mac tab', () => {
68         store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 1;
69         // when
70         cy.mount(
71             <StyledEngineProvider injectFirst>
72                 <ThemeProvider theme={CustomTheme}>
73                     <Provider store={store}>
74                         <WebDavS3InfoDialog {...props} />
75                     </Provider>
76                 </ThemeProvider>
77             </StyledEngineProvider>
78         );
79
80         // then
81         cy.contains("https://download.example.com/c=zzzzz-4zz18-b1f8tbldjrm8885").should('exist');
82     });
83
84     it('render s3 tab with federated token', () => {
85         store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
86         // when
87         cy.mount(
88             <StyledEngineProvider injectFirst>
89                 <ThemeProvider theme={CustomTheme}>
90                     <Provider store={store}>
91                         <WebDavS3InfoDialog {...props} />
92                     </Provider>
93                 </ThemeProvider>
94             </StyledEngineProvider>
95         );
96
97         // then
98         cy.contains("Secret Keyv2_zzzzb-jjjjj-123123_xxxtokenxxx").should('exist');
99     });
100
101     it('render s3 tab with local token', () => {
102         store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
103         store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.token = "v2/zzzzz-jjjjj-123123/xxxtokenxxx";
104         // when
105         cy.mount(
106             <StyledEngineProvider injectFirst>
107                 <ThemeProvider theme={CustomTheme}>
108                     <Provider store={store}>
109                         <WebDavS3InfoDialog {...props} />
110                     </Provider>
111                 </ThemeProvider>
112             </StyledEngineProvider>
113         );
114
115         // then
116         cy.contains("Access Keyzzzzz-jjjjj-123123Secret Keyxxxtokenxxx").should('exist');
117     });
118
119     it('render cyberduck tab with wildcard DNS', () => {
120         store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 0;
121         store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.collectionsUrl = "https://*.collections.example.com";
122         // when
123         cy.mount(
124             <StyledEngineProvider injectFirst>
125                 <ThemeProvider theme={CustomTheme}>
126                     <Provider store={store}>
127                         <WebDavS3InfoDialog {...props} />
128                     </Provider>
129                 </ThemeProvider>
130             </StyledEngineProvider>
131         );
132
133         // then
134         cy.contains("davs://bobby@zzzzz-4zz18-b1f8tbldjrm8885.collections.example.com").should('exist');
135     });
136
137 });