mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1432] unified selection and single info drawer (#385)
* track document list selection state * selection management enhancements * (fix) hide info drawer on selection reset * use store selection * remove event handler * upgrade info drawer for personal files * upgrade favorties * upgrade recent files * move info drawer to a separate component * test fixes * update tests * test fixes * remove obsolete directive * use last selection entry * switch back to first selected node * selection improvements, versioning uses same node * optimised toolbar visibility evaluation * upgrade libs * update js api * test fixes * test fixes * test updates * test fixes * fix e2e tests * show metadata for last clicked node
This commit is contained in:
@@ -24,17 +24,22 @@
|
||||
*/
|
||||
|
||||
import { PageComponent } from './page.component';
|
||||
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||
|
||||
class TestClass extends PageComponent {
|
||||
node: any;
|
||||
|
||||
setSelection(selection: MinimalNodeEntity[] = []) {
|
||||
this.onSelectionChanged(selection);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super(null, null);
|
||||
super(null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
describe('PageComponent', () => {
|
||||
let component;
|
||||
let component: TestClass;
|
||||
|
||||
beforeEach(() => {
|
||||
component = new TestClass();
|
||||
@@ -56,47 +61,44 @@ describe('PageComponent', () => {
|
||||
|
||||
describe('hasSelection()', () => {
|
||||
it('returns true when it has nodes selected', () => {
|
||||
const hasSelection = component.hasSelection([ {}, {} ]);
|
||||
expect(hasSelection).toBe(true);
|
||||
component.setSelection([
|
||||
{ entry: { isFile: true } },
|
||||
{ entry: { isFile: true } }
|
||||
]);
|
||||
expect(component.hasSelection).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when it has no selections', () => {
|
||||
const hasSelection = component.hasSelection([]);
|
||||
expect(hasSelection).toBe(false);
|
||||
component.setSelection([]);
|
||||
expect(component.hasSelection).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFileSelected()', () => {
|
||||
describe('firstSelectedDocument', () => {
|
||||
it('returns true if selected node is file', () => {
|
||||
const selection = [ { entry: { isFile: true } } ];
|
||||
expect(component.isFileSelected(selection)).toBe(true);
|
||||
component.setSelection(selection);
|
||||
expect(component.firstSelectedDocument).toBe(selection[0]);
|
||||
});
|
||||
|
||||
it('returns false if selected node is folder', () => {
|
||||
const selection = [ { entry: { isFolder: true } } ];
|
||||
expect(component.isFileSelected(selection)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false if there are more than one selections', () => {
|
||||
const selection = [ { entry: { isFile: true } }, { entry: { isFile: true } } ];
|
||||
expect(component.isFileSelected(selection)).toBe(false);
|
||||
const selection = [ { entry: { isFile: false, isFolder: true } } ];
|
||||
component.setSelection(selection);
|
||||
expect(component.firstSelectedDocument).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFolderSelected()', () => {
|
||||
describe('firstSelectedFolder', () => {
|
||||
it('returns true if selected node is folder', () => {
|
||||
const selection = [ { entry: { isFolder: true } } ];
|
||||
expect(component.isFolderSelected(selection)).toBe(true);
|
||||
const selection = [ { entry: { isFile: false, isFolder: true } } ];
|
||||
component.setSelection(selection);
|
||||
expect(component.firstSelectedFolder).toBe(selection[0]);
|
||||
});
|
||||
|
||||
it('returns false if selected node is file', () => {
|
||||
const selection = [ { entry: { isFile: true } } ];
|
||||
expect(component.isFolderSelected(selection)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false if there are more than one selections', () => {
|
||||
const selection = [ { entry: { isFolder: true } }, { entry: { isFolder: true } } ];
|
||||
expect(component.isFolderSelected(selection)).toBe(false);
|
||||
const selection = [ { entry: { isFile: true, isFolder: false } } ];
|
||||
component.setSelection(selection);
|
||||
expect(component.firstSelectedFolder).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user