[ACA-1760] use async / await in list-views suite (#669)

This commit is contained in:
Adina Parpalita
2018-09-26 12:09:16 +03:00
committed by Denys Vuika
parent 4ff92c23e5
commit 23df2ad6a2
10 changed files with 1167 additions and 1235 deletions

View File

@@ -29,112 +29,113 @@ import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Recent Files', () => {
const username = `user-${Utils.random()}`;
const username = `user-${Utils.random()}`;
const folderName = `folder-${Utils.random()}`; let folderId;
const fileName1 = `file-${Utils.random()}.txt`;
const fileName2 = `file-${Utils.random()}.txt`; let file2Id;
const fileName3 = `file-${Utils.random()}.txt`;
const folderName = `folder-${Utils.random()}`; let folderId;
const fileName1 = `file-${Utils.random()}.txt`;
const fileName2 = `file-${Utils.random()}.txt`; let file2Id;
const fileName3 = `file-${Utils.random()}.txt`;
const siteName = `site-${Utils.random()}`;
const folderSite = `folder2-${Utils.random()}`; let folderSiteId;
const fileSite = `file-${Utils.random()}.txt`;
const siteName = `site-${Utils.random()}`;
const folderSite = `folder2-${Utils.random()}`; let folderSiteId;
const fileSite = `file-${Utils.random()}.txt`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const recentFilesPage = new BrowsingPage();
const { dataTable, breadcrumb } = recentFilesPage;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const recentFilesPage = new BrowsingPage();
const { dataTable, breadcrumb } = recentFilesPage;
beforeAll(done => {
apis.admin.people.createUser({ username })
.then(() => apis.user.nodes.createFolders([ folderName ])).then(resp => folderId = resp.entry.id)
.then(() => apis.user.nodes.createFiles([ fileName1 ], folderName))
.then(() => apis.user.nodes.createFiles([ fileName2 ])).then(resp => file2Id = resp.entry.id)
.then(() => apis.user.nodes.createFiles([ fileName3 ]).then(resp => apis.user.nodes.deleteNodeById(resp.entry.id, false)))
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
folderId = (await apis.user.nodes.createFolders([ folderName ])).entry.id;
await apis.user.nodes.createFiles([ fileName1 ], folderName);
file2Id = (await apis.user.nodes.createFiles([ fileName2 ])).entry.id;
const id = (await apis.user.nodes.createFiles([ fileName3 ])).entry.id;
await apis.user.nodes.deleteNodeById(id, false);
.then(() => apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.user.sites.getDocLibId(siteName))
.then(resp => apis.user.nodes.createFolder(folderSite, resp)).then(resp => folderSiteId = resp.entry.id)
.then(() => apis.user.nodes.createFile(fileSite, folderSiteId))
await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC);
const docLibId = await apis.user.sites.getDocLibId(siteName);
folderSiteId = (await apis.user.nodes.createFolder(folderSite, docLibId)).entry.id;
await apis.user.nodes.createFile(fileSite, folderSiteId);
.then(() => apis.user.search.waitForApi(username, { expect: 3 }))
await apis.user.search.waitForApi(username, { expect: 3 });
.then(() => loginPage.loginWith(username))
.then(done);
await loginPage.loginWith(username);
done();
});
beforeEach(async (done) => {
await recentFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES);
await dataTable.waitForHeader();
done();
});
afterAll(async (done) => {
await Promise.all([
apis.user.nodes.deleteNodesById([ folderId, file2Id ]),
apis.user.sites.deleteSite(siteName),
apis.admin.trashcan.emptyTrash(),
logoutPage.load()
]);
done();
});
it('has the correct columns - [C213168]', async () => {
const labels = [ 'Name', 'Location', 'Size', 'Modified' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(await dataTable.getColumnHeaders().count()).toBe(4 + 1, 'Incorrect number of columns');
await elements.forEach(async (element, index) => {
expect(await element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
beforeEach(done => {
recentFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
it('default sorting column - [C213171]', async () => {
expect(await dataTable.getSortedColumnHeader().getText()).toBe('Modified');
expect(await dataTable.getSortingOrder()).toBe('desc');
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodesById([ folderId, file2Id ]),
apis.user.sites.deleteSite(siteName),
apis.admin.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('displays the files added by the current user in the last 30 days - [C213170]', async () => {
expect(await dataTable.countRows()).toEqual(3, 'Incorrect number of files displayed');
expect(await dataTable.getRowByName(fileName1).isPresent()).toBe(true, `${fileName1} not displayed`);
expect(await dataTable.getRowByName(fileName2).isPresent()).toBe(true, `${fileName2} not displayed`);
expect(await dataTable.getRowByName(fileSite).isPresent()).toBe(true, `${fileSite} not displayed`);
});
it('has the correct columns - [C213168]', () => {
const labels = [ 'Name', 'Location', 'Size', 'Modified' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
it(`file not displayed if it's been deleted - [C213174]`, async () => {
expect(await dataTable.getRowByName(fileName3).isPresent()).not.toBe(true, `${fileName3} is displayed`);
});
expect(dataTable.getColumnHeaders().count()).toBe(4 + 1, 'Incorrect number of columns');
it('Location column displays the parent folder of the file - [C213175]', async () => {
expect(await dataTable.getItemLocation(fileName1).getText()).toEqual(folderName);
expect(await dataTable.getItemLocation(fileName2).getText()).toEqual('Personal Files');
expect(await dataTable.getItemLocation(fileSite).getText()).toEqual(folderSite);
});
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('Location column displays a tooltip with the entire path of the file - [C213177]', async () => {
expect(await dataTable.getItemLocationTileAttr(fileName1)).toEqual(`Personal Files/${folderName}`);
expect(await dataTable.getItemLocationTileAttr(fileName2)).toEqual('Personal Files');
expect(await dataTable.getItemLocationTileAttr(fileSite)).toEqual(`File Libraries/${siteName}/${folderSite}`);
});
it('default sorting column - [C213171]', () => {
expect(dataTable.getSortedColumnHeader().getText()).toBe('Modified');
expect(dataTable.getSortingOrder()).toBe('desc');
});
it('Location column redirect - file in user Home - [C213176]', async () => {
await dataTable.clickItemLocation(fileName2);
expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]);
});
it('displays the files added by the current user in the last 30 days - [C213170]', () => {
expect(dataTable.countRows()).toEqual(3, 'Incorrect number of files displayed');
expect(dataTable.getRowByName(fileName1).isPresent()).toBe(true, `${fileName1} not displayed`);
expect(dataTable.getRowByName(fileName2).isPresent()).toBe(true, `${fileName2} not displayed`);
expect(dataTable.getRowByName(fileSite).isPresent()).toBe(true, `${fileSite} not displayed`);
});
it('Location column redirect - file in folder - [C280486]', async () => {
await dataTable.clickItemLocation(fileName1);
expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderName ]);
});
it(`file not displayed if it's been deleted - [C213174]`, () => {
expect(dataTable.getRowByName(fileName3).isPresent()).not.toBe(true, `${fileName3} is displayed`);
});
it('Location column displays the parent folder of the file - [C213175]', () => {
expect(dataTable.getItemLocation(fileName1).getText()).toEqual(folderName);
expect(dataTable.getItemLocation(fileName2).getText()).toEqual('Personal Files');
expect(dataTable.getItemLocation(fileSite).getText()).toEqual(folderSite);
});
it('Location column displays a tooltip with the entire path of the file - [C213177]', () => {
expect(dataTable.getItemLocationTileAttr(fileName1)).toEqual(`Personal Files/${folderName}`);
expect(dataTable.getItemLocationTileAttr(fileName2)).toEqual('Personal Files');
expect(dataTable.getItemLocationTileAttr(fileSite)).toEqual(`File Libraries/${siteName}/${folderSite}`);
});
it('Location column redirect - file in user Home - [C213176]', () => {
dataTable.clickItemLocation(fileName2)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]));
});
it('Location column redirect - file in folder - [C280486]', () => {
dataTable.clickItemLocation(fileName1)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderName ]));
});
it('Location column redirect - file in site - [C280487]', () => {
dataTable.clickItemLocation(fileSite)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'File Libraries', siteName, folderSite ]));
});
it('Location column redirect - file in site - [C280487]', async () => {
await dataTable.clickItemLocation(fileSite);
expect(await breadcrumb.getAllItems()).toEqual([ 'File Libraries', siteName, folderSite ]);
});
});