Skip to content

Commit

Permalink
e2e test review fix flaky test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
akashrathod28 committed Dec 8, 2023
1 parent 0431ee4 commit 7ecc25a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 62 deletions.
8 changes: 4 additions & 4 deletions e2e/playwright/list-views/src/tests/file-libraries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ test.describe('File Libraries', () => {
[userSiteModerated]: Site.VisibilityEnum.MODERATED,
[userSitePublic]: Site.VisibilityEnum.PUBLIC
};
for (const site of Object.keys(expectedSitesVisibility)) {
for (const [site, visibility] of Object.keys(expectedSitesVisibility)) {
const sitesVisibility = await myLibrariesPage.dataTable.getRowAllInnerTexts(site);
expect(sitesVisibility.toLowerCase()).toContain(expectedSitesVisibility[site].toLowerCase());
expect(sitesVisibility.toLowerCase()).toContain(visibility.toLowerCase());
}
});

Expand All @@ -126,9 +126,9 @@ test.describe('File Libraries', () => {
[adminSite4]: Site.RoleEnum.SiteManager
};

for (const site of Object.keys(expectedSitesRoles)) {
for (const [site, role] of Object.keys(expectedSitesRoles)) {
const sitesRowNames = await myLibrariesPage.dataTable.getRowAllInnerTexts(site);
expect(sitesRowNames.toLowerCase()).toContain(expectedSitesRoles[site].split('Site')[1].toLowerCase());
expect(sitesRowNames.toLowerCase()).toContain(role.split('Site')[1].toLowerCase());

Check failure on line 131 in e2e/playwright/list-views/src/tests/file-libraries.spec.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (list-views, 8)

[List Views] › src/tests/file-libraries.spec.ts:121:9 › File Libraries › My Libraries › [C289903] User role is correctly displayed

1) [List Views] › src/tests/file-libraries.spec.ts:121:9 › File Libraries › My Libraries › [C289903] User role is correctly displayed TypeError: Cannot read properties of undefined (reading 'toLowerCase') 129 | for (const [site, role] of Object.keys(expectedSitesRoles)) { 130 | const sitesRowNames = await myLibrariesPage.dataTable.getRowAllInnerTexts(site); > 131 | expect(sitesRowNames.toLowerCase()).toContain(role.split('Site')[1].toLowerCase()); | ^ 132 | } 133 | }); 134 | at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/list-views/src/tests/file-libraries.spec.ts:131:76

Check failure on line 131 in e2e/playwright/list-views/src/tests/file-libraries.spec.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (list-views, 8)

[List Views] › src/tests/file-libraries.spec.ts:121:9 › File Libraries › My Libraries › [C289903] User role is correctly displayed

1) [List Views] › src/tests/file-libraries.spec.ts:121:9 › File Libraries › My Libraries › [C289903] User role is correctly displayed Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TypeError: Cannot read properties of undefined (reading 'toLowerCase') 129 | for (const [site, role] of Object.keys(expectedSitesRoles)) { 130 | const sitesRowNames = await myLibrariesPage.dataTable.getRowAllInnerTexts(site); > 131 | expect(sitesRowNames.toLowerCase()).toContain(role.split('Site')[1].toLowerCase()); | ^ 132 | } 133 | }); 134 | at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/list-views/src/tests/file-libraries.spec.ts:131:76

Check failure on line 131 in e2e/playwright/list-views/src/tests/file-libraries.spec.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (list-views, 8)

[List Views] › src/tests/file-libraries.spec.ts:121:9 › File Libraries › My Libraries › [C289903] User role is correctly displayed

