Skip to content

Commit

Permalink
ESLint: cleanup await expect from protractor tests (#9630)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika authored Apr 30, 2024
1 parent 4109f27 commit f401b8c
Show file tree
Hide file tree
Showing 114 changed files with 2,104 additions and 1,916 deletions.
22 changes: 11 additions & 11 deletions e2e-playwright/process-services-cloud/specs/people-cloud.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ test.describe('People component stories tests', () => {
Kielbasa Sausage cancel
`;

await processServicesCloud.navigateTo({moduleNames:['people-cloud'], componentName: 'people-cloud', story: 'valid-preselected-users' });
await processServicesCloud.navigateTo({ moduleNames: ['people-cloud'], componentName: 'people-cloud', story: 'valid-preselected-users' });

await expect(peopleComponent.usersNaming).toContainText(expectedUsersName);
expect(peopleComponent.usersNaming).toContainText(expectedUsersName);
});

test('Mandatory Preselected Users', async ({ processServicesCloud, peopleComponent }) => {
Expand All @@ -38,20 +38,20 @@ test.describe('People component stories tests', () => {
Shepherds Pie cancel
`;

await processServicesCloud.navigateTo({moduleNames:['people-cloud'], componentName: 'people-cloud', story: 'mandatory-preselected-users' });
await processServicesCloud.navigateTo({ moduleNames: ['people-cloud'], componentName: 'people-cloud', story: 'mandatory-preselected-users' });
await peopleComponent.getUserLocator('Kielbasa Sausage').hover();

await expect.soft(peopleComponent.usersNaming).toContainText(expectedUsersName);
await expect(peopleComponent.tooltip.content).toContainText('Mandatory');
expect.soft(peopleComponent.usersNaming).toContainText(expectedUsersName);
expect(peopleComponent.tooltip.content).toContainText('Mandatory');
});

test('Invalid Preselected Users', async ({ processServicesCloud, peopleComponent }) => {
const expectedWarningMessage = 'No user found with the username Invalid User';
const expectedWarningIcon = 'error_outline';

await processServicesCloud.navigateTo({moduleNames:['people-cloud'], componentName: 'people-cloud', story: 'invalid-preselected-users' });
await processServicesCloud.navigateTo({ moduleNames: ['people-cloud'], componentName: 'people-cloud', story: 'invalid-preselected-users' });

await expect(peopleComponent.error.content).toContainText(expectedWarningIcon + expectedWarningMessage);
expect(peopleComponent.error.content).toContainText(expectedWarningIcon + expectedWarningMessage);
});

test('Excluded Users', async ({ processServicesCloud, peopleComponent }) => {
Expand All @@ -60,18 +60,18 @@ test.describe('People component stories tests', () => {
yorkshire
`;

await processServicesCloud.navigateTo({moduleNames:['people-cloud'], componentName: 'people-cloud', story: 'excluded-users' });
await processServicesCloud.navigateTo({ moduleNames: ['people-cloud'], componentName: 'people-cloud', story: 'excluded-users' });
await peopleComponent.usersInput.type('user');

await expect(peopleComponent.listbox.allOptions).not.toContainText(expectedExcludedUsers);
expect(peopleComponent.listbox.allOptions).not.toContainText(expectedExcludedUsers);
});

test('No Users', async ({ processServicesCloud, peopleComponent }) => {
const expectedInformation = 'No user found with the username user';

await processServicesCloud.navigateTo({moduleNames:['people-cloud'], componentName: 'people-cloud', story: 'no-users' });
await processServicesCloud.navigateTo({ moduleNames: ['people-cloud'], componentName: 'people-cloud', story: 'no-users' });
await peopleComponent.usersInput.type('user');

await expect(peopleComponent.listbox.oneOption).toContainText(expectedInformation);
expect(peopleComponent.listbox.oneOption).toContainText(expectedInformation);
});
});
34 changes: 13 additions & 21 deletions e2e/content-services/components/comment-component.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
* limitations under the License.
*/

import { createApiService,
LoginPage,
StringUtil,
UploadActions,
UserModel,
UsersActions,
ViewerPage
} from '@alfresco/adf-testing';
import { createApiService, LoginPage, StringUtil, UploadActions, UserModel, UsersActions, ViewerPage } from '@alfresco/adf-testing';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { CommentsPage } from '../../core/pages/comments.page';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
Expand Down Expand Up @@ -66,7 +59,6 @@ describe('Comment', () => {
});

describe('component', () => {

beforeEach(async () => {
await apiService.login(acsUser.username, acsUser.password);

Expand Down Expand Up @@ -100,9 +92,9 @@ describe('Comment', () => {
await commentsPage.checkCommentInputIsDisplayed();

await commentsPage.getTotalNumberOfComments('Comments (1)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.test);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
expect(await commentsPage.getMessage(0)).toEqual(comments.test);
expect(await commentsPage.getUserName(0)).toEqual(userFullName);
expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
});

it('[C276948] Should be able to add a comment on a file', async () => {
Expand All @@ -116,9 +108,9 @@ describe('Comment', () => {
await commentsPage.checkUserIconIsDisplayed();

await commentsPage.getTotalNumberOfComments('Comments (1)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.first);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
expect(await commentsPage.getMessage(0)).toEqual(comments.first);
expect(await commentsPage.getUserName(0)).toEqual(userFullName);
expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
});

it('[C280021] Should be able to add a multiline comment on a file', async () => {
Expand All @@ -132,17 +124,17 @@ describe('Comment', () => {
await commentsPage.checkUserIconIsDisplayed();

await commentsPage.getTotalNumberOfComments('Comments (1)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.multiline);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
expect(await commentsPage.getMessage(0)).toEqual(comments.multiline);
expect(await commentsPage.getUserName(0)).toEqual(userFullName);
expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);

await commentsPage.addComment(comments.second);
await commentsPage.checkUserIconIsDisplayed();

await commentsPage.getTotalNumberOfComments('Comments (2)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.second);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
expect(await commentsPage.getMessage(0)).toEqual(comments.second);
expect(await commentsPage.getUserName(0)).toEqual(userFullName);
expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ describe('Content Services Viewer', () => {
const initialHeight = await viewerPage.getCanvasHeight();

await viewerPage.clickZoomInButton();
await expect(+(await viewerPage.getCanvasWidth())).toBeGreaterThan(+initialWidth);
await expect(+(await viewerPage.getCanvasHeight())).toBeGreaterThan(+initialHeight);
expect(+(await viewerPage.getCanvasWidth())).toBeGreaterThan(+initialWidth);
expect(+(await viewerPage.getCanvasHeight())).toBeGreaterThan(+initialHeight);

await viewerPage.clickActualSize();
await expect(+(await viewerPage.getCanvasWidth())).toEqual(+initialWidth);
await expect(+(await viewerPage.getCanvasHeight())).toEqual(+initialHeight);
expect(+(await viewerPage.getCanvasWidth())).toEqual(+initialWidth);
expect(+(await viewerPage.getCanvasHeight())).toEqual(+initialHeight);

await viewerPage.clickZoomOutButton();
await expect(+(await viewerPage.getCanvasWidth())).toBeLessThan(+initialWidth);
await expect(+(await viewerPage.getCanvasHeight())).toBeLessThan(+initialHeight);
expect(+(await viewerPage.getCanvasWidth())).toBeLessThan(+initialWidth);
expect(+(await viewerPage.getCanvasHeight())).toBeLessThan(+initialHeight);

await viewerPage.clickCloseButton();
});
Expand Down Expand Up @@ -298,7 +298,7 @@ describe('Content Services Viewer', () => {

await viewerPage.checkZoomInButtonIsNotDisplayed();
await viewerPage.checkUnknownFormatIsDisplayed();
await expect(await viewerPage.getUnknownFormatMessage()).toBe("Couldn't load preview. Unknown format.");
expect(await viewerPage.getUnknownFormatMessage()).toBe(`Couldn't load preview. Unknown format.`);

await viewerPage.clickCloseButton();
});
Expand Down Expand Up @@ -397,6 +397,12 @@ describe('Content Services Viewer', () => {
});
});

/**
* Upload a new version of a file
*
* @param originalFileName The name of the original file
* @param newVersionLocation The location of the new version
*/
async function uploadNewVersion(originalFileName: string, newVersionLocation: string): Promise<void> {
await contentServicesPage.doubleClickRow(originalFileName);
await viewerPage.waitTillContentLoaded();
Expand All @@ -410,14 +416,25 @@ describe('Content Services Viewer', () => {
await browser.refresh();
}

/**
* Preview an unsupported file
*
* @param unsupportedFileName The name of the unsupported file
*/
async function previewUnsupportedFile(unsupportedFileName: string): Promise<void> {
await contentServicesPage.doubleClickRow(unsupportedFileName);
await viewerPage.waitTillContentLoaded();
await viewerPage.checkUnknownFormatIsDisplayed();
await expect(await viewerPage.getUnknownFormatMessage()).toBe("Couldn't load preview. Unknown format.");
expect(await viewerPage.getUnknownFormatMessage()).toBe(`Couldn't load preview. Unknown format.`);
await viewerPage.clickCloseButton();
}

/**
* Change the name of the file in the viewer
*
* @param fileName The name of the file to be changed
* @param newName The new name of the file
*/
async function changeFileNameInViewer(fileName: string, newName: string): Promise<void> {
await contentServicesPage.doubleClickRow(fileName);
await viewerPage.waitTillContentLoaded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ describe('Document List Component', () => {
await navigationBarPage.clickLogoutButton();
});

it("[C279926] Should only display the user's files and folders", async () => {
it('[C279926] Should only display the user files and folders', async () => {
await contentServicesPage.goToDocumentList();
await contentServicesPage.checkContentIsDisplayed(folderName);
await contentServicesPage.checkContentIsDisplayed(pdfFileModel.name);
await contentServicesPage.checkContentIsDisplayed(docxFileModel.name);
await expect(await contentServicesPage.getDocumentListRowNumber()).toBe(4);
expect(await contentServicesPage.getDocumentListRowNumber()).toBe(4);
});

it('[C279927] Should display default columns', async () => {
Expand Down Expand Up @@ -182,27 +182,27 @@ describe('Document List Component', () => {
});

it('[C260112] Should be able to sort by name (Ascending)', async () => {
await expect(await contentServicesPage.sortAndCheckListIsOrderedByName('asc')).toBe(true, 'List is not sorted.');
expect(await contentServicesPage.sortAndCheckListIsOrderedByName('asc')).toBe(true);
});

it('[C272770] Should be able to sort by name (Descending)', async () => {
await expect(await contentServicesPage.sortAndCheckListIsOrderedByName('desc')).toBe(true, 'List is not sorted.');
expect(await contentServicesPage.sortAndCheckListIsOrderedByName('desc')).toBe(true);
});

it('[C272771] Should be able to sort by author (Ascending)', async () => {
await expect(await contentServicesPage.sortAndCheckListIsOrderedByAuthor('asc')).toBe(true, 'List is not sorted.');
expect(await contentServicesPage.sortAndCheckListIsOrderedByAuthor('asc')).toBe(true);
});

it('[C272772] Should be able to sort by author (Descending)', async () => {
await expect(await contentServicesPage.sortAndCheckListIsOrderedByAuthor('desc')).toBe(true, 'List is not sorted.');
expect(await contentServicesPage.sortAndCheckListIsOrderedByAuthor('desc')).toBe(true);
});

it('[C272773] Should be able to sort by date (Ascending)', async () => {
await expect(await contentServicesPage.sortAndCheckListIsOrderedByCreated('asc')).toBe(true, 'List is not sorted.');
expect(await contentServicesPage.sortAndCheckListIsOrderedByCreated('asc')).toBe(true);
});

it('[C272774] Should be able to sort by date (Descending)', async () => {
await expect(await contentServicesPage.sortAndCheckListIsOrderedByCreated('desc')).toBe(true, 'List is not sorted.');
expect(await contentServicesPage.sortAndCheckListIsOrderedByCreated('desc')).toBe(true);
});
});

Expand Down
Loading

0 comments on commit f401b8c

Please sign in to comment.