-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathopen-collection.spec.ts
More file actions
66 lines (55 loc) · 2.83 KB
/
Copy pathopen-collection.spec.ts
File metadata and controls
66 lines (55 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import path from 'path';
import { test, expect, Page } from '../../../playwright';
import { buildCommonLocators } from '../../utils/page/locators';
import { createCollection } from '../../utils/page';
const openCollectionActionsMenu = async (page: Page, collectionName: string) => {
await test.step(`Open actions menu for collection "${collectionName}"`, async () => {
const locators = buildCommonLocators(page);
await locators.sidebar.collectionRow(collectionName).hover();
await locators.actions.collectionActions(collectionName).click();
});
};
const clickRemoveInCollectionMenu = async (page: Page) => {
const locators = buildCommonLocators(page);
await locators.dropdown.item('Remove').click();
await locators.modal.removeCollection.modal().waitFor({ state: 'visible', timeout: 5000 });
};
const confirmRemoveCollection = async (page: Page) => {
const locators = buildCommonLocators(page);
const removeModal = locators.modal.removeCollection;
const hasDiscardButton = await removeModal.discardAllAndRemoveButton().isVisible().catch(() => false);
if (hasDiscardButton) {
await removeModal.discardAllAndRemoveButton().click();
} else {
await removeModal.removeButton().click();
}
await removeModal.modal().waitFor({ state: 'hidden', timeout: 5000 });
};
test.describe('Open collection sanity testcases', () => {
test('TC-2614: Verify user able to Remove the Opened collection from the sidebar', { tag: '@sanity' }, async ({ page, createTmpDir }) => {
const collectionName = 'remove-test-collection';
const collectionLocation = await createTmpDir(collectionName);
const collectionPath = path.join(collectionLocation, collectionName);
const locators = buildCommonLocators(page);
await test.step('create collection', async () => {
await createCollection(page, collectionName, collectionLocation);
});
await test.step('open collection actions menu and verify Remove option is shown', async () => {
await openCollectionActionsMenu(page, collectionName);
await expect(locators.dropdown.item('Remove')).toBeVisible();
});
await test.step('click Remove and verify confirmation modal shows path and CTAs', async () => {
await clickRemoveInCollectionMenu(page);
const removeModal = locators.modal.removeCollection;
await expect(removeModal.modal()).toBeVisible();
await expect(removeModal.removeButton()).toBeVisible();
await expect(removeModal.cancelButton()).toBeVisible();
await expect(removeModal.path()).toContainText(collectionPath);
});
await test.step('confirm removal and verify success toast', async () => {
await confirmRemoveCollection(page);
await expect(locators.toast.collectionRemovedFromWorkspace()).toBeVisible();
await expect(locators.sidebar.collection(collectionName)).not.toBeVisible();
});
});
});