1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { mount, configure } from 'enzyme';
7 import 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';
16 configure({ adapter: new Adapter() });
18 describe('WebDavS3InfoDialog', () => {
19 let props: WithDialogProps<WebDavS3InfoDialogData> & WithStyles<CssRules>;
23 const initialDialogState = {
24 [COLLECTION_WEBDAV_S3_DIALOG_NAME]: {
27 uuid: "zzzzz-4zz18-b1f8tbldjrm8885",
28 token: "v2/zzzzb-jjjjj-123123/xxxtokenxxx",
29 downloadUrl: "https://download.example.com",
30 collectionsUrl: "https://collections.example.com",
31 localCluster: "zzzzz",
34 setActiveTab: (event: any, tabNr: number) => { }
38 const initialAuthState = {
39 localCluster: "zzzzz",
40 remoteHostsConfig: {},
43 store = createStore(combineReducers({
44 dialog: (state: any = initialDialogState, action: any) => state,
45 auth: (state: any = initialAuthState, action: any) => state,
55 it('render cyberduck tab', () => {
56 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 0;
58 const wrapper = mount(
59 <MuiThemeProvider theme={CustomTheme}>
60 <Provider store={store}>
61 <WebDavS3InfoDialog {...props} />
67 expect(wrapper.text()).toContain("davs://bobby@download.example.com/c=zzzzz-4zz18-b1f8tbldjrm8885");
70 it('render win/mac tab', () => {
71 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 1;
73 const wrapper = mount(
74 <MuiThemeProvider theme={CustomTheme}>
75 <Provider store={store}>
76 <WebDavS3InfoDialog {...props} />
82 expect(wrapper.text()).toContain("https://download.example.com/c=zzzzz-4zz18-b1f8tbldjrm8885");
85 it('render s3 tab with federated token', () => {
86 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
88 const wrapper = mount(
89 <MuiThemeProvider theme={CustomTheme}>
90 <Provider store={store}>
91 <WebDavS3InfoDialog {...props} />
97 expect(wrapper.text()).toContain("Secret Keyv2_zzzzb-jjjjj-123123_xxxtokenxxx");
100 it('render s3 tab with local token', () => {
101 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
102 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.token = "v2/zzzzz-jjjjj-123123/xxxtokenxxx";
104 const wrapper = mount(
105 <MuiThemeProvider theme={CustomTheme}>
106 <Provider store={store}>
107 <WebDavS3InfoDialog {...props} />
113 expect(wrapper.text()).toContain("Access Keyzzzzz-jjjjj-123123Secret Keyxxxtokenxxx");
116 it('render cyberduck tab with wildcard DNS', () => {
117 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 0;
118 store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.collectionsUrl = "https://*.collections.example.com";
120 const wrapper = mount(
121 <MuiThemeProvider theme={CustomTheme}>
122 <Provider store={store}>
123 <WebDavS3InfoDialog {...props} />
129 expect(wrapper.text()).toContain("davs://bobby@zzzzz-4zz18-b1f8tbldjrm8885.collections.example.com");