Skip to content

Commit

Permalink
[ACA-1946] automate tests for Favourite Libraries list (#803)
Browse files Browse the repository at this point in the history
* automate part of the Favourite Libraries tests
refactor File Libraries tests to include My Libraries

* rephrasing

* forgotten changes

* fix tests
  • Loading branch information
adinapitul authored and suzanadirla committed Nov 16, 2018
1 parent dcacbc1 commit ca67da3
Show file tree
Hide file tree
Showing 24 changed files with 413 additions and 189 deletions.
71 changes: 39 additions & 32 deletions e2e/components/sidenav/sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class Sidenav extends Component {
label: '.item--label',
expansion_panel: ".mat-expansion-panel-header",
expansion_panel_content: ".mat-expansion-panel-body",
active: 'item--active',
activeLink: '.item--active',
newButton: '[data-automation-id="create-button"]'
};
Expand All @@ -50,6 +51,23 @@ export class Sidenav extends Component {
super(Sidenav.selectors.root, ancestor);
}

private async expandMenu(name: string) {
try{

if (await element(by.cssContainingText('.mat-expanded', name)).isPresent()) {
return Promise.resolve();
} else {
const link = this.getLink(name);
await Utils.waitUntilElementClickable(link);
await link.click();
await element(by.css(Sidenav.selectors.expansion_panel_content)).isPresent();
}

} catch (e) {
console.log('---- sidebar navigation catch expandMenu: ', e);
}
}

async openNewMenu() {
const { menu, newButton } = this;

Expand All @@ -67,60 +85,49 @@ export class Sidenav extends Component {
await this.menu.clickMenuItem('Create Library');
}

async isActiveByLabel(label: string) {
const className = await this.getLinkByLabel(label).getAttribute('class');
return className.includes(Sidenav.selectors.activeLink.replace('.', ''));
async isActive(name: string) {
const className = await this.getLinkLabel(name).getAttribute('class');
return className.includes(Sidenav.selectors.active);
}

async childIsActiveByLabel(label: string) {
const labelElement = await this.getLinkByLabel(label).element(by.css('span'));
return (await labelElement.getAttribute('class'))
.includes(Sidenav.selectors.activeLink.replace('.', ''));
async childIsActive(name: string) {
const childClass = await this.getLinkLabel(name).element(by.css('span')).getAttribute('class');
return childClass.includes(Sidenav.selectors.active);
}

getLink(label: string) {
return this.component.element(by.cssContainingText(Sidenav.selectors.link, label));
getLink(name: string) {
return this.getLinkLabel(name).element(by.xpath('..'));
}

getLinkByLabel(label: string) {
return this.component.element(by.cssContainingText(Sidenav.selectors.label, label));
// return browser.element(by.xpath(`.//*[.="${label}" and class="${Sidenav.selectors.label}"]`))
getLinkLabel(name: string) {
return this.component.element(by.cssContainingText(Sidenav.selectors.label, name));
}

async getLinkTooltip(label: string) {
return await this.getLink(label).getAttribute('title');
getActiveLink() {
return this.activeLink;
}

async navigateToLinkByLabel(label: string) {
async getLinkTooltip(name: string) {
return await this.getLink(name).getAttribute('title');
}

async navigateToLink(name: string) {
try{
const link = this.getLinkByLabel(label);
const link = this.getLinkLabel(name);
await Utils.waitUntilElementClickable(link);
return await link.click();

} catch (e){
console.log('---- sidebar navigation catch navigateToLinkByLabel: ', e);
console.log('---- sidebar navigation catch navigateToLink: ', e);
}
}

async isFileLibrariesMenuExpanded() {
return await element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent();
}

async expandMenu(label: string) {
try{

if (await element(by.cssContainingText('.mat-expanded', label)).isPresent()) {
return Promise.resolve();
} else {
const link = this.getLinkByLabel(label);
await Utils.waitUntilElementClickable(link);
await link.click();
await element(by.css(Sidenav.selectors.expansion_panel_content)).isPresent();
}

} catch (e) {
console.log('---- sidebar navigation catch expandMenu: ', e);
}
async expandFileLibraries() {
return await this.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
}

}
24 changes: 19 additions & 5 deletions e2e/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const E2E_ROOT_PATH = __dirname;
export const APP_ROUTES = {
FAVORITES: '/favorites',
MY_LIBRARIES: '/libraries',
FAVORITE_LIBRARIES: '/favorite/libraries',
LOGIN: '/login',
LOGOUT: '/logout',
PERSONAL_FILES: '/personal-files',
Expand All @@ -70,7 +71,8 @@ export const SIDEBAR_LABELS = {
export const PAGE_TITLES = {
VIEWER: 'Preview',
SEARCH: 'Search Results',
MY_LIBRARIES: 'File Libraries'
MY_LIBRARIES: 'My Libraries',
FAVORITE_LIBRARIES: 'Favorite Libraries'
};

// Site visibility
Expand All @@ -82,10 +84,22 @@ export const SITE_VISIBILITY = {

// Site roles
export const SITE_ROLES = {
SITE_CONSUMER: 'SiteConsumer',
SITE_COLLABORATOR: 'SiteCollaborator',
SITE_CONTRIBUTOR: 'SiteContributor',
SITE_MANAGER: 'SiteManager'
SITE_CONSUMER: {
ROLE: 'SiteConsumer',
LABEL: 'Consumer'
},
SITE_COLLABORATOR: {
ROLE: 'SiteCollaborator',
LABEL: 'Collaborator'
},
SITE_CONTRIBUTOR: {
ROLE: 'SiteContributor',
LABEL: 'Contributor'
},
SITE_MANAGER: {
ROLE: 'SiteManager',
LABEL: 'Manager'
}
};

export const FILES = {
Expand Down
40 changes: 20 additions & 20 deletions e2e/pages/browsing-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,75 +43,75 @@ export class BrowsingPage extends Page {
// helper methods

async clickPersonalFilesAndWait() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.PERSONAL_FILES);
await this.dataTable.waitForHeader();
}

async clickPersonalFiles() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.PERSONAL_FILES);
}


async clickFileLibrariesAndWait() {
await this.sidenav.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.MY_LIBRARIES);
await this.sidenav.expandFileLibraries();
await this.sidenav.navigateToLink(SIDEBAR_LABELS.MY_LIBRARIES);
await this.dataTable.waitForHeader();
}

async clickFileLibraries() {
await this.sidenav.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.MY_LIBRARIES);
await this.sidenav.expandFileLibraries();
await this.sidenav.navigateToLink(SIDEBAR_LABELS.MY_LIBRARIES);
}

async clickFavoriteLibraries() {
await this.sidenav.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITE_LIBRARIES);
async goToFavoriteLibraries() {
await this.sidenav.expandFileLibraries();
await this.sidenav.navigateToLink(SIDEBAR_LABELS.FAVORITE_LIBRARIES);
}

async clickMyLibraries() {
async goToMyLibraries() {
if ( !(await this.sidenav.isFileLibrariesMenuExpanded()) ) {
await this.sidenav.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
await this.sidenav.expandFileLibraries();
}
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.MY_LIBRARIES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.MY_LIBRARIES);
}

async clickRecentFilesAndWait() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.RECENT_FILES);
await this.dataTable.waitForHeader();
}

async clickRecentFiles() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.RECENT_FILES);
}


async clickSharedFilesAndWait() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.SHARED_FILES);
await this.dataTable.waitForHeader();
}

async clickSharedFiles() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.SHARED_FILES);
}


