From b3136f5dc33e7759b2775e9164e1faa3531ddb55 Mon Sep 17 00:00:00 2001 From: Nishant0928 Date: Thu, 27 Jul 2023 13:54:16 +0530 Subject: [PATCH] WEBUI-994: prevent replacing and removing an attachment under retention when using nuxeo-file --- ui/test/nuxeo-file.test.js | 48 ++++++++++++++++++++++++++++++++++++++ ui/widgets/nuxeo-file.js | 1 - 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 ui/test/nuxeo-file.test.js diff --git a/ui/test/nuxeo-file.test.js b/ui/test/nuxeo-file.test.js new file mode 100644 index 0000000000..8f5cd04de4 --- /dev/null +++ b/ui/test/nuxeo-file.test.js @@ -0,0 +1,48 @@ +/** + @license + (C) Copyright Nuxeo Corp. (http://nuxeo.com/) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +import { fixture, html } from '@nuxeo/testing-helpers'; +import '../widgets/nuxeo-file'; + +suite('nuxeo-file', () => { + let element; + setup(async () => { + element = await fixture( + html` + + `, + ); + }); + + suite('should return whether property is under retention', () => { + test('when file:content is a retained property && xpath = file:content', () => { + const document = { + isUnderRetentionOrLegalHold: true, + retainedProperties: ['file:content'], + }; + element.xpath = 'file:content'; + expect(element._isDropzoneVisible(document)).to.eql(true); + }); + test('when file:content is not a retained property && xpath = file:content', () => { + const document = { + isUnderRetentionOrLegalHold: true, + retainedProperties: [], + }; + element.xpath = 'file:content'; + expect(element._isDropzoneVisible(document)).to.eql(false); + }); + }); +}); diff --git a/ui/widgets/nuxeo-file.js b/ui/widgets/nuxeo-file.js index 7cdee35d6c..7e6a5a6a68 100644 --- a/ui/widgets/nuxeo-file.js +++ b/ui/widgets/nuxeo-file.js @@ -301,7 +301,6 @@ import { UploaderBehavior } from './nuxeo-uploader-behavior.js'; return this.readonly; } - _hasValue() { return this.multiple ? !!this.value && this.value.length > 0 : !!this.value; }