[ACA-1627] add automated tests for Comments (#1012)

This commit is contained in:
Adina Parpalita 2019-03-12 08:42:55 -07:00 committed by Denys Vuika
parent 714b566788
commit dbf821628c
6 changed files with 683 additions and 3 deletions

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { ElementFinder, ElementArrayFinder, by, browser, ExpectedConditions as EC } from 'protractor'; import { ElementFinder, ElementArrayFinder, by, browser, ExpectedConditions as EC, until } from 'protractor';
import { Component } from '../component'; import { Component } from '../component';
import { BROWSER_WAIT_TIMEOUT } from '../../configs'; import { BROWSER_WAIT_TIMEOUT } from '../../configs';
@ -44,6 +44,19 @@ export class InfoDrawer extends Component {
headerTitle: '.adf-info-drawer-layout-header-title', headerTitle: '.adf-info-drawer-layout-header-title',
// comments tab
commentsContainer: '.adf-comments-container',
commentsHeader: '.adf-comments-header',
commentsTextArea: '.adf-comments-input-container textarea',
addCommentButton: 'button.adf-comments-input-add',
commentsList: '.adf-comment-list',
commentsListItem: '.adf-comment-list-item',
commentById: `adf-comment-`,
commentUserName: 'comment-user',
commentUserAvatar: 'comment-user-icon',
commentMessage: 'comment-message',
commentTime: 'comment-time',
// metadata card // metadata card
metadataTabContent: '.app-metadata-tab .mat-card-content', metadataTabContent: '.app-metadata-tab .mat-card-content',
metadataTabAction: '.app-metadata-tab .mat-card-actions .mat-button', metadataTabAction: '.app-metadata-tab .mat-card-actions .mat-button',
@ -65,6 +78,19 @@ export class InfoDrawer extends Component {
tabActiveContent: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.activeTabContent)); tabActiveContent: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.activeTabContent));
commentsContainer: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.commentsContainer));
commentsHeader: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.commentsHeader));
commentTextarea: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.commentsTextArea));
addCommentButton: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.addCommentButton));
commentsList: ElementArrayFinder = this.component.all(by.css(InfoDrawer.selectors.commentsListItem));
commentListItem = by.css(InfoDrawer.selectors.commentsListItem);
commentUserAvatar = by.id(InfoDrawer.selectors.commentUserAvatar);
commentUser = by.id(InfoDrawer.selectors.commentUserName)
commentText = by.id(InfoDrawer.selectors.commentMessage);
commentTime = by.id(InfoDrawer.selectors.commentTime);
nextButton: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.next)); nextButton: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.next));
previousButton: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.previous)); previousButton: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.previous));
@ -98,22 +124,36 @@ export class InfoDrawer extends Component {
return !(await browser.isElementPresent(by.css(InfoDrawer.selectors.tabs))); return !(await browser.isElementPresent(by.css(InfoDrawer.selectors.tabs)));
} }
async waitForCommentsTabContainer() {
await browser.wait(EC.visibilityOf(this.commentsContainer), BROWSER_WAIT_TIMEOUT);
}
getTabByTitle(title: string) { getTabByTitle(title: string) {
return this.component.element(by.cssContainingText(InfoDrawer.selectors.tabLabel, title)); return this.component.element(by.cssContainingText(InfoDrawer.selectors.tabLabel, title));
} }
async getTabsCount() {
return await this.component.all(by.css(InfoDrawer.selectors.tabLabel)).count();
}
async isTabPresent(title: string) { async isTabPresent(title: string) {
return await this.getTabByTitle(title).isPresent(); return await this.getTabByTitle(title).isPresent();
} }
async isTabDisplayed(title: string) { async isTabDisplayed(title: string) {
return await this.getTabByTitle(title).isDisplayed(); if (await browser.isElementPresent(this.getTabByTitle(title))) {
return await this.getTabByTitle(title).isDisplayed();
}
} }
async getTabTitle(index: number) { async getTabTitle(index: number) {
return await this.tabLabelsList.get(index - 1).getAttribute('innerText'); return await this.tabLabelsList.get(index - 1).getAttribute('innerText');
} }
async getActiveTabTitle() {
return await this.tabActiveLabel.getText();
}
async clickTab(title: string) { async clickTab(title: string) {
await this.getTabByTitle(title).click(); await this.getTabByTitle(title).click();
} }
@ -184,6 +224,34 @@ export class InfoDrawer extends Component {
return await this.isTabDisplayed('About'); return await this.isTabDisplayed('About');
} }
async isPropertiesTabDisplayed() {
return await this.isTabDisplayed('Properties');
}
async isCommentsTabDisplayed() {
return await this.isTabDisplayed('Comments');
}
async clickCommentsTab() {
try {
await this.getTabByTitle('Comments').click();
await this.waitForCommentsTabContainer();
await browser.wait(EC.visibilityOf(this.addCommentButton), BROWSER_WAIT_TIMEOUT);
} catch (error) {
console.error('--- catch error on clickCommentsTab ---');
throw error;
}
}
async clickAboutTab() {
try {
return await this.getTabByTitle('About').click();
} catch (error) {
console.error('--- catch error on clickAboutTab ---');
}
}
async isMessageDisplayed() { async isMessageDisplayed() {
return await browser.isElementPresent(this.hint); return await browser.isElementPresent(this.hint);
@ -321,5 +389,75 @@ export class InfoDrawer extends Component {
return await this.clickButton('Cancel'); return await this.clickButton('Cancel');
} }
async getCommentsTabHeaderText() {
return await this.commentsHeader.getText();
}
async isCommentTextAreaDisplayed() {
return await browser.isElementPresent(this.commentTextarea);
}
async isAddCommentButtonEnabled() {
const present = await browser.isElementPresent(this.addCommentButton);
if (present) {
return await this.addCommentButton.isEnabled();
}
return false;
}
async getCommentListItem() {
return await browser.wait(until.elementLocated(this.commentListItem), BROWSER_WAIT_TIMEOUT / 2);
}
async getCommentById(commentId?: string) {
if (commentId) {
return await browser.wait(until.elementLocated(by.id(`${InfoDrawer.selectors.commentById}${commentId}`)), BROWSER_WAIT_TIMEOUT / 2);
}
return await this.getCommentListItem();
}
async isCommentDisplayed(commentId?: string) {
return await browser.isElementPresent(await this.getCommentById(commentId));
}
async isCommentUserAvatarDisplayed(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
return await browser.isElementPresent(commentElement.findElement(this.commentUserAvatar));
}
async getCommentText(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
const message = await commentElement.findElement(this.commentText);
return await message.getText();
}
async getCommentUserName(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
const user = await commentElement.findElement(this.commentUser);
return await user.getText();
}
async getCommentTime(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
const time = await commentElement.findElement(this.commentTime);
return await time.getText();
}
async getNthCommentId(index: number) {
return await this.commentsList.get(index - 1).getAttribute('id');
}
async typeComment(text: string) {
return await this.commentTextarea.sendKeys(text);
}
async clickAddButton() {
return await this.addCommentButton.click();
}
async getCommentTextFromTextArea() {
return await this.commentTextarea.getAttribute('value');
}
} }

