mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
add tests for Restore from Trash (#79)
This commit is contained in:
committed by
Cilibiu Bogdan
parent
8fd55fbb3a
commit
d7ba58616c
@@ -25,7 +25,8 @@ export abstract class Page {
|
|||||||
app: by.css('app-root'),
|
app: by.css('app-root'),
|
||||||
layout: by.css('app-layout'),
|
layout: by.css('app-layout'),
|
||||||
overlay: by.css('.cdk-overlay-container'),
|
overlay: by.css('.cdk-overlay-container'),
|
||||||
snackBar: by.css('simple-snack-bar')
|
snackBar: by.css('simple-snack-bar'),
|
||||||
|
snackBarAction: by.css('.mat-simple-snackbar-action')
|
||||||
};
|
};
|
||||||
|
|
||||||
public app: ElementFinder = element(this.locators.app);
|
public app: ElementFinder = element(this.locators.app);
|
||||||
@@ -63,4 +64,8 @@ export abstract class Page {
|
|||||||
.then(() => this.snackBar.getText())
|
.then(() => this.snackBar.getText())
|
||||||
.catch(() => '');
|
.catch(() => '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSnackBarAction(): ElementFinder {
|
||||||
|
return this.snackBar.element(this.locators.snackBarAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -85,9 +85,10 @@ describe('Permanently delete from Trash', () => {
|
|||||||
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
|
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
|
||||||
button.click();
|
button.click();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => trashPage.getSnackBarMessage())
|
||||||
|
.then(text => {
|
||||||
|
expect(text).toBe(`${file1} deleted`);
|
||||||
expect(dataTable.getRowByContainingText(file1).isPresent()).toBe(false, 'Item was not deleted');
|
expect(dataTable.getRowByContainingText(file1).isPresent()).toBe(false, 'Item was not deleted');
|
||||||
expect(trashPage.getSnackBarMessage()).toBe(`${file1} deleted`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -97,9 +98,10 @@ describe('Permanently delete from Trash', () => {
|
|||||||
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
|
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
|
||||||
button.click();
|
button.click();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => trashPage.getSnackBarMessage())
|
||||||
|
.then(text => {
|
||||||
|
expect(text).toBe(`${folder1} deleted`);
|
||||||
expect(dataTable.getRowByContainingText(folder1).isPresent()).toBe(false, 'Item was not deleted');
|
expect(dataTable.getRowByContainingText(folder1).isPresent()).toBe(false, 'Item was not deleted');
|
||||||
expect(trashPage.getSnackBarMessage()).toBe(`${folder1} deleted`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -109,10 +111,11 @@ describe('Permanently delete from Trash', () => {
|
|||||||
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
|
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
|
||||||
button.click();
|
button.click();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => trashPage.getSnackBarMessage())
|
||||||
|
.then(text => {
|
||||||
|
expect(text).toBe(`2 items deleted`);
|
||||||
expect(dataTable.getRowByContainingText(file2).isPresent()).toBe(false, 'Item was not deleted');
|
expect(dataTable.getRowByContainingText(file2).isPresent()).toBe(false, 'Item was not deleted');
|
||||||
expect(dataTable.getRowByContainingText(folder2).isPresent()).toBe(false, 'Item was not deleted');
|
expect(dataTable.getRowByContainingText(folder2).isPresent()).toBe(false, 'Item was not deleted');
|
||||||
expect(trashPage.getSnackBarMessage()).toBe(`2 items deleted`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
148
e2e/suites/actions/restore.test.ts
Normal file
148
e2e/suites/actions/restore.test.ts
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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('Restore from Trash', () => {
|
||||||
|
const username = `user-${Utils.random()}`;
|
||||||
|
|
||||||
|
const file1 = `file-${Utils.random()}.txt`;
|
||||||
|
let file1Id;
|
||||||
|
const file2 = `file-${Utils.random()}.txt`;
|
||||||
|
let file2Id;
|
||||||
|
const file3 = `file-${Utils.random()}.txt`;
|
||||||
|
let file3Id;
|
||||||
|
|
||||||
|
const folder1 = `folder-${Utils.random()}`;
|
||||||
|
let folder1Id;
|
||||||
|
const folder2 = `folder-${Utils.random()}`;
|
||||||
|
let folder2Id;
|
||||||
|
|
||||||
|
const apis = {
|
||||||
|
admin: new RepoClient(),
|
||||||
|
user: new RepoClient(username, username)
|
||||||
|
};
|
||||||
|
|
||||||
|
const loginPage = new LoginPage();
|
||||||
|
const logoutPage = new LogoutPage();
|
||||||
|
const trashPage = new BrowsingPage();
|
||||||
|
const personalFilesPage = new BrowsingPage();
|
||||||
|
const { dataTable } = trashPage;
|
||||||
|
const { toolbar } = trashPage;
|
||||||
|
|
||||||
|
beforeAll(done => {
|
||||||
|
apis.admin.people.createUser(username)
|
||||||
|
.then(() => apis.user.nodes.createFiles([ file1 ]).then(resp => file1Id = resp.data.entry.id))
|
||||||
|
.then(() => apis.user.nodes.createFiles([ file2 ]).then(resp => file2Id = resp.data.entry.id))
|
||||||
|
.then(() => apis.user.nodes.createFiles([ file3 ]).then(resp => file3Id = resp.data.entry.id))
|
||||||
|
.then(() => apis.user.nodes.createFolders([ folder1 ]).then(resp => folder1Id = resp.data.entry.id))
|
||||||
|
.then(() => apis.user.nodes.createFolders([ folder2 ]).then(resp => folder2Id = resp.data.entry.id))
|
||||||
|
|
||||||
|
.then(() => apis.user.nodes.deleteNodeById(file1Id, false))
|
||||||
|
.then(() => apis.user.nodes.deleteNodeById(file2Id, false))
|
||||||
|
.then(() => apis.user.nodes.deleteNodeById(file3Id, false))
|
||||||
|
.then(() => apis.user.nodes.deleteNodeById(folder1Id, false))
|
||||||
|
.then(() => apis.user.nodes.deleteNodeById(folder2Id, 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.user.nodes.deleteNodeById(file1Id),
|
||||||
|
apis.user.nodes.deleteNodeById(file2Id),
|
||||||
|
apis.user.nodes.deleteNodeById(file3Id),
|
||||||
|
apis.user.nodes.deleteNodeById(folder1Id),
|
||||||
|
apis.user.nodes.deleteNodeById(folder2Id),
|
||||||
|
logoutPage.load()
|
||||||
|
])
|
||||||
|
.then(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('restore file', () => {
|
||||||
|
dataTable.clickOnRowByContainingText(file1)
|
||||||
|
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
|
||||||
|
.then(() => trashPage.getSnackBarMessage())
|
||||||
|
.then(text => {
|
||||||
|
expect(text).toContain(`${file1} restored`);
|
||||||
|
expect(text).toContain(`View`);
|
||||||
|
expect(dataTable.getRowByContainingText(file1).isPresent()).toBe(false, 'Item was not removed from list');
|
||||||
|
})
|
||||||
|
.then(() => personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES))
|
||||||
|
.then(() => personalFilesPage.dataTable.waitForHeader())
|
||||||
|
.then(() => {
|
||||||
|
expect(personalFilesPage.dataTable.getRowByContainingText(file1).isPresent()).toBe(true, 'Item not displayed in list');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('restore folder', () => {
|
||||||
|
dataTable.clickOnRowByContainingText(folder1)
|
||||||
|
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
|
||||||
|
.then(() => trashPage.getSnackBarMessage())
|
||||||
|
.then(text => {
|
||||||
|
expect(text).toContain(`${folder1} restored`);
|
||||||
|
expect(text).toContain(`View`);
|
||||||
|
expect(dataTable.getRowByContainingText(folder1).isPresent()).toBe(false, 'Item was not removed from list');
|
||||||
|
})
|
||||||
|
.then(() => personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES))
|
||||||
|
.then(() => personalFilesPage.dataTable.waitForHeader())
|
||||||
|
.then(() => {
|
||||||
|
expect(personalFilesPage.dataTable.getRowByContainingText(folder1).isPresent()).toBe(true, 'Item not displayed in list');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('restore multiple items', () => {
|
||||||
|
dataTable.selectMultipleItems([ file2, folder2 ])
|
||||||
|
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
|
||||||
|
.then(() => trashPage.getSnackBarMessage())
|
||||||
|
.then(text => {
|
||||||
|
expect(text).toContain(`Restore successful`);
|
||||||
|
expect(text).not.toContain(`View`);
|
||||||
|
expect(dataTable.getRowByContainingText(file2).isPresent()).toBe(false, 'Item was not removed from list');
|
||||||
|
expect(dataTable.getRowByContainingText(folder2).isPresent()).toBe(false, 'Item was not removed from list');
|
||||||
|
})
|
||||||
|
.then(() => personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES))
|
||||||
|
.then(() => personalFilesPage.dataTable.waitForHeader())
|
||||||
|
.then(() => {
|
||||||
|
expect(personalFilesPage.dataTable.getRowByContainingText(file2).isPresent()).toBe(true, 'Item not displayed in list');
|
||||||
|
expect(personalFilesPage.dataTable.getRowByContainingText(folder2).isPresent()).toBe(true, 'Item not displayed in list');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('View from notification', () => {
|
||||||
|
dataTable.clickOnRowByContainingText(file3)
|
||||||
|
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
|
||||||
|
.then(() => trashPage.getSnackBarAction().click())
|
||||||
|
.then(() => personalFilesPage.dataTable.waitForHeader())
|
||||||
|
.then(() => {
|
||||||
|
expect(personalFilesPage.sidenav.isActiveByLabel('Personal Files')).toBe(true, 'Personal Files sidebar link not active');
|
||||||
|
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -9,6 +9,7 @@ const projectRoot = path.resolve(__dirname);
|
|||||||
|
|
||||||
exports.config = {
|
exports.config = {
|
||||||
allScriptsTimeout: 11000,
|
allScriptsTimeout: 11000,
|
||||||
|
|
||||||
specs: [
|
specs: [
|
||||||
'./e2e/suites/authentication/*.test.ts',
|
'./e2e/suites/authentication/*.test.ts',
|
||||||
'./e2e/suites/list-views/*.test.ts',
|
'./e2e/suites/list-views/*.test.ts',
|
||||||
@@ -17,6 +18,7 @@ exports.config = {
|
|||||||
'./e2e/suites/pagination/pagination.test.ts',
|
'./e2e/suites/pagination/pagination.test.ts',
|
||||||
'./e2e/suites/actions/*.test.ts'
|
'./e2e/suites/actions/*.test.ts'
|
||||||
],
|
],
|
||||||
|
|
||||||
capabilities: {
|
capabilities: {
|
||||||
'browserName': 'chrome',
|
'browserName': 'chrome',
|
||||||
chromeOptions: {
|
chromeOptions: {
|
||||||
@@ -25,14 +27,18 @@ exports.config = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
directConnect: true,
|
directConnect: true,
|
||||||
|
|
||||||
baseUrl: 'http://localhost:3000',
|
baseUrl: 'http://localhost:3000',
|
||||||
|
|
||||||
framework: 'jasmine2',
|
framework: 'jasmine2',
|
||||||
jasmineNodeOpts: {
|
jasmineNodeOpts: {
|
||||||
showColors: true,
|
showColors: true,
|
||||||
defaultTimeoutInterval: 30000,
|
defaultTimeoutInterval: 30000,
|
||||||
print: function() {}
|
print: function() {}
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [{
|
plugins: [{
|
||||||
package: 'jasmine2-protractor-utils',
|
package: 'jasmine2-protractor-utils',
|
||||||
disableHTMLReport: false,
|
disableHTMLReport: false,
|
||||||
@@ -43,10 +49,12 @@ exports.config = {
|
|||||||
htmlReportDir: `${projectRoot}/e2e-output/html-report/`,
|
htmlReportDir: `${projectRoot}/e2e-output/html-report/`,
|
||||||
screenshotPath: `${projectRoot}/e2e-output/screenshots/`
|
screenshotPath: `${projectRoot}/e2e-output/screenshots/`
|
||||||
}],
|
}],
|
||||||
|
|
||||||
onPrepare() {
|
onPrepare() {
|
||||||
require('ts-node').register({
|
require('ts-node').register({
|
||||||
project: 'e2e/tsconfig.e2e.json'
|
project: 'e2e/tsconfig.e2e.json'
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
||||||
|
|
||||||
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
|
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
|
||||||
@@ -57,5 +65,23 @@ exports.config = {
|
|||||||
useFullTestName: false,
|
useFullTestName: false,
|
||||||
reportFailedUrl: true
|
reportFailedUrl: true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
return browser.driver.executeScript(disableCSSAnimation);
|
||||||
|
|
||||||
|
function disableCSSAnimation() {
|
||||||
|
var css = '* {' +
|
||||||
|
'-webkit-transition-duration: 0s !important;' +
|
||||||
|
'transition-duration: 0s !important;' +
|
||||||
|
'-webkit-animation-duration: 0s !important;' +
|
||||||
|
'animation-duration: 0s !important;' +
|
||||||
|
'}',
|
||||||
|
head = document.head || document.getElementsByTagName('head')[0],
|
||||||
|
style = document.createElement('style');
|
||||||
|
|
||||||
|
style.type = 'text/css';
|
||||||
|
style.appendChild(document.createTextNode(css));
|
||||||
|
head.appendChild(style);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user