Skip to content

Commit

Permalink
WEBUI-990: prevent replacing and removing nuxeo document attachment u…
Browse files Browse the repository at this point in the history
…nder retention
  • Loading branch information
rakeshkumar1019 committed Aug 11, 2023
1 parent 39bc8ec commit caddeef
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 100 deletions.
78 changes: 39 additions & 39 deletions test/nuxeo-document-attachments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@ All Hyland product names are registered or unregistered trademarks of Hyland Sof
See the License for the specific language governing permissions and
limitations under the License.
*/
import { fixture, html } from '@nuxeo/testing-helpers';
import '../elements/nuxeo-document-attachments/nuxeo-document-attachments';
suite('nuxeo-document-attachments', () => {
let element;
setup(async () => {
element = await fixture(
html`
<nuxeo-document-attachments></nuxeo-document-attachments>
`,
);
sinon.stub(element, 'hasPermission').returns(true);
sinon.stub(element, 'isImmutable').returns(false);
sinon.stub(element, 'hasType').returns(false);
sinon.stub(element, 'isTrashed').returns(false);
sinon.spy(element, '_isDropzoneAvailable');
});
suite('should return whether property is under retention', () => {
const document = {
isUnderRetentionOrLegalHold: true,
retainedProperties: [
'checkext:single',
'checkext:field1/2/item',
'files:files/*/file',
'checkext:multiple',
'file:content',
],
};
test('when xpath = checkext:single, for dropzone', () => {
element.xpath = 'checkext:single';
expect(element._isDropzoneAvailable(document)).to.eql(false);
});
test('when xpath = checkext:multiple, for dropzone', () => {
element.xpath = 'checkext:multiple';
expect(element._isDropzoneAvailable(document)).to.eql(false);
});
});
});
import { fixture, html } from '@nuxeo/testing-helpers';
import '../elements/nuxeo-document-attachments/nuxeo-document-attachments';

suite('nuxeo-document-attachments', () => {
let element;
setup(async () => {
element = await fixture(
html`
<nuxeo-document-attachments></nuxeo-document-attachments>
`,
);
sinon.stub(element, 'hasPermission').returns(true);
sinon.stub(element, 'isImmutable').returns(false);
sinon.stub(element, 'hasType').returns(false);
sinon.stub(element, 'isTrashed').returns(false);
sinon.spy(element, '_isDropzoneAvailable');
});

suite('should return whether property is under retention', () => {
const document = {
isUnderRetentionOrLegalHold: true,
retainedProperties: [
'checkext:single',
'checkext:field1/2/item',
'files:files/*/file',
'checkext:multiple',
'file:content',
],
};
test('when xpath = checkext:single, for dropzone', () => {
element.xpath = 'checkext:single';
expect(element._isDropzoneAvailable(document)).to.eql(false);
});
test('when xpath = checkext:multiple, for dropzone', () => {
element.xpath = 'checkext:multiple';
expect(element._isDropzoneAvailable(document)).to.eql(false);
});
});
});
122 changes: 61 additions & 61 deletions test/nuxeo-replace-blob.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,64 @@ All Hyland product names are registered or unregistered trademarks of Hyland Sof
See the License for the specific language governing permissions and
limitations under the License.
*/
import { fixture, html } from '@nuxeo/testing-helpers';
import '../elements/nuxeo-document-actions/nuxeo-replace-blob-button';
suite('nuxeo-replace-blob-button', () => {
let element;
setup(async () => {
element = await fixture(
html`
<nuxeo-replace-blob-button></nuxeo-replace-blob-button>
`,
);
sinon.stub(element, 'hasPermission').returns(true);
sinon.stub(element, 'isImmutable').returns(false);
sinon.stub(element, 'hasType').returns(false);
sinon.stub(element, 'isTrashed').returns(false);
sinon.stub(element, 'hasFacet').returns(false);
sinon.stub(element, 'hasContent').returns(false);
sinon.spy(element, '_isAvailable');
});
suite('should return whether property is under retention', () => {
const document = {
isUnderRetentionOrLegalHold: true,
retainedProperties: [
'checkext:single',
'checkext:field1/2/item',
'files:files/*/file',
'checkext:multiple',
'file:content',
],
};
test('when xpath = checkext:single, for document blob', () => {
element.xpath = 'checkext:single';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = checkext:multiple/0, for document attachement', () => {
element.xpath = 'checkext:multiple/0';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = checkext:multiple/1, for document attachement', () => {
element.xpath = 'checkext:multiple/1';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = checkext:field1/0, for custom property - document attachment', () => {
element.xpath = 'checkext:field1/0';
expect(element._isAvailable(document)).to.eql(true);
});
test('when xpath = checkext:field1/2, for custom property - document attachment', () => {
element.xpath = 'checkext:field1/2';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = files:files/0/file, for document attachement', () => {
element.xpath = 'files:files/0/file';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = file:content, for document viewer', () => {
element.xpath = 'file:content';
expect(element._isAvailable(document)).to.eql(false);
});
});
});
import { fixture, html } from '@nuxeo/testing-helpers';
import '../elements/nuxeo-document-actions/nuxeo-replace-blob-button';

suite('nuxeo-replace-blob-button', () => {
let element;
setup(async () => {
element = await fixture(
html`
<nuxeo-replace-blob-button></nuxeo-replace-blob-button>
`,
);
sinon.stub(element, 'hasPermission').returns(true);
sinon.stub(element, 'isImmutable').returns(false);
sinon.stub(element, 'hasType').returns(false);
sinon.stub(element, 'isTrashed').returns(false);
sinon.stub(element, 'hasFacet').returns(false);
sinon.stub(element, 'hasContent').returns(false);
sinon.spy(element, '_isAvailable');
});

suite('should return whether property is under retention', () => {
const document = {
isUnderRetentionOrLegalHold: true,
retainedProperties: [
'checkext:single',
'checkext:field1/2/item',
'files:files/*/file',
'checkext:multiple',
'file:content',
],
};
test('when xpath = checkext:single, for document blob', () => {
element.xpath = 'checkext:single';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = checkext:multiple/0, for document attachement', () => {
element.xpath = 'checkext:multiple/0';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = checkext:multiple/1, for document attachement', () => {
element.xpath = 'checkext:multiple/1';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = checkext:field1/0, for custom property - document attachment', () => {
element.xpath = 'checkext:field1/0';
expect(element._isAvailable(document)).to.eql(true);
});
test('when xpath = checkext:field1/2, for custom property - document attachment', () => {
element.xpath = 'checkext:field1/2';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = files:files/0/file, for document attachement', () => {
element.xpath = 'files:files/0/file';
expect(element._isAvailable(document)).to.eql(false);
});
test('when xpath = file:content, for document viewer', () => {
element.xpath = 'file:content';
expect(element._isAvailable(document)).to.eql(false);
});
});
});

0 comments on commit caddeef

Please sign in to comment.