-
Notifications
You must be signed in to change notification settings - Fork 2.6k
open-collection testcases #8381
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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 }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this timeout if not remove it
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really required. Added just for time when application might be slow. Removed. |
||
| }; | ||
|
|
||
| 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(); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,44 +44,37 @@ | |
| */ | ||
| const closeAllCollections = async (page) => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert back changes done in
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted. |
||
| await test.step('Close all collections', async () => { | ||
| const numberOfCollections = await page.locator('[data-testid="collections"] .collection-name').count(); | ||
| const locators = buildCommonLocators(page); | ||
| const collectionsContainer = locators.sidebar.collectionsContainer(); | ||
| const numberOfCollections = await collectionsContainer.locator('.collection-name').count(); | ||
|
|
||
| for (let i = 0; i < numberOfCollections; i++) { | ||
| const firstCollection = page.locator('[data-testid="collections"] .collection-name').first(); | ||
| const firstCollection = collectionsContainer.locator('.collection-name').first(); | ||
| await firstCollection.scrollIntoViewIfNeeded(); | ||
|
|
||
| const removeMenuItem = page.locator('.dropdown-item').getByText('Remove'); | ||
| const removeMenuItem = locators.dropdown.item('Remove'); | ||
| await expect(async () => { | ||
| await firstCollection.hover(); | ||
| await firstCollection.locator('.collection-actions .icon').click({ force: true }); | ||
| await expect(removeMenuItem).toBeVisible({ timeout: 2000 }); | ||
| }).toPass({ timeout: 15000 }); | ||
| await removeMenuItem.click(); | ||
|
|
||
| // Wait for modal to appear - could be either regular remove or drafts confirmation | ||
| const removeModal = page.locator('.bruno-modal').filter({ hasText: 'Remove Collection' }); | ||
| await removeModal.waitFor({ state: 'visible', timeout: 5000 }); | ||
| const removeModal = locators.modal.removeCollection; | ||
| await removeModal.modal().waitFor({ state: 'visible', timeout: 5000 }); | ||
|
|
||
| // Check if it's the drafts confirmation modal (has "Discard All and Remove" button) | ||
| const hasDiscardButton = await page.getByRole('button', { name: 'Discard All and Remove' }).isVisible().catch(() => false); | ||
| const hasDiscardButton = await removeModal.discardAllAndRemoveButton().isVisible().catch(() => false); | ||
|
|
||
| if (hasDiscardButton) { | ||
| // Drafts modal - the modal animates in and the footer can shift mid-frame, | ||
| // causing Playwright's "element is stable" actionability check to fail | ||
| // intermittently on slower machines. Use force to skip the stability check; | ||
| // visibility is already verified above via waitFor. | ||
| await page.getByRole('button', { name: 'Discard All and Remove' }).click({ force: true }); | ||
| await removeModal.discardAllAndRemoveButton().click({ force: true }); | ||
| } else { | ||
| // Regular modal - click the submit button | ||
| await page.locator('.bruno-modal-footer .submit').click(); | ||
| await removeModal.removeButton().click(); | ||
| } | ||
|
|
||
| // Wait for modal to close | ||
| await removeModal.waitFor({ state: 'hidden', timeout: 5000 }); | ||
| await removeModal.modal().waitFor({ state: 'hidden', timeout: 5000 }); | ||
| } | ||
|
|
||
| // Wait until no collections are left open (check sidebar only) | ||
| await expect(page.getByTestId('collections').locator('.collection-name')).toHaveCount(0); | ||
| await expect(collectionsContainer.locator('.collection-name')).toHaveCount(0); | ||
| }); | ||
| }; | ||
|
|
||
|
|
@@ -390,7 +383,7 @@ | |
| if (inFolder) { | ||
| await expect(locators.sidebar.folderRequest(parentName, requestName)).toBeVisible(); | ||
| } else { | ||
| await expect(locators.sidebar.request(requestName)).toBeVisible(); | ||
| await expect(locators.sidebar.scopedRequest(parentName, requestName)).toBeVisible(); | ||
|
Check failure on line 386 in tests/utils/page/actions.ts
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this line back to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted. |
||
| } | ||
| }); | ||
| }; | ||
|
|
@@ -683,7 +676,7 @@ | |
| * Add an environment variable to the currently open environment. Variables and | ||
| * secrets live on separate tabs, so a secret is routed to the Secrets tab and a | ||
| * plain variable to the Variables tab before the row is added. | ||
| * @param page - The page object | ||
| * @param page - The page object | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add the space again
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
| * @param variable - The variable to add (name, value, and optional secret flag) | ||
| * @returns void | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above actions are generic enough to be moved to
pages/<component>