Skip to content

Commit

Permalink
CR comments fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
katarzynakita committed Jun 10, 2024
1 parent e535afa commit 4fceade
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
30 changes: 12 additions & 18 deletions e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,46 +142,40 @@ test.describe('Mark items as favorites', () => {
});

test('favorite a file', async ({ personalFiles }) => {
await personalFiles.dataTable.selectItem(fileNotFav1);
await personalFiles.acaHeader.clickMoreActions();
await personalFiles.matMenu.clickMenuItem('Favorite');
await personalFiles.selectItemsAndToggleFavorite([fileNotFav1], 'Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav1Id, { expect: true })).toBe(true);
});

test('favorite a folder', async ({ personalFiles }) => {
await personalFiles.dataTable.selectItem(folder);
await personalFiles.acaHeader.clickMoreActions();
await personalFiles.matMenu.clickMenuItem('Favorite');
await personalFiles.selectItemsAndToggleFavorite([folder], 'Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, folderId, { expect: true })).toBe(true);
});

test('unfavorite an item', async ({ personalFiles }) => {
await personalFiles.dataTable.selectItem(fileFav1);
await personalFiles.acaHeader.clickMoreActions();
await personalFiles.matMenu.clickMenuItem('Remove Favorite');
await personalFiles.selectItemsAndToggleFavorite([fileFav1], 'Remove Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, fileFav1Id, { expect: false })).toBe(false);
});

test('favorite multiple items - all unfavorite', async ({ personalFiles }) => {
await personalFiles.dataTable.selectMultiItem(fileNotFav2, fileNotFav3);
await personalFiles.acaHeader.clickMoreActions();
await personalFiles.matMenu.clickMenuItem('Favorite');
await personalFiles.selectItemsAndToggleFavorite([fileNotFav2, fileNotFav3], 'Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav2Id, { expect: true })).toBe(true);
expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav3Id, { expect: true })).toBe(true);
});

test('favorite multiple items - some favorite and some unfavorite', async ({ personalFiles }) => {
await personalFiles.dataTable.selectMultiItem(fileNotFav4, fileFav2);
await personalFiles.acaHeader.clickMoreActions();
await personalFiles.matMenu.clickMenuItem('Favorite');
await personalFiles.selectItemsAndToggleFavorite([fileNotFav4, fileFav2], 'Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav4Id, { expect: true })).toBe(true);
expect(await favoritesApi.isFavoriteWithRetry(username, fileFav2Id, { expect: true })).toBe(true);
});

test('unfavorite multiple items', async ({ personalFiles }) => {
await personalFiles.dataTable.selectMultiItem(fileFav3, fileFav4);
await personalFiles.acaHeader.clickMoreActions();
await personalFiles.matMenu.clickMenuItem('Remove Favorite');
await personalFiles.selectItemsAndToggleFavorite([fileFav3, fileFav4], 'Remove Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, fileFav3Id, { expect: false })).toBe(false);
expect(await favoritesApi.isFavoriteWithRetry(username, fileFav4Id, { expect: false })).toBe(false);
});
Expand Down
10 changes: 1 addition & 9 deletions projects/aca-playwright-shared/src/api/favorites-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,11 @@ export class FavoritesPageApi {
} catch {}
}

async removeFavoriteById(username: string, nodeId: string): Promise<void> {
try {
await this.apiService.favorites.deleteFavorite(username, nodeId);
} catch (error) {
console.error('FavoritesApi: removeFavoriteById failed ', error);
}
}

async removeFavoritesByIds(username: string, ids: string[]): Promise<void> {
try {
if (ids && ids.length > 0) {
for (const id of ids) {
await this.removeFavoriteById(username, id);
await this.apiService.favorites.deleteFavorite(username, id);
}
}
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,12 @@ export class PersonalFilesPage extends BasePage {
await this.contentNodeSelector.selectDestination(destinationName);
await this.contentNodeSelector.actionButton.click();
}

async selectItemsAndToggleFavorite(item: string[], action: 'Favorite' | 'Remove Favorite') {
for (const itemToSelect of item) {
await this.dataTable.selectItem(itemToSelect);
}
await this.acaHeader.clickMoreActions();
await this.matMenu.clickMenuItem(action);
}
}

0 comments on commit 4fceade

Please sign in to comment.