Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions tests/collection/open/open-collection.spec.ts
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) => {

Copy link
Copy Markdown
Collaborator

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>

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' });
};

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();
});
});
});
2 changes: 1 addition & 1 deletion tests/collection/open/open-multiple-collections.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test.describe('Open Multiple Collections', () => {
});
});

test('Should open multiple collections using Open Collection feature', async ({
test('TC777: Verify opening of multiple collections from parent folder with successful launch', { tag: '@sanity' }, async ({
page,
electronApp,
createTmpDir
Expand Down
1 change: 0 additions & 1 deletion tests/utils/page/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
await page.getByRole('button', { name: 'Discard All and Remove' }).click({ force: true });
} else {
// Regular modal - click the submit button
await page.locator('.bruno-modal-footer .submit').click();

Check failure on line 76 in tests/utils/page/actions.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E Tests (macOS)

[default] › tests/codeeditor-state/fold-persistence.spec.ts:111:7 › CodeEditor — fold state persists across tab switches › Body editor: folded {} block survives Body → Headers → Body

3) [default] › tests/codeeditor-state/fold-persistence.spec.ts:111:7 › CodeEditor — fold state persists across tab switches › Body editor: folded {} block survives Body → Headers → Body Error: locator.click: Target page, context or browser has been closed Call log: - waiting for locator('.bruno-modal-footer .submit') - locator resolved to <div class="StyledWrapper-fWWGoA Fecll submit">…</div> - attempting click action 2 × waiting for element to be visible, enabled and stable - element is not stable - retrying click action - waiting 20ms 2 × waiting for element to be visible, enabled and stable - element is not stable - retrying click action - waiting 100ms - waiting for element to be visible, enabled and stable - element is not stable - retrying click action - waiting 500ms - waiting for element to be visible, enabled and stable at tests/utils/page/actions.ts:76 74 | } else { 75 | // Regular modal - click the submit button > 76 | await page.locator('.bruno-modal-footer .submit').click(); | ^ 77 | } 78 | 79 | // Wait for modal to close at /Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:76:59 at closeAllCollections (/Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:46:3) at /Users/runner/work/bruno/bruno/tests/codeeditor-state/fold-persistence.spec.ts:108:5
}

// Wait for modal to close
Expand All @@ -84,7 +84,6 @@
await expect(page.getByTestId('collections').locator('.collection-name')).toHaveCount(0);
});
};

/**
* Open a collection from the sidebar and accept the JavaScript Sandbox modal
* @param page - The page object
Expand Down Expand Up @@ -726,7 +725,7 @@
const addRowToActiveTab = async (page: Page, name: string, value: string) => {
await test.step(`Add row "${name}" to the active environment tab`, async () => {
const nameInput = page.locator('input[placeholder="Name"]').last();
await nameInput.waitFor({ state: 'visible' });

Check failure on line 728 in tests/utils/page/actions.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E Tests (macOS)

[default] › tests/environments/create-environment/collection-env-create.spec.ts:15:7 › Collection Environment Create Tests › should import collection and create environment for request usage

4) [default] › tests/environments/create-environment/collection-env-create.spec.ts:15:7 › Collection Environment Create Tests › should import collection and create environment for request usage › Create environment with variables › Add 5 environment variables › Add environment variable "userId" › Add row "userId" to the active environment tab Error: locator.waitFor: Target page, context or browser has been closed Call log: - waiting for locator('input[placeholder="Name"]').last() to be visible at tests/utils/page/actions.ts:728 726 | await test.step(`Add row "${name}" to the active environment tab`, async () => { 727 | const nameInput = page.locator('input[placeholder="Name"]').last(); > 728 | await nameInput.waitFor({ state: 'visible' }); | ^ 729 | await nameInput.fill(name); 730 | 731 | const row = page.getByTestId(`env-var-row-${name}`); at /Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:728:21 at addRowToActiveTab (/Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:726:14) at /Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:697:11 at addEnvironmentVariable (/Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:690:3) at /Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:711:7 at addEnvironmentVariables (/Users/runner/work/bruno/bruno/tests/utils/page/actions.ts:709:3) at /Users/runner/work/bruno/bruno/tests/environments/create-environment/collection-env-create.spec.ts:31:7 at /Users/runner/work/bruno/bruno/tests/environments/create-environment/collection-env-create.spec.ts:28:5
await nameInput.fill(name);

const row = page.getByTestId(`env-var-row-${name}`);
Expand Down
Loading
Loading