async clickFavoritesAndWait() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.FAVORITES);
await this.dataTable.waitForHeader();
}

async clickFavorites() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.FAVORITES);
}


async clickTrashAndWait() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.TRASH);
await this.dataTable.waitForHeader();
}

async clickTrash() {
await this.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH);
await this.sidenav.navigateToLink(SIDEBAR_LABELS.TRASH);
}

}
2 changes: 1 addition & 1 deletion e2e/suites/actions/context-menu-single-selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('Context menu actions - single selection : ', () => {
it('Context menu closes when clicking away from it - [C280619]', async () => {
await dataTable.rightClickOnItem(fileUser);
expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed');
await page.sidenav.activeLink.click();
await page.sidenav.getActiveLink().click();
expect(await dataTable.hasContextMenu()).toBe(false, 'Context menu is displayed');
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/suites/actions/create-folder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Create folder', () => {
await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE);
const docLibId = (await apis.admin.sites.getDocLibId(siteName));
await apis.admin.nodes.createFolder(folderName1, docLibId);
await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER);
await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER.ROLE);
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFolder(duplicateFolderName, parentId);
await loginPage.loginWith(username);
Expand Down
2 changes: 1 addition & 1 deletion e2e/suites/actions/edit-folder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Edit folder', () => {
await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE);
const docLibId = await apis.admin.sites.getDocLibId(siteName);
await apis.admin.nodes.createFolder(folderName, docLibId);
await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER);
await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER.ROLE);

parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFolder(folderName, parentId, '', folderDescription);
Expand Down
2 changes: 1 addition & 1 deletion e2e/suites/actions/restore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('Restore from Trash', () => {
await toolbar.getButtonByTitleAttribute('Restore').click();
await page.clickSnackBarAction();
await page.dataTable.waitForHeader();
expect(await page.sidenav.isActiveByLabel('Personal Files')).toBe(true, 'Personal Files sidebar link not active');
expect(await page.sidenav.isActive('Personal Files')).toBe(true, 'Personal Files sidebar link not active');
expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);

await apis.user.nodes.deleteNodeById(fileId, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ describe('Granular permissions available actions : ', () => {

docxFileId = (await apis.admin.upload.uploadFile(docxFile, docLibId)).entry.id;

await apis.admin.sites.addSiteMember(siteName, userManager, SITE_ROLES.SITE_MANAGER);
await apis.admin.sites.addSiteMember(siteName, userConsumer, SITE_ROLES.SITE_CONSUMER);
await apis.admin.sites.addSiteMember(siteName, userManager, SITE_ROLES.SITE_MANAGER.ROLE);
await apis.admin.sites.addSiteMember(siteName, userConsumer, SITE_ROLES.SITE_CONSUMER.ROLE);

await apis.admin.nodes.setGranularPermission(file3Id, false, userConsumer, SITE_ROLES.SITE_MANAGER);
await apis.admin.nodes.setGranularPermission(file3Id, false, userConsumer, SITE_ROLES.SITE_MANAGER.ROLE);

await apis.userConsumer.shared.shareFileById(file1Id);
await apis.userConsumer.shared.shareFileById(file2Id);
Expand Down
34 changes: 26 additions & 8 deletions e2e/suites/actions/toolbar-single-selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,28 @@ describe('Toolbar actions - single selection : ', () => {
xit('');

describe('General tests', () => {
it('actions are displayed for top level of File Libraries - [C213135]', async () => {
await page.clickFileLibrariesAndWait();
beforeEach(async (done) => {
await Utils.pressEscape();
await dataTable.clearSelection();
done();
});

it('Correct actions appear when a library is selected - My Libraries - [C213135]', async () => {
await page.goToMyLibraries();
await dataTable.selectItem(siteName);
expect(await toolbar.isEmpty()).toBe(false, 'toolbar not displayed');
expect(await toolbar.isButtonPresent('View details')).toBe(true, `View details is not displayed for ${siteName}`);
await toolbar.openMoreMenu();
expect(await toolbar.menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${siteName}`);
});

it('Correct actions appear when a library is selected - Favorite Libraries - [C289892]', async () => {
await page.goToFavoriteLibraries();
await dataTable.selectItem(siteName);
expect(await toolbar.isEmpty()).toBe(false, 'toolbar not displayed');
expect(await toolbar.isButtonPresent('View details')).toBe(true, `View details is not displayed for ${siteName}`);
await toolbar.openMoreMenu();
expect(await toolbar.menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${siteName}`);
});

it('selected row is marked with a check circle icon - [C213134]', async () => {
Expand All @@ -103,7 +121,7 @@ describe('Toolbar actions - single selection : ', () => {
});
});

describe('Personal Files', () => {
describe('on Personal Files', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickPersonalFilesAndWait();
Expand Down Expand Up @@ -144,7 +162,7 @@ describe('Toolbar actions - single selection : ', () => {
});
});

describe('File Libraries', () => {
describe('on File Libraries', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickFileLibrariesAndWait();
Expand Down Expand Up @@ -187,7 +205,7 @@ describe('Toolbar actions - single selection : ', () => {
});
});

describe('Shared Files', () => {
describe('on Shared Files', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickSharedFilesAndWait();
Expand Down Expand Up @@ -215,7 +233,7 @@ describe('Toolbar actions - single selection : ', () => {
});
});

describe('Recent Files', () => {
describe('on Recent Files', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickRecentFilesAndWait();
Expand All @@ -242,7 +260,7 @@ describe('Toolbar actions - single selection : ', () => {
});
});

describe('Favorites', () => {
describe('on Favorites', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickFavoritesAndWait();
Expand Down Expand Up @@ -283,7 +301,7 @@ describe('Toolbar actions - single selection : ', () => {
});
});

describe('Trash', () => {
describe('on Trash', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickTrashAndWait();
Expand Down
2 changes: 1 addition & 1 deletion e2e/suites/actions/unshare-file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ describe('Unshare a file', () => {
file1Id = (await apis.admin.nodes.createFile(file1, docLibId)).entry.id;
file2Id = (await apis.admin.nodes.createFile(file2, docLibId)).entry.id;

await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER);
await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE);

await apis.admin.shared.shareFileById(file1Id);
await apis.user.shared.shareFileById(file2Id);
Expand Down
Loading

0 comments on commit ca67da3

Please sign in to comment.