mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-2850][ACA-2849] Viewer - document properties not refreshed after changes or uploading new version (#1286)
* update viewer on upload complete * prevent multiple same actions triggers * Display node again after upload was complete * Add e2e test for showing 'Editing Offline' when a new version was uploaded and the node was locked before * Add e2e test for showing 'Editing Offline' when a new version was uploaded and the node was locked before * Add e2e test for showing 'Editing Offline' when a new version was uploaded and the node was locked before * Update src/app/components/page.component.ts return type Co-Authored-By: Denys Vuika <denys.vuika@alfresco.com> * return type Co-Authored-By: Denys Vuika <denys.vuika@alfresco.com> * return type Co-Authored-By: Denys Vuika <denys.vuika@alfresco.com> Co-authored-by: Martin Muller <damadden88@googlemail.com> Co-authored-by: Denys Vuika <denys.vuika@gmail.com>
This commit is contained in:
parent
0d0ddfcf37
commit
55547ed163
@ -351,6 +351,14 @@ export class Menu extends Component {
|
||||
return this.uploadFolderAction.isEnabled();
|
||||
}
|
||||
|
||||
async isCancelEditingActionPresent(): Promise<boolean> {
|
||||
return this.cancelEditingAction.isPresent();
|
||||
}
|
||||
|
||||
async isEditOfflineActionPresent(): Promise<boolean> {
|
||||
return this.editOfflineAction.isPresent();
|
||||
}
|
||||
|
||||
|
||||
async clickCreateFolder() {
|
||||
const action = this.createFolderAction;
|
||||
|
@ -74,6 +74,7 @@ describe('Viewer actions', () => {
|
||||
const fileForEditOffline = `file1-${Utils.random()}.docx`; let fileForEditOfflineId;
|
||||
const fileForCancelEditing = `file2-${Utils.random()}.docx`; let fileForCancelEditingId;
|
||||
const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; let fileForUploadNewVersionId;
|
||||
const fileForUploadNewVersion2 = `file4-${Utils.random()}.docx`; let fileForUploadNewVersionId2;
|
||||
|
||||
beforeAll(async (done) => {
|
||||
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
|
||||
@ -88,9 +89,11 @@ describe('Viewer actions', () => {
|
||||
fileForEditOfflineId = (await apis.user.upload.uploadFileWithRename(docxFile, parentId, fileForEditOffline)).entry.id;
|
||||
fileForCancelEditingId = (await apis.user.upload.uploadFileWithRename(docxFile, parentId, fileForCancelEditing)).entry.id;
|
||||
fileForUploadNewVersionId = (await apis.user.upload.uploadFileWithRename(docxFile, parentId, fileForUploadNewVersion)).entry.id;
|
||||
fileForUploadNewVersionId2 = (await apis.user.upload.uploadFileWithRename(docxFile, parentId, fileForUploadNewVersion2)).entry.id;
|
||||
|
||||
await apis.user.nodes.lockFile(fileForCancelEditingId);
|
||||
await apis.user.nodes.lockFile(fileForUploadNewVersionId);
|
||||
await apis.user.nodes.lockFile(fileForUploadNewVersionId2);
|
||||
|
||||
|
||||
await loginPage.loginWith(username);
|
||||
@ -221,6 +224,26 @@ describe('Viewer actions', () => {
|
||||
expect(await apis.user.nodes.getFileVersionLabel(filePersonalFilesId)).toEqual('2.0', 'File has incorrect version label');
|
||||
});
|
||||
|
||||
it('Upload new version action when node is locked - [MNT-21058]', async () => {
|
||||
|
||||
await dataTable.doubleClickOnRowByName(fileForUploadNewVersion2);
|
||||
await viewer.waitForViewerToOpen();
|
||||
|
||||
await toolbar.openMoreMenu();
|
||||
expect(await toolbar.menu.isCancelEditingActionPresent()).toBe(true, `'Cancel Editing' button should be shown`);
|
||||
expect(await toolbar.menu.isEditOfflineActionPresent()).toBe(false, `'Edit Offline' shouldn't be shown`);
|
||||
|
||||
await toolbar.menu.clickMenuItem('Upload New Version');
|
||||
await Utils.uploadFileNewVersion(docxFile);
|
||||
await page.waitForDialog();
|
||||
|
||||
await uploadNewVersionDialog.clickUpload();
|
||||
|
||||
await toolbar.openMoreMenu();
|
||||
expect(await toolbar.menu.isCancelEditingActionPresent()).toBe(false, `'Cancel Editing' button shouldn't be shown`);
|
||||
expect(await toolbar.menu.isEditOfflineActionPresent()).toBe(true, `'Edit Offline' should be shown`);
|
||||
});
|
||||
|
||||
it('Full screen action - [C279282]', async () => {
|
||||
await dataTable.doubleClickOnRowByName(docxPersonalFiles);
|
||||
await viewer.waitForViewerToOpen();
|
||||
|
@ -24,20 +24,29 @@
|
||||
*/
|
||||
|
||||
import { PageComponent } from './page.component';
|
||||
import {
|
||||
ReloadDocumentListAction,
|
||||
SetSelectedNodesAction
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { MinimalNodeEntity } from '@alfresco/js-api';
|
||||
|
||||
class TestClass extends PageComponent {
|
||||
node: any;
|
||||
|
||||
constructor() {
|
||||
super(null, null, null);
|
||||
constructor(store) {
|
||||
super(store, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
describe('PageComponent', () => {
|
||||
let component: TestClass;
|
||||
const store = {
|
||||
dispatch: jasmine.createSpy('dispatch'),
|
||||
select: jasmine.createSpy('select')
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
component = new TestClass();
|
||||
component = new TestClass(store);
|
||||
});
|
||||
|
||||
describe('getParentNodeId()', () => {
|
||||
@ -53,4 +62,38 @@ describe('PageComponent', () => {
|
||||
expect(component.getParentNodeId()).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Reload', () => {
|
||||
const locationHref = location.href;
|
||||
|
||||
afterEach(() => {
|
||||
window.history.pushState({}, null, locationHref);
|
||||
});
|
||||
|
||||
it('should not reload if url contains viewer outlet', () => {
|
||||
window.history.pushState({}, null, `${locationHref}#test(viewer:view)`);
|
||||
component.reload();
|
||||
expect(store.dispatch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload if url does not contain viewer outlet', () => {
|
||||
component.reload();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(
|
||||
new ReloadDocumentListAction()
|
||||
);
|
||||
});
|
||||
|
||||
it('should set selection after reload if node is passed', () => {
|
||||
const node = {
|
||||
entry: {
|
||||
id: 'node-id'
|
||||
}
|
||||
} as MinimalNodeEntity;
|
||||
|
||||
component.reload(node);
|
||||
expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(
|
||||
new SetSelectedNodesAction([node])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -133,6 +133,10 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
reload(selectedNode?: MinimalNodeEntity): void {
|
||||
if (this.isOutletPreviewUrl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.store.dispatch(new ReloadDocumentListAction());
|
||||
if (selectedNode) {
|
||||
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
|
||||
@ -146,4 +150,8 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
||||
trackById(_: number, obj: { id: string }) {
|
||||
return obj.id;
|
||||
}
|
||||
|
||||
private isOutletPreviewUrl(): boolean {
|
||||
return location.href.includes('viewer:view');
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,10 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
||||
debounceTime(300),
|
||||
takeUntil(this.onDestroy$)
|
||||
)
|
||||
.subscribe(file => this.apiService.nodeUpdated.next(file.data.entry));
|
||||
.subscribe(file => {
|
||||
this.apiService.nodeUpdated.next(file.data.entry);
|
||||
this.displayNode(file.data.entry.id);
|
||||
});
|
||||
|
||||
this.previewLocation = this.router.url
|
||||
.substr(0, this.router.url.indexOf('/', 1))
|
||||
|
Loading…
x
Reference in New Issue
Block a user