1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { mount, configure, shallow } from 'enzyme';
7 import * as Adapter from "enzyme-adapter-react-16";
8 import { MuiThemeProvider, WithStyles } from '@material-ui/core';
9 import { CustomTheme } from '~/common/custom-theme';
10 import { WebDavS3InfoDialog, CssRules } from './webdav-s3-dialog';
11 import { WithDialogProps } from '~/store/dialog/with-dialog';
12 import { WebDavS3InfoDialogData, COLLECTION_WEBDAV_S3_DIALOG_NAME } from '~/store/collections/collection-info-actions';
13 import { Provider } from "react-redux";
14 import { createStore, combineReducers } from 'redux';
15 import { configureStore, RootStore } from '~/store/store';
16 import { createBrowserHistory } from "history";
17 import { createServices } from "~/services/services";
19 configure({ adapter: new Adapter() });
21 describe('WebDavS3InfoDialog', () => {
22 let props: WithDialogProps<WebDavS3InfoDialogData> & WithStyles<CssRules>;
26 const initialDialogState = {
27 [COLLECTION_WEBDAV_S3_DIALOG_NAME]: {
30 uuid: "zzzzz-4zz18-b1f8tbldjrm8885",
31 token: "v2/zzzzb-jjjjj-123123/xxxtokenxxx",
32 downloadUrl: "https://download.example.com",
33 collectionsUrl: "https://collections.example.com",
34 localCluster: "zzzzz",
37 setActiveTab: (event: any, tabNr: number) => { }
41 const initialAuthState = {
42 localCluster: "zzzzz",
43 remoteHostsConfig: {},
46 store = createStore(combineReducers({
47 dialog: (state: any = initialDialogState, action: any) => state,
48 auth: (state: any = initialAuthState, action: any) => state,
58 it('render cyberduck tab', () => {
59 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 0;
61 const wrapper = mount(
62 <MuiThemeProvider theme={CustomTheme}>
63 <Provider store={store}>
64 <WebDavS3InfoDialog {...props} />
70 expect(wrapper.text()).toContain("davs://bobby@download.example.com/by_id/zzzzz-4zz18-b1f8tbldjrm8885");
73 it('render win/mac tab', () => {
74 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 1;
76 const wrapper = mount(
77 <MuiThemeProvider theme={CustomTheme}>
78 <Provider store={store}>
79 <WebDavS3InfoDialog {...props} />
85 expect(wrapper.text()).toContain("https://download.example.com/by_id/zzzzz-4zz18-b1f8tbldjrm8885");
88 it('render s3 tab with federated token', () => {
89 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
91 const wrapper = mount(
92 <MuiThemeProvider theme={CustomTheme}>
93 <Provider store={store}>
94 <WebDavS3InfoDialog {...props} />
100 expect(wrapper.text()).toContain("Secret Keyv2_zzzzb-jjjjj-123123_xxxtokenxxx");
103 it('render s3 tab with local token', () => {
104 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
105 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.token = "v2/zzzzz-jjjjj-123123/xxxtokenxxx";
107 const wrapper = mount(
108 <MuiThemeProvider theme={CustomTheme}>
109 <Provider store={store}>
110 <WebDavS3InfoDialog {...props} />
116 expect(wrapper.text()).toContain("Access Keyzzzzz-jjjjj-123123Secret Keyxxxtokenxxx");
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";
123 const wrapper = mount(
124 <MuiThemeProvider theme={CustomTheme}>
125 <Provider store={store}>
126 <WebDavS3InfoDialog {...props} />
132 expect(wrapper.text()).toContain("davs://bobby@zzzzz-4zz18-b1f8tbldjrm8885.collections.example.com");