1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Provider } from 'react-redux';
7 import { combineReducers, createStore } from 'redux';
8 import { SharingDialogComponent } from './sharing-dialog-component';
10 extractUuidObjectType,
12 } from 'models/resource';
13 import { ThemeProvider } from "@mui/material";
14 import { CustomTheme } from 'common/custom-theme';
16 describe("<SharingDialogComponent />", () => {
21 const initialAuthState = {
23 keepWebServiceUrl: 'http://example.com/',
24 keepWebInlineServiceUrl: 'http://*.collections.example.com/',
27 AnonymousUserToken: ""
32 store = createStore(combineReducers({
33 auth: (state = initialAuthState, action) => state,
40 sharedResourceUuid: 'zzzzz-4zz18-zzzzzzzzzzzzzzz',
43 sharingURLsDisabled: false,
46 onCreateSharingToken: cy.stub(),
47 refreshPermissions: cy.stub(),
51 it("show sharing urls tab on collections when not disabled", () => {
52 expect(props.sharingURLsDisabled).to.equal(false);
53 expect(props.sharingURLsNr).to.equal(2);
54 expect(extractUuidObjectType(props.sharedResourceUuid)).to.equal(ResourceObjectType.COLLECTION)
56 <Provider store={store}>
57 <ThemeProvider theme={CustomTheme}>
58 <SharingDialogComponent {...props} />
61 cy.get('html').should('contain', 'Sharing URLs (2)');
63 // disable Sharing URLs UI
64 props.sharingURLsDisabled = true;
66 <Provider store={store}>
67 <ThemeProvider theme={CustomTheme}>
68 <SharingDialogComponent {...props} />
71 cy.get('html').should('not.contain', 'Sharing URLs');
74 it("does not show sharing urls on non-collection resources", () => {
75 props.sharedResourceUuid = 'zzzzz-j7d0g-0123456789abcde';
76 expect(extractUuidObjectType(props.sharedResourceUuid)).to.not.equal(ResourceObjectType.COLLECTION);
77 expect(props.sharingURLsDisabled).to.equal(false);
79 <Provider store={store}>
80 <ThemeProvider theme={CustomTheme}>
81 <SharingDialogComponent {...props} />
84 cy.get('html').should('not.contain', 'Sharing URLs');