mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-29 07:34:07 +00:00
fix: example-request tab collision (#7989)
* fix: prevent response-example tabs from hijacking request sidebar selection * fix: add selectors for examples with index * test: better locator * fix: duplicate name collision * fix: refactor sidebar example handling functions for better clarity and reusability * chore: cr comments
This commit is contained in:
@@ -1198,6 +1198,41 @@ const sendAndWaitForResponse = async (page: Page) => {
|
||||
});
|
||||
};
|
||||
|
||||
const createExampleFromSidebar = async (page: Page, requestName: string, exampleName: string, description: string = '') => {
|
||||
const requestRow = page.locator('.collection-item-name').filter({ hasText: requestName }).first();
|
||||
|
||||
await requestRow.hover();
|
||||
await requestRow.locator('..').locator('.menu-icon').click({ force: true });
|
||||
await page.locator('.dropdown-item').filter({ hasText: 'Create Example' }).click();
|
||||
|
||||
const exampleInput = page.getByTestId('create-example-name-input');
|
||||
await expect(exampleInput).toBeVisible();
|
||||
await exampleInput.clear();
|
||||
await exampleInput.fill(exampleName);
|
||||
const descriptionInput = page.getByTestId('create-example-description-input');
|
||||
await descriptionInput.clear();
|
||||
await descriptionInput.fill(description);
|
||||
await page.getByRole('button', { name: 'Create Example' }).click();
|
||||
await expect(page.locator('text=Create Response Example')).not.toBeAttached();
|
||||
};
|
||||
|
||||
const openExampleFromSidebar = async (page: Page, requestName: string, exampleName: string, index: number = 0) => {
|
||||
const requestRow = page.locator('.collection-item-name').filter({ hasText: requestName }).first();
|
||||
const requestBranch = requestRow.locator('..');
|
||||
const exampleRow = requestBranch
|
||||
.locator('.collection-item-name')
|
||||
.filter({ has: page.locator('.example-icon') })
|
||||
.getByText(exampleName, { exact: true })
|
||||
.nth(index);
|
||||
|
||||
if (!(await exampleRow.isVisible())) {
|
||||
await requestRow.getByTestId('request-item-chevron').click();
|
||||
}
|
||||
|
||||
await expect(exampleRow).toBeVisible();
|
||||
await exampleRow.click();
|
||||
};
|
||||
|
||||
export {
|
||||
closeAllCollections,
|
||||
openCollection,
|
||||
@@ -1243,7 +1278,9 @@ export {
|
||||
addPostResponseScript,
|
||||
addTestScript,
|
||||
sendAndWaitForErrorCard,
|
||||
sendAndWaitForResponse
|
||||
sendAndWaitForResponse,
|
||||
createExampleFromSidebar,
|
||||
openExampleFromSidebar
|
||||
};
|
||||
|
||||
export type { SandboxMode, EnvironmentType, EnvironmentVariable, ImportCollectionOptions, CreateRequestOptions, CreateUntitledRequestOptions, CreateTransientRequestOptions, AssertionInput };
|
||||
|
||||
Reference in New Issue
Block a user