mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
tests: fix breaking tests (#7132)
* fix: update placeholder text for environment variable input * fix: handle undefined color in environment objects Don't export if `undefined` * fix: update collection import logic for YML and BRU formats * fix: ensure error icon is not visible after header validation * fix: specify format for collection and environment serialization
This commit is contained in:
@@ -477,7 +477,7 @@ const EnvironmentVariablesTable = ({
|
||||
id={`${actualIndex}.name`}
|
||||
name={`${actualIndex}.name`}
|
||||
value={variable.name}
|
||||
placeholder={!variable.value || (typeof variable.value === 'string' && variable.value.trim() === '') ? 'Value' : ''}
|
||||
placeholder={!variable.value || (typeof variable.value === 'string' && variable.value.trim() === '') ? 'Name' : ''}
|
||||
onChange={(e) => handleNameChange(actualIndex, e)}
|
||||
onBlur={() => handleNameBlur(actualIndex)}
|
||||
onKeyDown={(e) => handleNameKeyDown(actualIndex, e)}
|
||||
|
||||
@@ -7,7 +7,7 @@ export const exportBrunoEnvironment = async ({ environments, environmentType, fi
|
||||
let cleanEnvironments = environments.map((environment) => ({
|
||||
name: environment.name,
|
||||
variables: (environment.variables || []).map((envVariable) => buildEnvVariable({ envVariable })),
|
||||
color: environment.color
|
||||
color: environment.color ?? undefined
|
||||
}));
|
||||
|
||||
await ipcRenderer.invoke('renderer:export-environment', {
|
||||
|
||||
@@ -457,7 +457,7 @@ const createCollectionFromBrunoObject = async (collection, dirPath) => {
|
||||
|
||||
// Create collection.bru if root exists
|
||||
if (collection.root) {
|
||||
const collectionContent = await stringifyCollection(collection.root);
|
||||
const collectionContent = await stringifyCollection(collection.root, {}, { format: 'bru' });
|
||||
fs.writeFileSync(path.join(dirPath, 'collection.bru'), collectionContent);
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ const createCollectionFromBrunoObject = async (collection, dirPath) => {
|
||||
fs.mkdirSync(envDirPath, { recursive: true });
|
||||
|
||||
for (const env of collection.environments) {
|
||||
const content = await stringifyEnvironment(env);
|
||||
const content = await stringifyEnvironment(env, { format: 'bru' });
|
||||
const filename = sanitizeName(`${env.name}.bru`);
|
||||
fs.writeFileSync(path.join(envDirPath, filename), content);
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
|
||||
const environmentWithInfo = (environment) => ({
|
||||
name: environment.name,
|
||||
variables: environment.variables,
|
||||
color: environment.color,
|
||||
color: environment.color ?? undefined,
|
||||
info: {
|
||||
type: 'bruno-environment',
|
||||
exportedAt: new Date().toISOString(),
|
||||
|
||||
@@ -100,13 +100,13 @@ async function importCollection(collection, collectionLocation, mainWindow, uniq
|
||||
let brunoConfig = getBrunoJsonConfig(collection);
|
||||
|
||||
if (format === 'yml') {
|
||||
const collectionContent = await stringifyCollection(collection.root, { format });
|
||||
const collectionContent = await stringifyCollection(collection.root, brunoConfig, { format });
|
||||
await writeFile(path.join(collectionPath, 'opencollection.yml'), collectionContent);
|
||||
} else if (format === 'bru') {
|
||||
const stringifiedBrunoConfig = await stringifyJson(brunoConfig);
|
||||
await writeFile(path.join(collectionPath, 'bruno.json'), stringifiedBrunoConfig);
|
||||
|
||||
const collectionContent = await stringifyCollection(collection.root, { format });
|
||||
const collectionContent = await stringifyCollection(collection.root, brunoConfig, { format });
|
||||
await writeFile(path.join(collectionPath, 'collection.bru'), collectionContent);
|
||||
} else {
|
||||
throw new Error(`Invalid format: ${format}`);
|
||||
|
||||
@@ -2,8 +2,6 @@ import { test, expect } from '../../../playwright';
|
||||
|
||||
test.describe('Multiline Variables - Write Test', () => {
|
||||
test('should create and use multiline environment variable dynamically', async ({ pageWithUserData: page }) => {
|
||||
test.setTimeout(60 * 1000);
|
||||
|
||||
// open the collection
|
||||
const collection = page.getByTestId('collections').locator('#sidebar-collection-name').filter({ hasText: 'multiline-variables' });
|
||||
await expect(collection).toBeVisible();
|
||||
|
||||
@@ -58,7 +58,10 @@ test.describe.serial('Header Validation', () => {
|
||||
|
||||
// Verify the error icon is not visible
|
||||
const errorIcon = headerRow.locator('.text-red-600');
|
||||
await expect(errorIcon).not.toBeVisible();
|
||||
|
||||
// wait for formik to revalidate
|
||||
await headerRow.click();
|
||||
await expect(errorIcon).not.toBeVisible({});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user