View File

@ -0,0 +1,398 @@
/*!
* @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 { LoginPage, BrowsingPage } from '../../pages/pages';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { InfoDrawer } from './../../components/info-drawer/info-drawer';
import { Utils } from '../../utilities/utils';
import * as moment from 'moment';
describe('Comments', () => {
const username = `user1-${Utils.random()}`;
const parent = `parent-${Utils.random()}`; let parentId;
const file1 = `file1-${Utils.random()}.txt`;
const fileWith1Comment = `file1Comment-${Utils.random()}.txt`; let fileWith1CommentId;
const fileWith2Comments = `file2Comments-${Utils.random()}.txt`; let fileWith2CommentsId;
const file2Personal = `file2Personal-${Utils.random()}.txt`;
const file2Shared = `file2Shared-${Utils.random()}.txt`; let file2SharedId;
const file2Recent = `file2Recent-${Utils.random()}.txt`;
const file2Favorites = `file2Favorites-${Utils.random()}.txt`; let file2FavoritesId;
let commentFile1Entry;
let comment1File2Entry, comment2File2Entry;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const infoDrawer = new InfoDrawer();
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable } = page;
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFile(file1, parentId);
await apis.user.nodes.createFile(file2Personal, parentId);
await apis.user.nodes.createFile(file2Recent, parentId);
file2SharedId = (await apis.user.nodes.createFile(file2Shared, parentId)).entry.id
file2FavoritesId = (await apis.user.nodes.createFile(file2Favorites, parentId)).entry.id;
fileWith1CommentId = (await apis.user.nodes.createFile(fileWith1Comment, parentId)).entry.id;
fileWith2CommentsId = (await apis.user.nodes.createFile(fileWith2Comments, parentId)).entry.id;
commentFile1Entry = (await apis.user.comments.addComment(fileWith1CommentId, 'this is my comment')).entry;
comment1File2Entry = (await apis.user.comments.addComment(fileWith2CommentsId, 'first comment')).entry;
comment2File2Entry = (await apis.user.comments.addComment(fileWith2CommentsId, 'second comment')).entry;
await apis.user.shared.shareFilesByIds([file2SharedId, fileWith1CommentId, fileWith2CommentsId]);
await apis.user.favorites.addFavoritesByIds('file', [file2FavoritesId, fileWith1CommentId, fileWith2CommentsId]);
await loginPage.loginWith(username);
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
done();
});
describe('from Personal Files', () => {
beforeEach(async (done) => {
await page.clickPersonalFilesAndWait();
await dataTable.doubleClickOnRowByName(parent);
done();
});
afterEach(async (done) => {
await dataTable.clearSelection();
done();
});
it('Comments tab default fields - [C299173]', async () => {
await dataTable.selectItem(file1);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getActiveTabTitle()).toBe('COMMENTS');
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (0)');
expect(await infoDrawer.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await infoDrawer.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');
});
it('Comment info display - [C280582]', async () => {
await dataTable.selectItem(fileWith1Comment);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await infoDrawer.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');
expect(await infoDrawer.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await infoDrawer.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await infoDrawer.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await infoDrawer.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time');
expect(await infoDrawer.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
});
it('Comments are displayed ordered by created date in descending order - [C280583]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await infoDrawer.getNthCommentId(2)).toContain(comment1File2Entry.id);
});
it('Total number of comments is displayed - [C280585]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (2)');
});
it('Add button is enabled when typing in the comment field - [C280589]', async () => {
await dataTable.selectItem(file1);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');
await infoDrawer.typeComment('my comment');
expect(await infoDrawer.isAddCommentButtonEnabled()).toBe(true, 'Add comment button not enabled');
});
it('Add a comment - [C280590]', async () => {
const myComment = 'my comment';
await dataTable.selectItem(file2Personal);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await infoDrawer.typeComment(myComment);
await infoDrawer.clickAddButton();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await infoDrawer.getCommentText()).toBe(myComment, 'Incorrect comment text');
});
it('Escape key clears the text when focus is on the textarea - [C280591]', async () => {
await dataTable.selectItem(file2Personal);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await infoDrawer.typeComment('myComment');
expect(await infoDrawer.getCommentTextFromTextArea()).toBe('myComment');
await Utils.pressEscape();
expect(await infoDrawer.getCommentTextFromTextArea()).toBe('');
});
});
describe('from Favorites', () => {
beforeAll(async (done) => {
await apis.user.favorites.waitForApi({ expect: 3 });
done();
});
beforeEach(async (done) => {
await page.clickFavoritesAndWait();
done();
});
afterEach(async (done) => {
await dataTable.clearSelection();
done();
});
it('Comment info display - [C299196]', async () => {
await dataTable.selectItem(fileWith1Comment);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await infoDrawer.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');
expect(await infoDrawer.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await infoDrawer.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await infoDrawer.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await infoDrawer.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time');
expect(await infoDrawer.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
});
it('Comments are displayed ordered by created date in descending order - [C299197]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await infoDrawer.getNthCommentId(2)).toContain(comment1File2Entry.id);
});
it('Total number of comments is displayed - [C299198]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (2)');
});
it('Add a comment - [C299199]', async () => {
const myComment = 'my comment';
await dataTable.selectItem(file2Favorites);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await infoDrawer.typeComment(myComment);
await infoDrawer.clickAddButton();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await infoDrawer.getCommentText()).toBe(myComment, 'Incorrect comment text');
});
});
describe('from Shared Files', () => {
beforeAll(async (done) => {
await apis.user.shared.waitForApi({ expect: 3 });
done();
});
beforeEach(async (done) => {
await page.clickSharedFilesAndWait();
done();
});
afterEach(async (done) => {
await dataTable.clearSelection();
done();
});
it('Comment info display - [C299188]', async () => {
await dataTable.selectItem(fileWith1Comment);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await infoDrawer.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');
expect(await infoDrawer.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await infoDrawer.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await infoDrawer.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await infoDrawer.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time');
expect(await infoDrawer.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
});
it('Comments are displayed ordered by created date in descending order - [C299189]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await infoDrawer.getNthCommentId(2)).toContain(comment1File2Entry.id);
});
it('Total number of comments is displayed - [C299190]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (2)');
});
it('Add a comment - [C299191]', async () => {
const myComment = 'my comment';
await dataTable.selectItem(file2Shared);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await infoDrawer.typeComment(myComment);
await infoDrawer.clickAddButton();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await infoDrawer.getCommentText()).toBe(myComment, 'Incorrect comment text');
});
});
describe('from Recent Files', () => {
beforeAll(async (done) => {
await apis.user.search.waitForApi(username, { expect: 7 });
done();
});
beforeEach(async (done) => {
await page.clickRecentFilesAndWait();
done();
});
afterEach(async (done) => {
await dataTable.clearSelection();
done();
});
it('Comment info display - [C299192]', async () => {
await dataTable.selectItem(fileWith1Comment);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await infoDrawer.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');
expect(await infoDrawer.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await infoDrawer.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await infoDrawer.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await infoDrawer.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time');
expect(await infoDrawer.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
});
it('Comments are displayed ordered by created date in descending order - [C299193]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await infoDrawer.getNthCommentId(2)).toContain(comment1File2Entry.id);
});
it('Total number of comments is displayed - [C299194]', async () => {
await dataTable.selectItem(fileWith2Comments);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (2)');
});
it('Add a comment - [C299195]', async () => {
const myComment = 'my comment';
await dataTable.selectItem(file2Recent);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await infoDrawer.typeComment(myComment);
await infoDrawer.clickAddButton();
expect(await infoDrawer.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await infoDrawer.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await infoDrawer.getCommentText()).toBe(myComment, 'Incorrect comment text');
});
});
});

View File

@ -0,0 +1,90 @@
/*!
* @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 { LoginPage, BrowsingPage } from '../../pages/pages';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { InfoDrawer } from './../../components/info-drawer/info-drawer';
import { Utils } from '../../utilities/utils';
describe('General', () => {
const username = `user1-${Utils.random()}`;
const parent = `parent-${Utils.random()}`; let parentId;
const file1 = `file1-${Utils.random()}.txt`;
const folder1 = `folder1-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const infoDrawer = new InfoDrawer();
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable } = page;
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFile(file1, parentId);
await apis.user.nodes.createFolder(folder1, parentId);
await loginPage.loginWith(username);
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
done();
});
beforeEach(async (done) => {
await page.clickPersonalFilesAndWait();
await dataTable.doubleClickOnRowByName(parent);
done();
});
afterEach(async (done) => {
if (await infoDrawer.isOpen()) {
await page.toolbar.clickViewDetails();
}
done();
});
it('Info drawer for a file - default tabs - [C299162]', async () => {
await dataTable.selectItem(file1);
await page.toolbar.clickViewDetails();
await infoDrawer.waitForInfoDrawerToOpen();
expect(await infoDrawer.getHeaderTitle()).toEqual('Details');
expect(await infoDrawer.isPropertiesTabDisplayed()).toBe(true, 'Properties tab is not displayed');
expect(await infoDrawer.isCommentsTabDisplayed()).toBe(true, 'Comments tab is not displayed');
expect(await infoDrawer.getTabsCount()).toBe(2, 'Incorrect number of tabs');
});
});

View File

@ -0,0 +1,49 @@
/*!
* @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 { RepoApi } from '../repo-api';
import { CommentsApi as AdfCommentsApi } from '@alfresco/js-api';
export class CommentsApi extends RepoApi {
commentsApi = new AdfCommentsApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
}
async getNodeComments(nodeId: string) {
await this.apiAuth();
return await this.commentsApi.listComments(nodeId);
}
async addComment(nodeId: string, comment: string) {
await this.apiAuth();
return await this.commentsApi.createComment(nodeId, { "content": comment });
}
async addComments(nodeId: string, comment: any) {
await this.apiAuth();
return await this.commentsApi.createComment(nodeId, comment);
}
}

View File

@ -27,6 +27,7 @@ import { RepoClientAuth } from './repo-client-models';
import { PeopleApi } from './apis/people/people-api'; import { PeopleApi } from './apis/people/people-api';
import { NodesApi } from './apis/nodes/nodes-api'; import { NodesApi } from './apis/nodes/nodes-api';
import { CommentsApi } from './apis/comments/comments-api';
import { SitesApi } from './apis/sites/sites-api'; import { SitesApi } from './apis/sites/sites-api';
import { FavoritesApi } from './apis/favorites/favorites-api'; import { FavoritesApi } from './apis/favorites/favorites-api';
import { QueriesApi } from './apis/queries/queries-api'; import { QueriesApi } from './apis/queries/queries-api';
@ -55,6 +56,10 @@ export class RepoClient {
return new NodesApi(this.auth.username, this.auth.password); return new NodesApi(this.auth.username, this.auth.password);
} }
get comments() {
return new CommentsApi(this.auth.username, this.auth.password);
}
get sites() { get sites() {
return new SitesApi(this.auth.username, this.auth.password); return new SitesApi(this.auth.username, this.auth.password);
} }

View File

@ -248,7 +248,7 @@
"query": "cm:modified:[NOW/DAY-1MONTH TO NOW/DAY+1DAY]" "query": "cm:modified:[NOW/DAY-1MONTH TO NOW/DAY+1DAY]"
}, },
{ {
"label": "In last 6 months", "label": "In the last 6 months",
"query": "cm:modified:[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]" "query": "cm:modified:[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]"
}, },
{ {