mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 06:28:33 +00:00
feat: variable descriptions (#8269)
* feat: add description column to various tables and enhance UI interactions - Introduced a description column in Headers, VarsTable, and other components to allow multi-line descriptions. - Added toggle buttons to show/hide the description column in relevant tables. - Updated EditableTable component to support dynamic row addition with customizable labels. - Enhanced UI for better user experience with consistent button styles and spacing adjustments. * chore: resize fix handles * fix: restrict column check for last index * refactor: remove unwanted style and fix bottom padding of the last child in the table row * tests: improve testability and fix impacted locators * tests: fix locators for value fields * fix: improve newline handling in description prefix * fix: ts changes * chore: remove redundant code and fix description roundtrip * chore: remove redundant check * tests(bru-lang): tests for description and annotation * test: improve locators and tests * tests: descriptions * chore: re-add description setup * fix: re-add description cols * chore: fix the double click reset * fix: account for hidden sidebar in request pane width calculation * refactor: ui/ux fixes for data type toggle * chore: inline common deps into bruno-lang and bruno-schema * chore: tests * chore: fix ux for descriptions * fix: layout for environment vars table * fix: ensure correct row selection for multipart file upload in tests * feat: enhance UID assignment for request headers and variables in collections * chore: simplify * chore: update pkg * chore: abstract the e2e utils * chore: fix exports * tests: fix locators for datatype vars * fix: ux issue with secrets in environment table * tests: update locators for collection headers and vars descriptions * tests: update locators to use data attributes for datatype selectors * chore: update default css width for actions column * chore: remove tooltip for string type warnings * fix: reduce name widths * refactor: update annotation serialization to use single-quote delimiters for descriptions * refactor(tests): simplify description formatting in jsonToEnv tests * feat: add multiline description escaping and unescaping functions with tests * refactor: clean up imports and improve multiline text block handling * refactor: update locators to use new test IDs for environment variable editors * refactor: streamline header input handling and improve environment variable row access * refactor: update e2e-test job to support self-hosted runners * refactor: update E2E test runner configuration to include e2e and macOS environments --------- Co-authored-by: Pragadesh-45 <temporaryg7904@gmail.com>
This commit is contained in:
@@ -115,9 +115,9 @@ test.describe('bru.setEnvVar(name, value) - secret variable persistence', () =>
|
||||
await expect(locators.environment.varRow('apiToken')).toBeVisible();
|
||||
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror').first())
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toHaveClass(/CodeMirror-empty/);
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.not.toContainText(NEW_VALUE);
|
||||
|
||||
await closeEnvironmentPanel(page, 'collection');
|
||||
@@ -158,7 +158,7 @@ test.describe('bru.setEnvVar(name, value) - secret variable persistence', () =>
|
||||
await expect(envTab.locator('.close-gradient')).not.toHaveClass(/has-changes/);
|
||||
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toContainText(NEW_VALUE);
|
||||
|
||||
await closeEnvironmentPanel(page, 'collection');
|
||||
@@ -213,7 +213,7 @@ test.describe('bru.setEnvVar(name, value) - secret variable persistence', () =>
|
||||
await locators.environment.secretsTab().click();
|
||||
await expect(locators.environment.varRow('apiToken')).toBeVisible();
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toContainText(INITIAL_VALUE);
|
||||
await closeEnvironmentPanel(page, 'collection');
|
||||
|
||||
@@ -244,9 +244,9 @@ test.describe('bru.setEnvVar(name, value) - secret variable persistence', () =>
|
||||
await expect(envTab.locator('.close-gradient')).not.toHaveClass(/has-changes/);
|
||||
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toContainText(NEW_VALUE);
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.not.toContainText(INITIAL_VALUE);
|
||||
await closeEnvironmentPanel(page, 'collection');
|
||||
|
||||
|
||||
@@ -74,17 +74,17 @@ test.describe.serial('bru.setEnvVar(name, value, { persist: true }) — typed va
|
||||
await expect(envTab).toBeVisible();
|
||||
|
||||
await expect(
|
||||
newPage.locator('[data-testid="env-var-row-typed_num"] .type-label').first()
|
||||
).toHaveText('number', { timeout: 5000 });
|
||||
newPage.locator('[data-testid="env-var-row-typed_num"] [data-testid="datatype-selector-trigger"]').first()
|
||||
).toHaveAttribute('data-selected-type', 'number', { timeout: 5000 });
|
||||
await expect(
|
||||
newPage.locator('[data-testid="env-var-row-typed_bool"] .type-label').first()
|
||||
).toHaveText('boolean');
|
||||
newPage.locator('[data-testid="env-var-row-typed_bool"] [data-testid="datatype-selector-trigger"]').first()
|
||||
).toHaveAttribute('data-selected-type', 'boolean');
|
||||
await expect(
|
||||
newPage.locator('[data-testid="env-var-row-typed_obj"] .type-label').first()
|
||||
).toHaveText('object');
|
||||
newPage.locator('[data-testid="env-var-row-typed_obj"] [data-testid="datatype-selector-trigger"]').first()
|
||||
).toHaveAttribute('data-selected-type', 'object');
|
||||
await expect(
|
||||
newPage.locator('[data-testid="env-var-row-typed_str"] .type-label').first()
|
||||
).toHaveText('string');
|
||||
newPage.locator('[data-testid="env-var-row-typed_str"] [data-testid="datatype-selector-trigger"]').first()
|
||||
).toHaveAttribute('data-selected-type', 'string');
|
||||
|
||||
await newPage.getByTestId('responsive-tab-secrets').click();
|
||||
|
||||
@@ -93,8 +93,8 @@ test.describe.serial('bru.setEnvVar(name, value, { persist: true }) — typed va
|
||||
).toBeVisible();
|
||||
// Reloaded with the inferred @number type — the selector shows 'number'.
|
||||
await expect(
|
||||
newPage.locator('[data-testid="env-var-row-existing_secret"] .type-label')
|
||||
).toHaveText('number');
|
||||
newPage.locator('[data-testid="env-var-row-existing_secret"] [data-testid="datatype-selector-trigger"]')
|
||||
).toHaveAttribute('data-selected-type', 'number');
|
||||
|
||||
await envTab.hover();
|
||||
await envTab.getByTestId('request-tab-close-icon').click({ force: true });
|
||||
|
||||
@@ -72,9 +72,9 @@ test.describe('bru.setGlobalEnvVar(name, value) - secret variable persistence (w
|
||||
await expect(locators.environment.varRow('apiToken')).toBeVisible();
|
||||
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror').first())
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toHaveClass(/CodeMirror-empty/);
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.not.toContainText(NEW_VALUE);
|
||||
|
||||
await closeEnvironmentPanel(page, 'global');
|
||||
@@ -117,7 +117,7 @@ test.describe('bru.setGlobalEnvVar(name, value) - secret variable persistence (w
|
||||
await expect(envTab.locator('.close-gradient')).not.toHaveClass(/has-changes/);
|
||||
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toContainText(NEW_VALUE);
|
||||
|
||||
await closeEnvironmentPanel(page, 'global');
|
||||
@@ -171,7 +171,7 @@ test.describe('bru.setGlobalEnvVar(name, value) - secret variable persistence (w
|
||||
await locators.environment.secretsTab().click();
|
||||
await expect(locators.environment.varRow('apiToken')).toBeVisible();
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toContainText(INITIAL_VALUE);
|
||||
await closeEnvironmentPanel(page, 'global');
|
||||
|
||||
@@ -202,9 +202,9 @@ test.describe('bru.setGlobalEnvVar(name, value) - secret variable persistence (w
|
||||
await expect(envTab.locator('.close-gradient')).not.toHaveClass(/has-changes/);
|
||||
|
||||
await locators.environment.varRowEyeToggle('apiToken').click();
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.toContainText(NEW_VALUE);
|
||||
await expect(locators.environment.varRow('apiToken').locator('.CodeMirror'))
|
||||
await expect(locators.environment.varRowValueEditor('apiToken'))
|
||||
.not.toContainText(INITIAL_VALUE);
|
||||
await closeEnvironmentPanel(page, 'global');
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const expectTypeLabel = async (page: Page, name: string, label: string) => {
|
||||
const locators = buildCommonLocators(page);
|
||||
const row = locators.environment.varRow(name);
|
||||
await scrollVirtuosoRowIntoView(page, row);
|
||||
await expect(locators.dataTypeSelector.typeLabel(row)).toHaveText(label, { timeout: SLOW_RENDER_TIMEOUT_MS });
|
||||
await expect(locators.dataTypeSelector.typeLabel(row)).toHaveAttribute('data-selected-type', label, { timeout: SLOW_RENDER_TIMEOUT_MS });
|
||||
};
|
||||
|
||||
const expectMismatchVisible = async (page: Page, name: string) => {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "env-description-yml",
|
||||
"type": "collection"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
name: WithDescriptions
|
||||
|
||||
variables:
|
||||
- name: host
|
||||
value: http://localhost:3000
|
||||
description: Single-line desc
|
||||
- name: token
|
||||
value: abc123
|
||||
description: |-
|
||||
Line one
|
||||
Line two
|
||||
- name: plain
|
||||
value: no-description
|
||||
@@ -0,0 +1,5 @@
|
||||
opencollection: "1.0.0"
|
||||
info:
|
||||
name: env-description-yml
|
||||
|
||||
bundled: false
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"maximized": false,
|
||||
"lastOpenedCollections": [
|
||||
"{{collectionPath}}"
|
||||
],
|
||||
"request": {
|
||||
"sslVerification": false,
|
||||
"customCaCertificate": {
|
||||
"enabled": false,
|
||||
"filePath": null
|
||||
}
|
||||
},
|
||||
"font": {
|
||||
"codeFont": "default"
|
||||
},
|
||||
"proxy": {
|
||||
"enabled": false,
|
||||
"protocol": "http",
|
||||
"hostname": "",
|
||||
"port": "",
|
||||
"auth": {
|
||||
"enabled": false,
|
||||
"username": "",
|
||||
"password": ""
|
||||
},
|
||||
"bypassProxy": ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { test, expect, Page } from '../../../playwright';
|
||||
import { buildCommonLocators } from '../../utils/page/locators';
|
||||
|
||||
const openEnvironmentConfigure = async (page: Page, envName: string) => {
|
||||
const locators = buildCommonLocators(page);
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.environment.envOption(envName)).toBeVisible();
|
||||
await locators.environment.envOption(envName).click();
|
||||
await expect(locators.environment.currentEnvironment().filter({ hasText: envName })).toBeVisible();
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.dropdown.item('Configure')).toBeVisible();
|
||||
await locators.dropdown.item('Configure').click();
|
||||
await expect(locators.tabs.requestTab('Environments')).toBeVisible();
|
||||
};
|
||||
|
||||
test.describe('Environment Variable Descriptions (YAML) - Read', () => {
|
||||
test('reads single-line and multiline descriptions from opencollection.yml environments', async ({
|
||||
pageWithUserData: page
|
||||
}) => {
|
||||
test.setTimeout(30_000);
|
||||
|
||||
const collection = page
|
||||
.getByTestId('collections')
|
||||
.locator('#sidebar-collection-name')
|
||||
.filter({ hasText: 'env-description-yml' });
|
||||
await expect(collection).toBeVisible();
|
||||
await collection.click();
|
||||
|
||||
await openEnvironmentConfigure(page, 'WithDescriptions');
|
||||
|
||||
const locators = buildCommonLocators(page);
|
||||
|
||||
await expect(page.locator('input[name="0.name"]')).toHaveValue('host');
|
||||
const hostDesc = locators.environment.variableDescriptionEditor(0);
|
||||
await expect(hostDesc.locator('.CodeMirror-line').first()).toHaveText('Single-line desc');
|
||||
|
||||
await expect(page.locator('input[name="1.name"]')).toHaveValue('token');
|
||||
const tokenDesc = locators.environment.variableDescriptionEditor(1);
|
||||
await expect(tokenDesc.locator('.CodeMirror-line').nth(0)).toHaveText('Line one');
|
||||
await expect(tokenDesc.locator('.CodeMirror-line').nth(1)).toHaveText('Line two');
|
||||
|
||||
await expect(page.locator('input[name="2.name"]')).toHaveValue('plain');
|
||||
const plainDesc = locators.environment.variableDescriptionEditor(2);
|
||||
await expect(plainDesc.locator('.CodeMirror-line').first()).toHaveText('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { test, expect, Page } from '../../../playwright';
|
||||
import { buildCommonLocators } from '../../utils/page/locators';
|
||||
|
||||
const openEnvironmentConfigure = async (page: Page, envName: string) => {
|
||||
const locators = buildCommonLocators(page);
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.environment.envOption(envName)).toBeVisible();
|
||||
await locators.environment.envOption(envName).click();
|
||||
await expect(locators.environment.currentEnvironment().filter({ hasText: envName })).toBeVisible();
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.dropdown.item('Configure')).toBeVisible();
|
||||
await locators.dropdown.item('Configure').click();
|
||||
await expect(locators.tabs.requestTab('Environments')).toBeVisible();
|
||||
};
|
||||
|
||||
test.describe('Environment Variable Descriptions (YAML) - Write', () => {
|
||||
test('writes a multiline description and persists it to the .yml file', async ({
|
||||
pageWithUserData: page,
|
||||
collectionFixturePath
|
||||
}) => {
|
||||
test.setTimeout(30_000);
|
||||
|
||||
const collection = page
|
||||
.getByTestId('collections')
|
||||
.locator('#sidebar-collection-name')
|
||||
.filter({ hasText: 'env-description-yml' });
|
||||
await expect(collection).toBeVisible();
|
||||
await collection.click();
|
||||
|
||||
await openEnvironmentConfigure(page, 'WithDescriptions');
|
||||
|
||||
await page.evaluate((rowIndex) => {
|
||||
const rows = document.querySelectorAll('tr');
|
||||
for (const row of rows) {
|
||||
if (row.querySelector(`input[name="${rowIndex}.name"]`)) {
|
||||
const cms = row.querySelectorAll('.CodeMirror');
|
||||
const cm = (cms[1] as any)?.CodeMirror;
|
||||
if (cm) cm.setValue('First line\nSecond line');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
|
||||
const plainDescEditor = buildCommonLocators(page).environment.variableDescriptionEditor(2);
|
||||
await expect(plainDescEditor.locator('.CodeMirror-line').nth(0)).toHaveText('First line');
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
await page.getByTestId('save-env').click();
|
||||
await expect(page.getByText('Changes saved successfully')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
const envFilePath = path.join(collectionFixturePath!, 'environments', 'WithDescriptions.yml');
|
||||
const fileContent = fs.readFileSync(envFilePath, 'utf8');
|
||||
|
||||
expect(fileContent).toContain('First line');
|
||||
expect(fileContent).toContain('Second line');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "env-description",
|
||||
"type": "collection"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
vars {
|
||||
@description('''Single-line desc''')
|
||||
host: http://localhost:3000
|
||||
@description('''empty description''')
|
||||
@description('''
|
||||
Line one
|
||||
Line two
|
||||
''')
|
||||
token: abc123
|
||||
plain: no-description
|
||||
@description("has ''' triple quotes inside")
|
||||
tricky: value
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"collections": [
|
||||
{
|
||||
"path": "{{collectionPath}}",
|
||||
"securityConfig": {
|
||||
"jsSandboxMode": "developer"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"maximized": false,
|
||||
"lastOpenedCollections": [
|
||||
"{{collectionPath}}"
|
||||
],
|
||||
"request": {
|
||||
"sslVerification": false,
|
||||
"customCaCertificate": {
|
||||
"enabled": false,
|
||||
"filePath": null
|
||||
}
|
||||
},
|
||||
"font": {
|
||||
"codeFont": "default"
|
||||
},
|
||||
"proxy": {
|
||||
"enabled": false,
|
||||
"protocol": "http",
|
||||
"hostname": "",
|
||||
"port": "",
|
||||
"auth": {
|
||||
"enabled": false,
|
||||
"username": "",
|
||||
"password": ""
|
||||
},
|
||||
"bypassProxy": ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { test, expect, Page } from '../../../playwright';
|
||||
import { buildCommonLocators } from '../../utils/page/locators';
|
||||
|
||||
const openEnvironmentConfigure = async (page: Page, envName: string) => {
|
||||
const locators = buildCommonLocators(page);
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.environment.envOption(envName)).toBeVisible();
|
||||
await locators.environment.envOption(envName).click();
|
||||
await expect(locators.environment.currentEnvironment().filter({ hasText: envName })).toBeVisible();
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.dropdown.item('Configure')).toBeVisible();
|
||||
await locators.dropdown.item('Configure').click();
|
||||
await expect(locators.tabs.requestTab('Environments')).toBeVisible();
|
||||
};
|
||||
|
||||
test.describe('Environment Variable Descriptions - Read', () => {
|
||||
test('reads single-line and multiline descriptions from a pre-existing environment file', async ({
|
||||
pageWithUserData: page
|
||||
}) => {
|
||||
test.setTimeout(30_000);
|
||||
|
||||
const collection = page
|
||||
.getByTestId('collections')
|
||||
.locator('#sidebar-collection-name')
|
||||
.filter({ hasText: 'env-description' });
|
||||
await expect(collection).toBeVisible();
|
||||
await collection.click();
|
||||
|
||||
await openEnvironmentConfigure(page, 'WithDescriptions');
|
||||
|
||||
const locators = buildCommonLocators(page);
|
||||
|
||||
// row 0: host — single-line description
|
||||
await expect(page.locator('input[name="0.name"]')).toHaveValue('host');
|
||||
const hostDesc = locators.environment.variableDescriptionEditor(0);
|
||||
await expect(hostDesc).toBeVisible();
|
||||
await expect(hostDesc.locator('.CodeMirror-line').first()).toHaveText('Single-line desc');
|
||||
|
||||
// row 1: orphaned @description('''empty description''') — empty name/value, description is 'empty description'
|
||||
await expect(page.locator('input[name="1.name"]')).toHaveValue('');
|
||||
const orphanDesc = locators.environment.variableDescriptionEditor(1);
|
||||
await expect(orphanDesc).toBeVisible();
|
||||
await expect(orphanDesc.locator('.CodeMirror-line').first()).toHaveText('empty description');
|
||||
|
||||
// row 2: token — gets the last (multiline) description; the first was consumed by the orphaned row
|
||||
await expect(page.locator('input[name="2.name"]')).toHaveValue('token');
|
||||
const tokenDesc = locators.environment.variableDescriptionEditor(2);
|
||||
await expect(tokenDesc).toBeVisible();
|
||||
await expect(tokenDesc.locator('.CodeMirror-line').nth(0)).toHaveText('Line one');
|
||||
await expect(tokenDesc.locator('.CodeMirror-line').nth(1)).toHaveText('Line two');
|
||||
|
||||
// row 3: plain — no description (editor is empty)
|
||||
await expect(page.locator('input[name="3.name"]')).toHaveValue('plain');
|
||||
const plainDesc = locators.environment.variableDescriptionEditor(3);
|
||||
await expect(plainDesc).toBeVisible();
|
||||
await expect(plainDesc.locator('.CodeMirror-line').first()).toHaveText('');
|
||||
|
||||
// row 4: tricky — description containing ''' (stored as triple-quoted @description('''...'''))
|
||||
await expect(page.locator('input[name="4.name"]')).toHaveValue('tricky');
|
||||
const trickyDesc = locators.environment.variableDescriptionEditor(4);
|
||||
await expect(trickyDesc).toBeVisible();
|
||||
await expect(trickyDesc.locator('.CodeMirror-line').first()).toHaveText('has \'\'\' triple quotes inside');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { test, expect, Page } from '../../../playwright';
|
||||
import { buildCommonLocators } from '../../utils/page/locators';
|
||||
|
||||
const openEnvironmentConfigure = async (page: Page, envName: string) => {
|
||||
const locators = buildCommonLocators(page);
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.environment.envOption(envName)).toBeVisible();
|
||||
await locators.environment.envOption(envName).click();
|
||||
await expect(locators.environment.currentEnvironment().filter({ hasText: envName })).toBeVisible();
|
||||
await locators.environment.currentEnvironment().click();
|
||||
await expect(locators.dropdown.item('Configure')).toBeVisible();
|
||||
await locators.dropdown.item('Configure').click();
|
||||
await expect(locators.tabs.requestTab('Environments')).toBeVisible();
|
||||
};
|
||||
|
||||
test.describe('Environment Variable Descriptions - Write', () => {
|
||||
test('writes a multiline description and persists it to the .bru file', async ({
|
||||
pageWithUserData: page,
|
||||
collectionFixturePath
|
||||
}) => {
|
||||
test.setTimeout(30_000);
|
||||
|
||||
const collection = page
|
||||
.getByTestId('collections')
|
||||
.locator('#sidebar-collection-name')
|
||||
.filter({ hasText: 'env-description' });
|
||||
await expect(collection).toBeVisible();
|
||||
await collection.click();
|
||||
|
||||
await openEnvironmentConfigure(page, 'WithDescriptions');
|
||||
|
||||
// Set the description value directly via CodeMirror's JS API so that the `change`
|
||||
// event fires synchronously and formik receives the update before we save.
|
||||
// keyboard.type / insertText are unreliable in Electron because synthetic key events
|
||||
// don't always go through CodeMirror's textarea input handler.
|
||||
await page.evaluate((rowIndex) => {
|
||||
const rows = document.querySelectorAll('tr');
|
||||
for (const row of rows) {
|
||||
if (row.querySelector(`input[name="${rowIndex}.name"]`)) {
|
||||
const cms = row.querySelectorAll('.CodeMirror');
|
||||
const cm = (cms[1] as any)?.CodeMirror; // description editor is the 2nd CodeMirror
|
||||
if (cm) cm.setValue('First line\nSecond line');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
|
||||
// Wait for the CodeMirror DOM to reflect the value, then give React a tick to flush formik
|
||||
const plainDescEditor = buildCommonLocators(page).environment.variableDescriptionEditor(2);
|
||||
await expect(plainDescEditor.locator('.CodeMirror-line').nth(0)).toHaveText('First line');
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
await page.getByTestId('save-env').click();
|
||||
await expect(page.getByText('Changes saved successfully')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// The IPC write completes before the toast resolves, so the file is ready to read.
|
||||
const envFilePath = path.join(collectionFixturePath!, 'environments', 'WithDescriptions.bru');
|
||||
const fileContent = fs.readFileSync(envFilePath, 'utf8');
|
||||
|
||||
expect(fileContent).toContain('First line');
|
||||
expect(fileContent).toContain('Second line');
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,12 @@
|
||||
vars {
|
||||
@description('''Single-line host desc''')
|
||||
host: http://localhost:3000
|
||||
}
|
||||
|
||||
vars:secret [
|
||||
@description('''
|
||||
Secret line one
|
||||
Secret line two
|
||||
''')
|
||||
secretToken
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
vars {
|
||||
@description('''Single-line host desc''')
|
||||
host: https://echo.usebruno.com
|
||||
}
|
||||
|
||||
vars:secret [
|
||||
@description('''
|
||||
Secret line one
|
||||
Secret line two
|
||||
''')
|
||||
secretToken
|
||||
]
|
||||
]
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"value": "http://localhost:3000",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"uid": "3WEAWueN0Ov99uOX0uuuM",
|
||||
@@ -18,7 +19,8 @@
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -32,7 +34,8 @@
|
||||
"value": "https://echo.usebruno.com",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"uid": "fSxTRpngl8fxkhrl3z7hA",
|
||||
@@ -40,7 +43,8 @@
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
"value": "http://localhost:3000",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -32,14 +34,16 @@
|
||||
"value": "https://echo.usebruno.com",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
"value": "http://localhost:3000",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
"value": "https://echo.usebruno.com",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
"value": "http://localhost:3000",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -32,14 +34,16 @@
|
||||
"value": "https://echo.usebruno.com",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
"value": "http://localhost:3000",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
"value": "https://echo.usebruno.com",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
"value": "http://localhost:3000",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": false
|
||||
"secret": false,
|
||||
"description": "Single-line host desc"
|
||||
},
|
||||
{
|
||||
"name": "secretToken",
|
||||
"value": "",
|
||||
"type": "text",
|
||||
"enabled": true,
|
||||
"secret": true
|
||||
"secret": true,
|
||||
"description": "Secret line one\nSecret line two"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { test, expect } from '../../../../../playwright';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { buildCommonLocators } from '../../../../utils/page/locators';
|
||||
|
||||
test.describe.serial('Collection Environment Import Tests', () => {
|
||||
test('should import single collection environment', async ({ pageWithUserData: page }) => {
|
||||
@@ -43,9 +44,17 @@ test.describe.serial('Collection Environment Import Tests', () => {
|
||||
const envTab = page.locator('.request-tab').filter({ hasText: 'Environments' });
|
||||
await expect(envTab).toBeVisible();
|
||||
|
||||
await expect(page.getByRole('row', { name: 'host' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
const locators = buildCommonLocators(page);
|
||||
await expect(locators.environment.varRowValueCell('host')).toBeVisible();
|
||||
const hostDesc = locators.environment.varRowDescriptionEditor('host');
|
||||
await expect(hostDesc.locator('.CodeMirror-line').first()).toHaveText('Single-line host desc');
|
||||
|
||||
await page.getByTestId('responsive-tab-secrets').click();
|
||||
await expect(page.getByRole('row', { name: 'secretToken' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
await expect(locators.environment.varRowValueCell('secretToken')).toBeVisible();
|
||||
|
||||
const secretDesc = locators.environment.varRowDescriptionEditor('secretToken');
|
||||
await expect(secretDesc.locator('.CodeMirror-line').nth(0)).toHaveText('Secret line one');
|
||||
await expect(secretDesc.locator('.CodeMirror-line').nth(1)).toHaveText('Secret line two');
|
||||
|
||||
await envTab.hover();
|
||||
await envTab.getByTestId('request-tab-close-icon').click({ force: true });
|
||||
@@ -125,11 +134,12 @@ test.describe.serial('Collection Environment Import Tests', () => {
|
||||
await expect(envTab).toBeVisible();
|
||||
|
||||
// Verify prod environment variables
|
||||
await expect(page.getByRole('row', { name: 'host' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
const locators = buildCommonLocators(page);
|
||||
await expect(locators.environment.varRowValueCell('host')).toBeVisible();
|
||||
|
||||
// secretToken was imported as a secret, so it lives on the Secrets tab, not Variables.
|
||||
await page.getByTestId('responsive-tab-secrets').click();
|
||||
await expect(page.getByRole('row', { name: 'secretToken' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
await expect(locators.environment.varRowValueCell('secretToken')).toBeVisible();
|
||||
|
||||
await envTab.hover();
|
||||
await envTab.getByTestId('request-tab-close-icon').click({ force: true });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { test, expect } from '../../../../../playwright';
|
||||
import path from 'path';
|
||||
import { buildCommonLocators } from '../../../../utils/page/locators';
|
||||
|
||||
test.describe.serial('Global Environment Import Tests', () => {
|
||||
test('should import single global environment', async ({ pageWithUserData: page }) => {
|
||||
@@ -58,9 +59,10 @@ test.describe.serial('Global Environment Import Tests', () => {
|
||||
await expect(envTab).toBeVisible();
|
||||
|
||||
// Verify imported variables
|
||||
await expect(page.getByRole('row', { name: 'host' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
const locators = buildCommonLocators(page);
|
||||
await expect(locators.environment.varRowValueCell('host')).toBeVisible();
|
||||
await page.getByTestId('responsive-tab-secrets').click();
|
||||
await expect(page.getByRole('row', { name: 'secretToken' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
await expect(locators.environment.varRowValueCell('secretToken')).toBeVisible();
|
||||
|
||||
await envTab.hover();
|
||||
await envTab.getByTestId('request-tab-close-icon').click({ force: true });
|
||||
@@ -142,11 +144,12 @@ test.describe.serial('Global Environment Import Tests', () => {
|
||||
await expect(envTab).toBeVisible();
|
||||
|
||||
// Verify imported variables
|
||||
await expect(page.getByRole('row', { name: 'host' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
const locators = buildCommonLocators(page);
|
||||
await expect(locators.environment.varRowValueCell('host')).toBeVisible();
|
||||
|
||||
// secretToken was imported as a secret, so it lives on the Secrets tab, not Variables.
|
||||
await page.getByTestId('responsive-tab-secrets').click();
|
||||
await expect(page.getByRole('row', { name: 'secretToken' }).getByRole('cell').nth(1)).toBeVisible();
|
||||
await expect(locators.environment.varRowValueCell('secretToken')).toBeVisible();
|
||||
|
||||
await envTab.hover();
|
||||
await envTab.getByTestId('request-tab-close-icon').click({ force: true });
|
||||
|
||||
@@ -37,7 +37,7 @@ test.describe('Multiline Variables - Write Test', () => {
|
||||
// Use force:true to bypass Playwright's stability check on the CodeMirror click.
|
||||
const variableRow = page.locator('tbody tr').filter({ has: page.locator('input[value="multiline_data_json"]') });
|
||||
await expect(variableRow).toBeVisible();
|
||||
const codeMirror = variableRow.locator('.CodeMirror');
|
||||
const codeMirror = variableRow.getByTestId(/^test-multiline-editor-\d+\.value$/);
|
||||
|
||||
const jsonValue = `{
|
||||
"user": {
|
||||
|
||||
Reference in New Issue
Block a user