1) [List Views] › src/tests/file-libraries.spec.ts:121:9 › File Libraries › My Libraries › [C289903] User role is correctly displayed Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TypeError: Cannot read properties of undefined (reading 'toLowerCase') 129 | for (const [site, role] of Object.keys(expectedSitesRoles)) { 130 | const sitesRowNames = await myLibrariesPage.dataTable.getRowAllInnerTexts(site); > 131 | expect(sitesRowNames.toLowerCase()).toContain(role.split('Site')[1].toLowerCase()); | ^ 132 | } 133 | }); 134 | at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/list-views/src/tests/file-libraries.spec.ts:131:76
}
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/playwright/list-views/src/tests/personal-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import { expect } from '@playwright/test';
import { APP_ROUTES, ApiClientFactory, LoginPage, NodesApi, SIDEBAR_LABELS, Utils, test } from '@alfresco/playwright-shared';

test.describe('Personal Files', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
const username = `user-${Utils.random()}`;
const userFolder = `user-folder-${Utils.random()}`;

test.beforeAll(async () => {
try {
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
nodesApi = await NodesApi.initialize(username, username);
Expand Down
5 changes: 2 additions & 3 deletions e2e/playwright/list-views/src/tests/recent-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { ApiClientFactory, LoginPage, NodesApi, SearchPageApi, SitesApi, Trashca
import { Site } from '@alfresco/js-api';

test.describe('Recent Files', () => {
const apiClientFactory = new ApiClientFactory();
let nodeActionsUser: NodesApi;
let siteActionsUser: SitesApi;
const username = `user-${Utils.random()}`;
Expand All @@ -41,10 +40,10 @@ test.describe('Recent Files', () => {

const siteName = `site-${Utils.random()}`;
const folderSite = `folder2-${Utils.random()}`;
let folderSiteId: string;
const fileSite = `file-${Utils.random()}.txt`;

test.beforeAll(async () => {
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
nodeActionsUser = await NodesApi.initialize(username, username);
Expand All @@ -59,7 +58,7 @@ test.describe('Recent Files', () => {

await siteActionsUser.createSite(siteName, Site.VisibilityEnum.PUBLIC);
const docLibId = await siteActionsUser.getDocLibId(siteName);
folderSiteId = (await nodeActionsUser.createFolder(folderSite, docLibId)).entry.id;
const folderSiteId = (await nodeActionsUser.createFolder(folderSite, docLibId)).entry.id;
await nodeActionsUser.createFile(fileSite, folderSiteId);

const searchApi = await SearchPageApi.initialize(username, username);
Expand Down
22 changes: 8 additions & 14 deletions e2e/playwright/list-views/src/tests/shared-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,21 @@ import { ApiClientFactory, LoginPage, NodesApi, Utils, test, SitesApi, timeouts,
import { Site } from '@alfresco/js-api';

test.describe('Shared Files', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
let siteActionsAdmin: SitesApi;

const username = `user-${Utils.random()}`;
const siteName = `site-${Utils.random()}`;
const fileAdmin = `fileSite-${Utils.random()}.txt`;
const folderUser = `folder-${Utils.random()}`;
let folderId: string;
const file1User = `file1-${Utils.random()}.txt`;
let file1Id: string;
const file2User = `file2-${Utils.random()}.txt`;
let file2Id: string;
const file3User = `file3-${Utils.random()}.txt`;
let file3Id: string;
const file4User = `file4-${Utils.random()}.txt`;
let file4Id: string;

test.beforeAll(async () => {
test.setTimeout(timeouts.extendedTest);
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
siteActionsAdmin = await SitesApi.initialize('admin');
Expand All @@ -63,11 +58,11 @@ test.describe('Shared Files', () => {
await shareActionsAdmin.shareFileById(nodeId);
await shareActionsAdmin.waitForFilesToBeShared([nodeId]);

folderId = (await nodesApi.createFolder(folderUser)).entry.id;
file1Id = (await nodesApi.createFile(file1User, folderId)).entry.id;
file2Id = (await nodesApi.createFile(file2User)).entry.id;
file3Id = (await nodesApi.createFile(file3User)).entry.id;
file4Id = (await nodesApi.createFile(file4User)).entry.id;
const folderId = (await nodesApi.createFolder(folderUser)).entry.id;
const file1Id = (await nodesApi.createFile(file1User, folderId)).entry.id;
const file2Id = (await nodesApi.createFile(file2User)).entry.id;
const file3Id = (await nodesApi.createFile(file3User)).entry.id;
const file4Id = (await nodesApi.createFile(file4User)).entry.id;

await shareActions.shareFilesByIds([file1Id, file2Id, file3Id, file4Id]);
await shareActions.waitForFilesToBeShared([file1Id, file2Id, file3Id, file4Id]);
Expand All @@ -92,14 +87,13 @@ test.describe('Shared Files', () => {

test.afterAll(async () => {
await siteActionsAdmin.deleteSites([siteName]);
await nodesApi.deleteNodes([folderId, file4Id]);
await nodesApi.deleteCurrentUserNodes();
});

test('[C213113] has the correct columns', async ({ sharedPage }) => {
const expectedColumns = ['Name', 'Location', 'Size', 'Modified', 'Modified by', 'Shared by', 'Tags'];
const actualColumns = await sharedPage.dataTable.getColumnHeaders();

await expect(actualColumns).toEqual(expectedColumns);
expect(actualColumns).toEqual(expectedColumns);
});

test('[C213115] default sorting column', async ({ sharedPage }) => {
Expand Down
26 changes: 7 additions & 19 deletions e2e/playwright/list-views/src/tests/trash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,50 +27,38 @@ import { ApiClientFactory, LoginPage, NodesApi, SitesApi, Utils, test } from '@a
import { Site } from '@alfresco/js-api';

test.describe('Trash', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
let siteActionsAdmin: SitesApi;

const username = `user-${Utils.random()}`;
const siteName = `site-${Utils.random()}`;
const fileSite = `file1-${Utils.random()}.txt`;

const folderUser = `folder-${Utils.random()}`;
let folderUserId: string;
const fileUser = `file-${Utils.random()}.txt`;
let fileUserId: string;

const folderDeleted = `folder-${Utils.random()}`;
let folderDeletedId: string;
const fileDeleted = `file-${Utils.random()}.txt`;
let fileDeletedId: string;

const folderNotDeleted = `folder-${Utils.random()}`;
let folderNotDeletedId: string;
const fileInFolder = `file-${Utils.random()}.txt`;
let fileInFolderId: string;

test.beforeAll(async () => {
try {
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
siteActionsAdmin = await SitesApi.initialize('admin');
nodesApi = await NodesApi.initialize(username, username);
const nodesApiAdmin = await NodesApi.initialize('admin');
const folderDeleted = `folder-${Utils.random()}`;

await siteActionsAdmin.createSite(siteName, Site.VisibilityEnum.PUBLIC);
const docLibId = await siteActionsAdmin.getDocLibId(siteName);
await siteActionsAdmin.addSiteMember(siteName, username, Site.RoleEnum.SiteManager);
const fileSiteId = (await nodesApiAdmin.createFile(fileSite, docLibId)).entry.id;

folderUserId = (await nodesApi.createFolder(folderUser)).entry.id;
folderDeletedId = (await nodesApi.createFolder(folderDeleted)).entry.id;
folderNotDeletedId = (await nodesApi.createFolder(folderNotDeleted)).entry.id;
fileUserId = (await nodesApi.createFile(fileUser)).entry.id;
fileDeletedId = (await nodesApi.createFile(fileDeleted, folderDeletedId)).entry.id;
fileInFolderId = (await nodesApi.createFile(fileInFolder, folderNotDeletedId)).entry.id;
const folderDeletedId = (await nodesApi.createFolder(folderDeleted)).entry.id;
const folderNotDeletedId = (await nodesApi.createFolder(folderNotDeleted)).entry.id;
const fileDeletedId = (await nodesApi.createFile(fileDeleted, folderDeletedId)).entry.id;
const fileInFolderId = (await nodesApi.createFile(fileInFolder, folderNotDeletedId)).entry.id;

await nodesApi.deleteNodes([fileSiteId, fileUserId, folderUserId, fileInFolderId, fileDeletedId, folderDeletedId], false);
await nodesApi.deleteNodes([fileSiteId, fileInFolderId, fileDeletedId, folderDeletedId], false);
} catch (error) {
console.error(`----- beforeAll failed : ${error}`);
}
Expand Down
15 changes: 4 additions & 11 deletions e2e/playwright/pagination/src/tests/favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,13 @@ export function favoritesTests(username: string) {
expect(await favoritePage.pagination.isNextEnabled()).toBe(true);
});

test('[C280114] Items per page values', async ({ favoritePage }) => {
await favoritePage.pagination.openMaxItemsMenu();
expect(await (await favoritePage.pagination.getNthItem(1)).innerText()).toBe('25');
expect(await (await favoritePage.pagination.getNthItem(2)).innerText()).toBe('50');
expect(await (await favoritePage.pagination.getNthItem(3)).innerText()).toBe('100');
await favoritePage.pagination.closeMenu();
});

test('[C280115] current page menu items', async ({ favoritePage }) => {
await favoritePage.pagination.openMaxItemsMenu();
expect(await favoritePage.pagination.getItemsCount()).toBe(3);
await favoritePage.pagination.clickMenuItem('25');
await favoritePage.dataTable.spinnerWaitForReload();
expect(await favoritePage.pagination.getMaxItems()).toContain('25');
expect(await favoritePage.pagination.getTotalPages()).toContain('of 3');
expect(await favoritePage.pagination.getItemsCount()).toBe(3);
await favoritePage.pagination.closeMenu();

await favoritePage.pagination.openMaxItemsMenu();
await favoritePage.pagination.clickMenuItem('50');
Expand Down Expand Up @@ -89,9 +81,10 @@ export function favoritesTests(username: string) {
await favoritePage.pagination.clickMenuItem('25');
expect(await favoritePage.pagination.getMaxItems()).toContain('25');
await favoritePage.pagination.clickOnNextPage();
await favoritePage.dataTable.spinnerWaitForReload();
expect(await favoritePage.pagination.getRange()).toContain('Showing 26-50 of 51');

await favoritePage.pagination.clickOnPreviousPage();
await favoritePage.dataTable.spinnerWaitForReload();
expect(await favoritePage.pagination.getRange()).toContain('Showing 1-25 of 51');
});

Expand Down
14 changes: 4 additions & 10 deletions e2e/playwright/pagination/src/tests/personal-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,13 @@ export function personalFilesTests(userName: string, parentName: string) {
expect(await personalFiles.pagination.isNextEnabled()).toBe(true);
});

test('[C280078] Items per page values', async ({ personalFiles }) => {
await personalFiles.pagination.openMaxItemsMenu();
expect(await (await personalFiles.pagination.getNthItem(1)).innerText()).toBe('25');
expect(await (await personalFiles.pagination.getNthItem(2)).innerText()).toBe('50');
expect(await (await personalFiles.pagination.getNthItem(3)).innerText()).toBe('100');
await personalFiles.closeMenu();
});

test('[C280079] current page menu items', async ({ personalFiles }) => {
await personalFiles.pagination.openMaxItemsMenu();
expect(await personalFiles.pagination.getItemsCount()).toBe(3);
await personalFiles.pagination.clickMenuItem('25');
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.pagination.getMaxItems()).toContain('25');
expect(await personalFiles.pagination.getTotalPages()).toContain('of 3');
expect(await personalFiles.pagination.getItemsCount()).toBe(3);

await personalFiles.pagination.openMaxItemsMenu();
await personalFiles.pagination.clickMenuItem('50');
Expand Down Expand Up @@ -86,9 +79,10 @@ export function personalFilesTests(userName: string, parentName: string) {
await personalFiles.pagination.clickMenuItem('25');
expect(await personalFiles.pagination.getMaxItems()).toContain('25');
await personalFiles.pagination.clickOnNextPage();
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.pagination.getRange()).toContain('Showing 26-50 of 51');

await personalFiles.pagination.clickOnPreviousPage();
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.pagination.getRange()).toContain('Showing 1-25 of 51');
});

Expand Down

0 comments on commit 7ecc25a

Please sign in to comment.