Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-5786] info drawer comments test cleanup #3378

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 7 additions & 229 deletions e2e/protractor/suites/info-drawer/comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,81 +123,6 @@ describe('Comments', () => {
expect(await commentsTab.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await commentsTab.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');
});

it('[C280583] Comments are displayed ordered by created date in descending order', async () => {
await dataTable.selectItem(fileWith2Comments);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await commentsTab.getNthCommentId(2)).toContain(comment1File2Entry.id);
});

it('[C280585] Total number of comments is displayed', async () => {
await dataTable.selectItem(fileWith2Comments);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (2)');
});

it('[C280589] Add button is enabled when typing in the comment field', async () => {
await dataTable.selectItem(file1);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');

await commentsTab.typeComment('my comment');
expect(await commentsTab.isAddCommentButtonEnabled()).toBe(true, 'Add comment button not enabled');
});

it('[C280590] Add a comment on a file', async () => {
const myComment = 'my comment';

await dataTable.selectItem(file2Personal);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await commentsTab.typeComment(myComment);
await commentsTab.clickAddButton();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await commentsTab.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await commentsTab.getCommentText()).toBe(myComment, 'Incorrect comment text');
});

it('[C299208] Add a comment on a folder', async () => {
const myComment = 'my comment';

await dataTable.selectItem(folder1);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await commentsTab.typeComment(myComment);
await commentsTab.clickAddButton();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await commentsTab.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await commentsTab.getCommentText()).toBe(myComment, 'Incorrect comment text');
});

it('[C280591] Escape key clears the text when focus is on the textarea', async () => {
await dataTable.selectItem(file2Personal);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await commentsTab.typeComment('myComment');

expect(await commentsTab.getCommentTextFromTextArea()).toBe('myComment');

await Utils.pressEscape();

expect(await commentsTab.getCommentTextFromTextArea()).toBe('');
});
});

describe('from Favorites', () => {
Expand All @@ -209,40 +134,6 @@ describe('Comments', () => {
await page.clickFavoritesAndWait();
});

it('[C299197] Comments are displayed ordered by created date in descending order', async () => {
await dataTable.selectItem(fileWith2Comments);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await commentsTab.getNthCommentId(2)).toContain(comment1File2Entry.id);
});

it('[C299198] Total number of comments is displayed', async () => {
await dataTable.selectItem(fileWith2Comments);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (2)');
});

it('[C299199] Add a comment on a file', async () => {
const myComment = 'my comment';

await dataTable.selectItem(file2Favorites);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await commentsTab.typeComment(myComment);
await commentsTab.clickAddButton();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await commentsTab.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await commentsTab.getCommentText()).toBe(myComment, 'Incorrect comment text');
});

it('[C299209] Add a comment on a folder', async () => {
const myComment = 'my comment';

Expand Down Expand Up @@ -270,32 +161,8 @@ describe('Comments', () => {
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await commentsTab.getNthCommentId(2)).toContain(comment1File2Entry.id);
});

it('[C299190] Total number of comments is displayed', async () => {
await dataTable.selectItem(fileWith2Comments);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (2)');
});

it('[C299191] Add a comment on a file', async () => {
const myComment = 'my comment';

await dataTable.selectItem(file2Shared);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();
await commentsTab.typeComment(myComment);
await commentsTab.clickAddButton();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await commentsTab.isCommentDisplayed()).toBe(true, `Comment not displayed`);
expect(await commentsTab.getCommentText()).toBe(myComment, 'Incorrect comment text');
expect(await commentsTab.getNthCommentText(1)).toContain(comment2File2Entry.content);
expect(await commentsTab.getNthCommentText(2)).toContain(comment1File2Entry.content);
});
});

Expand All @@ -308,25 +175,6 @@ describe('Comments', () => {
await page.clickRecentFilesAndWait();
});

it('[C299193] Comments are displayed ordered by created date in descending order', async () => {
await dataTable.selectItem(fileWith2Comments);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getNthCommentId(1)).toContain(comment2File2Entry.id);
expect(await commentsTab.getNthCommentId(2)).toContain(comment1File2Entry.id);
});

it('[C299194] Total number of comments is displayed', async () => {
await dataTable.selectItem(fileWith2Comments);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (2)');
});

it('[C299195] Add a comment on a file', async () => {
const myComment = 'my comment';

Expand All @@ -352,29 +200,6 @@ describe('Comments', () => {
await apis.user.search.waitForApi(username, { expect: 7 });
});

it('[C280582] File from Personal files', async () => {
await page.clickPersonalFilesAndWait();
await dataTable.doubleClickOnRowByName(parent);

await dataTable.selectItem(fileWith1Comment);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await commentsTab.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await commentsTab.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');

expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(
moment(commentFile1Entry.createdAt).fromNow(),
'Incorrect comment created time'
);
expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
});

it('[C299196] File from Favorites', async () => {
await page.clickFavoritesAndWait();

Expand All @@ -387,58 +212,11 @@ describe('Comments', () => {
expect(await commentsTab.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await commentsTab.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');

expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(
moment(commentFile1Entry.createdAt).fromNow(),
'Incorrect comment created time'
);
expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
});

it('[C299188] File from Shared Files', async () => {
await page.clickSharedFilesAndWait();

await dataTable.selectItem(fileWith1Comment);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await commentsTab.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await commentsTab.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');

expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(
moment(commentFile1Entry.createdAt).fromNow(),
'Incorrect comment created time'
);
expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
});

it('[C299192] File from Recent Files', async () => {
await page.clickRecentFilesAndWait();

await dataTable.selectItem(fileWith1Comment);
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickCommentsTab();

expect(await commentsTab.getCommentsTabHeaderText()).toBe('Comments (1)');
expect(await commentsTab.isCommentTextAreaDisplayed()).toBe(true, 'Comment field not present');
expect(await commentsTab.isAddCommentButtonEnabled()).toBe(false, 'Add comment button not disabled');

expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`);
expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(
moment(commentFile1Entry.createdAt).fromNow(),
'Incorrect comment created time'
);
expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed');
expect(await commentsTab.isCommentDisplayed()).toBe(true, `Comment is not displayed`);
expect(await commentsTab.getCommentText()).toBe(commentFile1Entry.content, 'Incorrect comment text');
expect(await commentsTab.getCommentUserName()).toBe(`${username} ${username}`, 'Incorrect comment user');
expect(await commentsTab.getCommentTime()).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time');
expect(await commentsTab.isCommentUserAvatarDisplayed()).toBe(true, 'User avatar not displayed');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export class CommentsTab extends Component {
return list.get(index - 1).getAttribute('id');
}

async getNthCommentText(index: number): Promise<string> {
const list = this.allByCss('mat-list-item .adf-comment-message');
return list.get(index - 1).getText();
}

async typeComment(text: string): Promise<void> {
await typeText(this.commentTextarea, text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export class InfoDrawer extends Component {
await this.commentsTab.waitForCommentsContainer();
await Promise.all([
BrowserVisibility.waitUntilElementIsVisible(this.commentsTab.component),
BrowserVisibility.waitUntilElementIsNotVisible(this.propertiesTab.component)
]);
} catch (error) {
Logger.error('--- info-drawer clickCommentsTab catch error: ', error);
Expand Down