mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
114 lines
4.5 KiB
TypeScript
114 lines
4.5 KiB
TypeScript
/*!
|
|
* @license
|
|
* Alfresco Example Content Application
|
|
*
|
|
* Copyright (C) 2005 - 2017 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 { browser, protractor, promise } from 'protractor';
|
|
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
|
|
import { APP_ROUTES, SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
|
|
import { RepoClient } from '../../utilities/repo-client/repo-client';
|
|
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`;
|
|
let filesIds;
|
|
|
|
const folder1 = `folder-${Utils.random()}`;
|
|
const folder2 = `folder-${Utils.random()}`;
|
|
let foldersIds;
|
|
|
|
const apis = {
|
|
admin: new RepoClient(),
|
|
user: new RepoClient(username, username)
|
|
};
|
|
|
|
const loginPage = new LoginPage();
|
|
const logoutPage = new LogoutPage();
|
|
const trashPage = new BrowsingPage();
|
|
const { dataTable } = trashPage;
|
|
const { toolbar } = trashPage;
|
|
|
|
beforeAll(done => {
|
|
apis.admin.people.createUser(username)
|
|
.then(() => apis.user.nodes.createFiles([ file1, file2 ]))
|
|
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id))
|
|
.then(() => apis.user.nodes.createFolders([ folder1, folder2 ]))
|
|
.then(resp => foldersIds = resp.data.list.entries.map(entries => entries.entry.id))
|
|
|
|
.then(() => apis.user.nodes.deleteNodesById(filesIds, false))
|
|
.then(() => apis.user.nodes.deleteNodesById(foldersIds, false))
|
|
|
|
.then(() => loginPage.load())
|
|
.then(() => loginPage.loginWith(username))
|
|
.then(done);
|
|
});
|
|
|
|
beforeEach(done => {
|
|
trashPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
|
|
.then(() => dataTable.waitForHeader())
|
|
.then(done);
|
|
});
|
|
|
|
afterAll(done => {
|
|
Promise.all([
|
|
apis.admin.trashcan.emptyTrash(),
|
|
logoutPage.load()
|
|
])
|
|
.then(done);
|
|
});
|
|
|
|
it('delete file', () => {
|
|
dataTable.clickOnItemName(file1)
|
|
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
|
|
.then(() => trashPage.getSnackBarMessage())
|
|
.then(text => {
|
|
expect(text).toBe(`${file1} deleted`);
|
|
expect(dataTable.getRowByName(file1).isPresent()).toBe(false, 'Item was not deleted');
|
|
});
|
|
});
|
|
|
|
it('delete folder', () => {
|
|
dataTable.clickOnItemName(folder1)
|
|
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
|
|
.then(() => trashPage.getSnackBarMessage())
|
|
.then(text => {
|
|
expect(text).toBe(`${folder1} deleted`);
|
|
expect(dataTable.getRowByName(folder1).isPresent()).toBe(false, 'Item was not deleted');
|
|
});
|
|
});
|
|
|
|
it('delete multiple items', () => {
|
|
dataTable.selectMultipleItems([ file2, folder2 ])
|
|
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
|
|
.then(() => trashPage.getSnackBarMessage())
|
|
.then(text => {
|
|
expect(text).toBe(`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');
|
|
});
|
|
});
|
|
});
|