mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-1680] add new tests for Permanently delete from Trash (#608)
This commit is contained in:
parent
c12ec405c4
commit
c687c22cc3
@ -27,8 +27,9 @@ export * from './login/login';
|
||||
export * from './header/header';
|
||||
export * from './header/user-info';
|
||||
export * from './data-table/data-table';
|
||||
export * from './dialog/confirm-dialog';
|
||||
export * from './dialog/create-edit-folder-dialog';
|
||||
export * from './pagination/pagination';
|
||||
export * from './sidenav/sidenav';
|
||||
export * from './toolbar/toolbar';
|
||||
export * from './dialog/create-edit-folder-dialog';
|
||||
export * from './viewer/viewer';
|
||||
|
69
e2e/components/dialog/confirm-dialog.ts
Executable file
69
e2e/components/dialog/confirm-dialog.ts
Executable file
@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2018 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
|
||||
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
|
||||
import { Component } from '../component';
|
||||
|
||||
export class ConfirmDialog extends Component {
|
||||
private static selectors = {
|
||||
root: 'adf-confirm-dialog',
|
||||
|
||||
title: '.mat-dialog-title',
|
||||
content: '.mat-dialog-content',
|
||||
delete: 'adf-confirm-accept',
|
||||
keep: 'adf-confirm-cancel'
|
||||
};
|
||||
|
||||
title: ElementFinder = this.component.element(by.css(ConfirmDialog.selectors.title));
|
||||
content: ElementFinder = this.component.element(by.css(ConfirmDialog.selectors.content));
|
||||
deleteButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.delete));
|
||||
keepButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.keep));
|
||||
|
||||
constructor(ancestor?: ElementFinder) {
|
||||
super(ConfirmDialog.selectors.root, ancestor);
|
||||
}
|
||||
|
||||
async waitForDialogToClose() {
|
||||
return await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
}
|
||||
|
||||
async getText() {
|
||||
return await this.content.getText();
|
||||
}
|
||||
|
||||
async clickDelete() {
|
||||
await this.deleteButton.click();
|
||||
}
|
||||
|
||||
async clickKeep() {
|
||||
await this.keepButton.click();
|
||||
await this.waitForDialogToClose();
|
||||
}
|
||||
}
|
@ -23,7 +23,9 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { browser, protractor } from 'protractor';
|
||||
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
|
||||
import { ConfirmDialog } from './../../components/components';
|
||||
import { SIDEBAR_LABELS } from '../../configs';
|
||||
import { RepoClient } from '../../utilities/repo-client/repo-client';
|
||||
import { Utils } from '../../utilities/utils';
|
||||
@ -31,12 +33,13 @@ import { Utils } from '../../utilities/utils';
|
||||
describe('Permanently delete from Trash', () => {
|
||||
const username = `user-${Utils.random()}`;
|
||||
|
||||
const file1 = `file-${Utils.random()}.txt`;
|
||||
const file2 = `file-${Utils.random()}.txt`;
|
||||
const file1 = `file1-${Utils.random()}.txt`;
|
||||
const file2 = `file2-${Utils.random()}.txt`;
|
||||
const file3 = `file3-${Utils.random()}.txt`;
|
||||
let filesIds;
|
||||
|
||||
const folder1 = `folder-${Utils.random()}`;
|
||||
const folder2 = `folder-${Utils.random()}`;
|
||||
const folder1 = `folder1-${Utils.random()}`;
|
||||
const folder2 = `folder2-${Utils.random()}`;
|
||||
let foldersIds;
|
||||
|
||||
const apis = {
|
||||
@ -49,74 +52,91 @@ describe('Permanently delete from Trash', () => {
|
||||
const trashPage = new BrowsingPage();
|
||||
const { dataTable, toolbar } = trashPage;
|
||||
|
||||
beforeAll(done => {
|
||||
apis.admin.people.createUser({ username })
|
||||
.then(() => apis.user.nodes.createFiles([ file1, file2 ]))
|
||||
.then(resp => filesIds = resp.list.entries.map(entries => entries.entry.id))
|
||||
.then(() => apis.user.nodes.createFolders([ folder1, folder2 ]))
|
||||
.then(resp => foldersIds = resp.list.entries.map(entries => entries.entry.id))
|
||||
const confirmDialog = new ConfirmDialog();
|
||||
|
||||
.then(() => apis.user.nodes.deleteNodesById(filesIds, false))
|
||||
.then(() => apis.user.nodes.deleteNodesById(foldersIds, false))
|
||||
beforeAll(async (done) => {
|
||||
await apis.admin.people.createUser({ username });
|
||||
filesIds = (await apis.user.nodes.createFiles([ file1, file2, file3 ])).list.entries.map(entries => entries.entry.id);
|
||||
foldersIds = (await apis.user.nodes.createFolders([ folder1, folder2 ])).list.entries.map(entries => entries.entry.id);
|
||||
await apis.user.nodes.deleteNodesById(filesIds, false);
|
||||
await apis.user.nodes.deleteNodesById(foldersIds, false);
|
||||
|
||||
.then(() => loginPage.loginWith(username))
|
||||
.then(done);
|
||||
await loginPage.loginWith(username);
|
||||
done();
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
trashPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
|
||||
.then(() => dataTable.waitForHeader())
|
||||
.then(done);
|
||||
beforeEach(async (done) => {
|
||||
await trashPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH);
|
||||
await dataTable.waitForHeader();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(done => {
|
||||
Promise.all([
|
||||
apis.admin.trashcan.emptyTrash(),
|
||||
afterAll(async (done) => {
|
||||
await Promise.all([
|
||||
apis.user.trashcan.emptyTrash(),
|
||||
logoutPage.load()
|
||||
])
|
||||
.then(done);
|
||||
]);
|
||||
done();
|
||||
});
|
||||
|
||||
it('delete file - [C217091]', () => {
|
||||
dataTable.selectItem(file1)
|
||||
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
|
||||
.then(() => trashPage.waitForDialog())
|
||||
.then(() => trashPage.getDialogActionByLabel('Delete'))
|
||||
.then((elm) => elm.click())
|
||||
.then(() => trashPage.waitForDialogToClose())
|
||||
.then(() => trashPage.getSnackBarMessage())
|
||||
.then(text => {
|
||||
expect(text).toEqual(`${file1} deleted`);
|
||||
expect(dataTable.getRowByName(file1).isPresent()).toBe(false, 'Item was not deleted');
|
||||
});
|
||||
it('delete file - [C217091]', async () => {
|
||||
await dataTable.selectItem(file1);
|
||||
await toolbar.actions.getButtonByTitleAttribute('Permanently delete').click();
|
||||
await trashPage.waitForDialog();
|
||||
await trashPage.getDialogActionByLabel('Delete').click();
|
||||
await trashPage.waitForDialogToClose();
|
||||
const text = await trashPage.getSnackBarMessage();
|
||||
|
||||
expect(text).toEqual(`${file1} deleted`);
|
||||
expect(dataTable.getRowByName(file1).isPresent()).toBe(false, 'Item was not deleted');
|
||||
});
|
||||
|
||||
it('delete folder - [C280416]', () => {
|
||||
dataTable.selectItem(folder1)
|
||||
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
|
||||
.then(() => trashPage.waitForDialog())
|
||||
.then(() => trashPage.getDialogActionByLabel('Delete'))
|
||||
.then((elm) => elm.click())
|
||||
.then(() => trashPage.waitForDialogToClose())
|
||||
.then(() => trashPage.getSnackBarMessage())
|
||||
.then(text => {
|
||||
expect(text).toEqual(`${folder1} deleted`);
|
||||
expect(dataTable.getRowByName(folder1).isPresent()).toBe(false, 'Item was not deleted');
|
||||
});
|
||||
it('delete folder - [C280416]', async () => {
|
||||
await dataTable.selectItem(folder1);
|
||||
await toolbar.actions.getButtonByTitleAttribute('Permanently delete').click();
|
||||
await trashPage.waitForDialog();
|
||||
await trashPage.getDialogActionByLabel('Delete').click();
|
||||
await trashPage.waitForDialogToClose();
|
||||
const text = await trashPage.getSnackBarMessage();
|
||||
|
||||
expect(text).toEqual(`${folder1} deleted`);
|
||||
expect(dataTable.getRowByName(folder1).isPresent()).toBe(false, 'Item was not deleted');
|
||||
});
|
||||
|
||||
it('delete multiple items - [C280417]', () => {
|
||||
dataTable.selectMultipleItems([ file2, folder2 ])
|
||||
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
|
||||
.then(() => trashPage.waitForDialog())
|
||||
.then(() => trashPage.getDialogActionByLabel('Delete'))
|
||||
.then((elm) => elm.click())
|
||||
.then(() => trashPage.waitForDialogToClose())
|
||||
.then(() => trashPage.getSnackBarMessage())
|
||||
.then(text => {
|
||||
expect(text).toEqual(`2 items deleted`);
|
||||
expect(dataTable.getRowByName(file2).isPresent()).toBe(false, 'Item was not deleted');
|
||||
expect(dataTable.getRowByName(folder2).isPresent()).toBe(false, 'Item was not deleted');
|
||||
});
|
||||
it('delete multiple items - [C280417]', async () => {
|
||||
await dataTable.selectMultipleItems([ file2, folder2 ]);
|
||||
await toolbar.actions.getButtonByTitleAttribute('Permanently delete').click();
|
||||
await trashPage.waitForDialog();
|
||||
await trashPage.getDialogActionByLabel('Delete').click();
|
||||
await trashPage.waitForDialogToClose();
|
||||
const text = await trashPage.getSnackBarMessage();
|
||||
|
||||
expect(text).toEqual(`2 items deleted`);
|
||||
expect(dataTable.getRowByName(file2).isPresent()).toBe(false, 'Item was not deleted');
|
||||
expect(dataTable.getRowByName(folder2).isPresent()).toBe(false, 'Item was not deleted');
|
||||
});
|
||||
|
||||
it('Confirmation dialog UI - [C269113]', async () => {
|
||||
await dataTable.selectItem(file3);
|
||||
await toolbar.actions.getButtonByTitleAttribute('Permanently delete').click();
|
||||
await trashPage.waitForDialog();
|
||||
|
||||
expect(await confirmDialog.getTitle()).toContain('Delete from trash');
|
||||
expect(await confirmDialog.getText()).toContain('This will permanently remove the selected item(s)');
|
||||
expect(await confirmDialog.deleteButton.isEnabled()).toBe(true, 'DELETE button is not enabled');
|
||||
expect(await confirmDialog.keepButton.isEnabled()).toBe(true, 'KEEP button is not enabled');
|
||||
|
||||
await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
|
||||
await dataTable.clearSelection();
|
||||
});
|
||||
|
||||
it('"Keep" action cancels the deletion - [C269115]', async () => {
|
||||
await dataTable.selectItem(file3);
|
||||
await toolbar.actions.getButtonByTitleAttribute('Permanently delete').click();
|
||||
await trashPage.waitForDialog();
|
||||
|
||||
expect(await confirmDialog.keepButton.isEnabled()).toBe(true, 'KEEP button is not enabled');
|
||||
await confirmDialog.clickKeep();
|
||||
expect(dataTable.getRowByName(file3).isPresent()).toBe(true, 'Item was deleted');
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user