diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/StyledWrapper.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/StyledWrapper.js
new file mode 100644
index 00000000000..1d9ae067cb1
--- /dev/null
+++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/StyledWrapper.js
@@ -0,0 +1,146 @@
+import styled from 'styled-components';
+
+export const ModalTitle = styled.div`
+ color: ${(props) => props.theme.colors.text.subtext2};
+ font-weight: 600;
+ font-size: ${(props) => props.theme.font.size.base};
+ line-height: 18px;
+`;
+
+const StyledWrapper = styled.div`
+ max-width: 100%;
+ .subheader {
+ margin-bottom: 0.5rem;
+ color: ${(props) => props.theme.colors.text.muted};
+ font-weight: 400;
+ font-size: ${(props) => props.theme.font.size.base};
+ line-height: 18px;
+
+ .collection-name {
+ color: ${(props) => props.theme.text};
+ font-weight: 600;
+ }
+ }
+
+ .version-card {
+ width: 100%;
+ border: 1px solid ${(props) => props.theme.border.border1};
+ border-radius: ${(props) => props.theme.border.radius.md};
+ overflow: hidden;
+
+ .version-row {
+ display: flex;
+ align-items: flex-start;
+ gap: 1rem;
+ padding: 1rem;
+ }
+
+ .version-col {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ }
+
+ .col-label {
+ color: ${(props) => props.theme.text};
+ font-weight: 500;
+ font-size: ${(props) => props.theme.font.size.base};
+ line-height: 20px;
+ }
+
+ .current-value {
+ color: ${(props) => props.theme.text};
+ font-weight: 400;
+ font-size: ${(props) => props.theme.font.size.sm};
+ line-height: 20px;
+ overflow-wrap: anywhere;
+
+ .unset {
+ font-family: inherit;
+ font-style: italic;
+ }
+ }
+
+ .arrow {
+ align-self: center;
+ color: ${(props) => props.theme.colors.text.muted};
+ flex-shrink: 0;
+ }
+
+ .input-wrap {
+ position: relative;
+
+ .textbox {
+ padding-right: 2.25rem;
+ color: ${(props) => props.theme.text};
+ font-weight: 400;
+ font-size: ${(props) => props.theme.font.size.sm};
+ line-height: 20px;
+ }
+
+ .copy-btn {
+ position: absolute;
+ top: 50%;
+ right: 0.5rem;
+ transform: translateY(-50%);
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ padding: 0.25rem;
+ background: transparent;
+ border: none;
+ cursor: pointer;
+ color: ${(props) => props.theme.colors.text.muted};
+
+ &:hover:not(:disabled) {
+ color: ${(props) => props.theme.text};
+ }
+
+ &:disabled {
+ opacity: 0.5;
+ cursor: default;
+ }
+ }
+ }
+ }
+
+ .preview {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 0.25rem;
+ padding: 0.625rem 1rem;
+ border-top: 1px solid ${(props) => props.theme.border.border1};
+ background-color: ${(props) => props.theme.background.mantle};
+ color: ${(props) => props.theme.text};
+ font-weight: 400;
+ font-size: ${(props) => props.theme.font.size.sm};
+ line-height: 20px;
+
+ strong {
+ font-weight: 700;
+ }
+
+ .old {
+ color: ${(props) => props.theme.colors.text.danger};
+ font-weight: 700;
+ word-break: break-all;
+ }
+
+ .new {
+ font-family: monospace;
+ color: ${(props) => props.theme.colors.text.green};
+ font-weight: 700;
+ word-break: break-all;
+ }
+
+ .preview-arrow {
+ color: ${(props) => props.theme.colors.text.muted};
+ flex-shrink: 0;
+ }
+ }
+`;
+
+export default StyledWrapper;
diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/index.js
new file mode 100644
index 00000000000..a351fcc564b
--- /dev/null
+++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/index.js
@@ -0,0 +1,143 @@
+import React, { useEffect, useMemo, useRef, useState } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+import { IconArrowRight, IconCopy, IconCheck, IconAlertTriangle } from '@tabler/icons';
+
+import Modal from 'components/Modal';
+import Portal from 'components/Portal';
+import { findCollectionByUid, getCollectionVersion, isOpenCollectionFormat } from 'utils/collections/index';
+import { saveCollectionVersion } from 'providers/ReduxStore/slices/collections/actions';
+import StyledWrapper, { ModalTitle } from './StyledWrapper';
+
+const CollectionNotFound = ({ onClose }) => (
+
+);
+
+const ChangeCollectionVersion = ({ collectionUid, onClose }) => {
+ const dispatch = useDispatch();
+ const inputRef = useRef(null);
+ const collection = useSelector((state) => findCollectionByUid(state.collections.collections, collectionUid));
+
+ const currentVersion = getCollectionVersion(collection);
+ const isYml = isOpenCollectionFormat(collection);
+ const targetKey = isYml ? 'info.version' : 'collectionVersion';
+ const targetFile = isYml ? 'opencollection.yml' : 'bruno.json';
+ const [newVersion, setNewVersion] = useState(currentVersion);
+ const [isSaving, setIsSaving] = useState(false);
+ const [copied, setCopied] = useState(false);
+
+ useEffect(() => {
+ if (inputRef.current) {
+ inputRef.current.focus();
+ inputRef.current.select();
+ }
+ }, []);
+
+ const trimmedVersion = newVersion.trim();
+ const canSubmit = useMemo(
+ () => trimmedVersion.length > 0 && trimmedVersion !== currentVersion,
+ [trimmedVersion, currentVersion]
+ );
+
+ const handleConfirm = () => {
+ if (!canSubmit || isSaving) return;
+ setIsSaving(true);
+ dispatch(saveCollectionVersion(collectionUid, trimmedVersion))
+ .then(() => onClose())
+ .catch(() => setIsSaving(false));
+ };
+
+ const handleCopy = () => {
+ if (!trimmedVersion || !navigator.clipboard) return;
+ navigator.clipboard.writeText(trimmedVersion)
+ .then(() => {
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ }).catch(() => {});
+ };
+
+ if (!collection) {
+ return
+ );
+};
+
+export default ChangeCollectionVersion;
diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/index.spec.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/index.spec.js
new file mode 100644
index 00000000000..eda5e485265
--- /dev/null
+++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/ChangeCollectionVersion/index.spec.js
@@ -0,0 +1,126 @@
+import '@testing-library/jest-dom';
+import React from 'react';
+import { render, screen, fireEvent, waitFor } from '@testing-library/react';
+import { Provider } from 'react-redux';
+import { configureStore, createSlice } from '@reduxjs/toolkit';
+import ChangeCollectionVersion from './index';
+
+const mockSaveCollectionVersion = jest.fn();
+
+jest.mock('providers/ReduxStore/slices/collections/actions', () => ({
+ saveCollectionVersion: (collectionUid, version) => {
+ mockSaveCollectionVersion(collectionUid, version);
+ return () => Promise.resolve();
+ }
+}));
+
+jest.mock('components/Portal', () => ({
+ __esModule: true,
+ default: ({ children }) =>
+}));
+
+jest.mock('./StyledWrapper', () => ({
+ __esModule: true,
+ default: ({ children, className }) =>
+}));
+
+jest.mock('components/Modal', () => ({
+ __esModule: true,
+ default: (props) => (
+
+ )
+}));
+
+const buildCollection = (overrides = {}) => ({
+ uid: 'collection-1',
+ name: 'Bruno-Testbench',
+ pathname: '/tmp/bruno-testbench',
+ brunoConfig: { opencollection: '1.0.0', name: 'Bruno-Testbench', version: 'v1.0.0' },
+ ...overrides
+});
+
+const renderModal = (collection, onClose = jest.fn()) => {
+ const collections = collection ? [collection] : [];
+ const slice = createSlice({ name: 'collections', initialState: { collections }, reducers: {} });
+ const store = configureStore({ reducer: { collections: slice.reducer } });
+ const utils = render(
+
+ );
+ return { ...utils, onClose };
+};
+
+beforeEach(() => {
+ mockSaveCollectionVersion.mockClear();
+});
+
+describe('ChangeCollectionVersion', () => {
+ it('lets you save only when the new version is different from the current one', () => {
+ renderModal(buildCollection());
+ const submit = screen.getByTestId('change-version-submit-btn');
+ const input = screen.getByTestId('change-version-input');
+
+ expect(submit).toBeDisabled();
+ fireEvent.change(input, { target: { value: '2' } });
+ expect(submit).toBeEnabled();
+ fireEvent.change(input, { target: { value: 'v1.0.0' } });
+ expect(submit).toBeDisabled();
+ });
+
+ it('limits the version input at 50 characters', () => {
+ renderModal(buildCollection());
+ expect(screen.getByTestId('change-version-input')).toHaveAttribute('maxlength', '50');
+ });
+
+ it('does not let you save an empty or blank version', () => {
+ renderModal(buildCollection());
+ fireEvent.change(screen.getByTestId('change-version-input'), { target: { value: ' ' } });
+ expect(screen.getByTestId('change-version-submit-btn')).toBeDisabled();
+ });
+
+ it('removes extra spaces around the version before saving, then closes', async () => {
+ const { onClose } = renderModal(buildCollection());
+
+ fireEvent.change(screen.getByTestId('change-version-input'), { target: { value: ' 2.0.0 ' } });
+ fireEvent.click(screen.getByTestId('change-version-submit-btn'));
+
+ expect(mockSaveCollectionVersion).toHaveBeenCalledWith('collection-1', '2.0.0');
+ await waitFor(() => expect(onClose).toHaveBeenCalled());
+ });
+
+ it('for a bru collection, the preview mentions bruno.json and collectionVersion', () => {
+ renderModal(buildCollection({ brunoConfig: { version: '1', name: 'Legacy', type: 'collection' } }));
+ fireEvent.change(screen.getByTestId('change-version-input'), { target: { value: '2' } });
+
+ const preview = screen.getByTestId('change-version-preview');
+ expect(preview).toHaveTextContent('collectionVersion');
+ expect(preview).toHaveTextContent('bruno.json');
+ expect(preview).not.toHaveTextContent('info.version');
+ });
+
+ it('shows "Not Set" for a yml collection that has no version yet', () => {
+ renderModal(buildCollection({ brunoConfig: { opencollection: '1.0.0', name: 'Bruno-Testbench' } }));
+
+ expect(screen.getByTestId('change-version-current')).toHaveTextContent('Not Set');
+ expect(screen.getByTestId('change-version-input')).toHaveValue('');
+ });
+
+ it('shows a "Collection not found" message when the collection is missing', () => {
+ renderModal(null);
+
+ expect(screen.getByTestId('modal-title')).toHaveTextContent('Change Collection Version');
+ expect(screen.getByText(/Collection not found/i)).toBeInTheDocument();
+ expect(screen.queryByTestId('change-version-input')).not.toBeInTheDocument();
+ });
+});
diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.js
index d37eb98de1e..f03cdbbeac9 100644
--- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.js
+++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.js
@@ -8,9 +8,7 @@ const CollectionVersionInfo = ({ name, version, folderCount = 0, requestCount =
{name}
- {version ? (
- {`Version: ${version}`}
- ) : null}
+ {`Version: ${version || 'Not Set'}`}
{`${folderCount} ${folderLabel}`}
diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.spec.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.spec.js
index e05df180972..8b6806d411d 100644
--- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.spec.js
+++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.spec.js
@@ -14,9 +14,9 @@ describe('CollectionVersionInfo', () => {
expect(screen.getByTestId('version-value')).toHaveTextContent('Version: 2.3-beta');
});
- it('omits the version when the collection has none', () => {
+ it('shows "Not Set" when the collection has no version', () => {
render();
- expect(screen.queryByTestId('version-value')).not.toBeInTheDocument();
+ expect(screen.getByTestId('version-value')).toHaveTextContent('Not Set');
});
it('renders folder and request counts and pluralizes them', () => {
diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/StyledWrapper.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/StyledWrapper.js
index ccd67dbd008..2ea55552e47 100644
--- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/StyledWrapper.js
+++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/StyledWrapper.js
@@ -44,6 +44,10 @@ const StyledWrapper = styled.div`
white-space: nowrap;
}
+ .version-value.unset {
+ font-style: italic;
+ }
+
.version-summary {
display: flex;
align-items: center;
diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/index.js
index bac6ff49928..82c3cf630da 100644
--- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/index.js
+++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/GenerateDocumentation/index.js
@@ -13,7 +13,7 @@ import StyledWrapper from './StyledWrapper';
import CollectionVersionInfo from './CollectionVersionInfo';
import EnvironmentSelectionList from './EnvironmentSelectionList';
import { useApp } from 'providers/App';
-import { transformCollectionToSaveToExportAsFile, findCollectionByUid, areItemsLoading, sortItemsBySidebarOrder, getCollectionItemCounts } from 'utils/collections/index';
+import { transformCollectionToSaveToExportAsFile, findCollectionByUid, areItemsLoading, sortItemsBySidebarOrder, getCollectionItemCounts, getCollectionVersion } from 'utils/collections/index';
import { brunoToOpenCollection } from '@usebruno/converters';
import { sanitizeName } from 'utils/common/regex';
import { escapeHtml } from 'utils/response';
@@ -76,8 +76,7 @@ const GenerateDocumentation = ({ onClose, collectionUid }) => {
[collection]
);
- // The collection's current version (read-only here); formatted for display below.
- const currentVersion = collection?.version;
+ const currentVersion = getCollectionVersion(collection);
// Folder + request counts, computed from the collection tree (recursively).
const { folderCount, requestCount } = useMemo(
diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
index 16b7f2c0a9a..2d7221c02c6 100644
--- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
+++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
@@ -44,6 +44,7 @@ import {
responseReceived,
updateLastAction,
setCollectionSecurityConfig,
+ updateCollectionVersion as _updateCollectionVersion,
collectionAddOauth2CredentialsByUrl,
collectionClearOauth2CredentialsByUrlAndCredentialsId,
initRunRequestEvent,
@@ -313,6 +314,40 @@ export const saveCollectionRoot = (collectionUid) => (dispatch, getState) => {
});
};
+export const saveCollectionVersion = (collectionUid, version) => (dispatch, getState) => {
+ const state = getState();
+ const collection = findCollectionByUid(state.collections.collections, collectionUid);
+
+ return new Promise((resolve, reject) => {
+ if (!collection) {
+ return reject(new Error('Collection not found'));
+ }
+
+ const updatedVersion = typeof version === 'string' ? version.trim() : '';
+
+ const brunoConfigToSave = { ...(collection.brunoConfig || {}) };
+ if (updatedVersion) {
+ brunoConfigToSave.version = updatedVersion;
+ } else {
+ delete brunoConfigToSave.version;
+ }
+
+ const { ipcRenderer } = window;
+
+ ipcRenderer
+ .invoke('renderer:update-bruno-config', brunoConfigToSave, collection.pathname, collection.root)
+ .then(() => {
+ dispatch(_updateCollectionVersion({ collectionUid, version: updatedVersion }));
+ toast.success('Collection version updated');
+ })
+ .then(resolve)
+ .catch((err) => {
+ toast.error('Failed to update collection version');
+ reject(err);
+ });
+ });
+};
+
export const saveFolderRoot = (collectionUid, folderUid, silent = false) => (dispatch, getState) => {
const state = getState();
const collection = findCollectionByUid(state.collections.collections, collectionUid);
diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
index 2dc35d5cc4e..99a6c5ede95 100644
--- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
+++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
@@ -287,6 +287,24 @@ export const collectionsSlice = createSlice({
collection.securityConfig = action.payload.securityConfig;
}
},
+ updateCollectionVersion: (state, action) => {
+ const collection = findCollectionByUid(state.collections, action.payload.collectionUid);
+ if (collection) {
+ const version = action.payload.version;
+ const applyVersion = (target) => {
+ if (!target) return;
+ if (version) {
+ target.version = version;
+ } else {
+ delete target.version;
+ }
+ };
+ collection.brunoConfig = collection.brunoConfig || {};
+ applyVersion(collection.brunoConfig);
+ // Keep any unsaved brunoConfig draft in sync so a later settings-save can't wipe it.
+ applyVersion(collection.draft?.brunoConfig);
+ }
+ },
brunoConfigUpdateEvent: (state, action) => {
const { collectionUid, brunoConfig } = action.payload;
const collection = findCollectionByUid(state.collections, collectionUid);
@@ -3046,7 +3064,7 @@ export const collectionsSlice = createSlice({
// Persist the selection to the UI state snapshot
const { ipcRenderer } = window;
if (ipcRenderer) {
- const extension = collection?.brunoConfig?.version === '1' ? 'bru' : 'yml';
+ const extension = collection?.brunoConfig?.opencollection ? 'yml' : 'bru';
const environmentPath = environment?.pathname
|| (environment?.name && collection?.pathname
? path.join(collection.pathname, 'environments', `${environment.name}.${extension}`)
@@ -3889,6 +3907,7 @@ export const {
updateCollectionLoadingState,
collectionLoadedFromTree,
setCollectionSecurityConfig,
+ updateCollectionVersion,
brunoConfigUpdateEvent,
renameCollection,
removeCollection,
diff --git a/packages/bruno-app/src/utils/collections/index.js b/packages/bruno-app/src/utils/collections/index.js
index 0c10eb31bce..9baa952111f 100644
--- a/packages/bruno-app/src/utils/collections/index.js
+++ b/packages/bruno-app/src/utils/collections/index.js
@@ -1256,6 +1256,10 @@ const getPathParams = (item) => {
return pathParams;
};
+export const isOpenCollectionFormat = (collection) => Boolean(collection?.brunoConfig?.opencollection);
+
+export const getCollectionVersion = (collection) => collection?.brunoConfig?.version || '';
+
export const getTotalRequestCountInCollection = (collection) => {
let count = 0;
each(collection.items, (item) => {
diff --git a/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts b/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts
index 0bc59b372bb..7cf10046f61 100644
--- a/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts
+++ b/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts
@@ -86,14 +86,20 @@ const hasRequestDefaults = (root: BrunoCollectionRoot | undefined): boolean => {
};
export const brunoToOpenCollection = (collection: BrunoCollection): OpenCollection => {
+ const brunoConfig = collection.brunoConfig as BrunoConfig | undefined;
+
+ const collectionVersion = brunoConfig?.version;
+ const hasCollectionVersion = collectionVersion != null && collectionVersion !== '';
+
const openCollection: OpenCollection = {
opencollection: '1.0.0',
info: {
- name: collection.name || 'Untitled Collection'
+ name: collection.name || 'Untitled Collection',
+ ...(hasCollectionVersion ? { version: String(collectionVersion) } : {})
}
};
- const config = toOpenCollectionConfig(collection.brunoConfig as BrunoConfig);
+ const config = toOpenCollectionConfig(brunoConfig);
if (config) {
openCollection.config = config;
}
@@ -150,11 +156,11 @@ export const brunoToOpenCollection = (collection: BrunoCollection): OpenCollecti
presets?: BrunoPresets;
} = {};
- if ((collection.brunoConfig as BrunoConfig)?.ignore?.length) {
- brunoExtension.ignore = (collection.brunoConfig as BrunoConfig).ignore;
+ if (brunoConfig?.ignore?.length) {
+ brunoExtension.ignore = brunoConfig.ignore;
}
- const presets = (collection.brunoConfig as BrunoConfig)?.presets;
+ const presets = brunoConfig?.presets;
if (presets?.requestType || presets?.requestUrl) {
brunoExtension.presets = {};
if (presets.requestType) {
diff --git a/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts b/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts
index 2b8d0a5bcf0..9d1415f21f9 100644
--- a/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts
+++ b/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts
@@ -17,12 +17,15 @@ const fromOpenCollectionConfig = (oc: OpenCollection): BrunoConfig => {
: ['node_modules', '.git'];
const brunoConfig: BrunoConfig = {
- version: '1',
name: oc.info?.name || 'Untitled Collection',
type: 'collection',
ignore: ignoreList
};
+ if (oc.info?.version != null && oc.info.version !== '') {
+ brunoConfig.version = String(oc.info.version);
+ }
+
if (brunoExtension?.presets?.requestType || brunoExtension?.presets?.requestUrl) {
brunoConfig.presets = {};
if (brunoExtension.presets.requestType) {
diff --git a/packages/bruno-converters/src/opencollection/types.ts b/packages/bruno-converters/src/opencollection/types.ts
index 0be53a34c53..4029bcc902c 100644
--- a/packages/bruno-converters/src/opencollection/types.ts
+++ b/packages/bruno-converters/src/opencollection/types.ts
@@ -175,6 +175,8 @@ export interface BrunoPresets {
export interface BrunoConfig {
version?: string;
+ // present only for OpenCollection (yml) collections; its presence marks the format.
+ opencollection?: string;
name?: string;
type?: string;
ignore?: string[];
diff --git a/packages/bruno-converters/tests/opencollection/collection-version.spec.js b/packages/bruno-converters/tests/opencollection/collection-version.spec.js
new file mode 100644
index 00000000000..e73998aa718
--- /dev/null
+++ b/packages/bruno-converters/tests/opencollection/collection-version.spec.js
@@ -0,0 +1,45 @@
+import { describe, it, expect } from '@jest/globals';
+import { brunoToOpenCollection } from '../../src/opencollection/bruno-to-opencollection';
+import { openCollectionToBruno } from '../../src/opencollection/opencollection-to-bruno';
+
+describe('openCollectionToBruno (import): keeps the collection version', () => {
+ it('keeps the version as-is when importing', () => {
+ const { brunoConfig } = openCollectionToBruno({ opencollection: '1.0.0', info: { name: 'API', version: 'v2.3.4' } });
+ expect(brunoConfig.version).toBe('v2.3.4');
+ });
+
+ it('turns a number version into text (2 becomes "2")', () => {
+ const { brunoConfig } = openCollectionToBruno({ opencollection: '1.0.0', info: { name: 'API', version: 2 } });
+ expect(brunoConfig.version).toBe('2');
+ });
+
+ it('has no version when the imported file has none', () => {
+ const { brunoConfig } = openCollectionToBruno({ opencollection: '1.0.0', info: { name: 'API' } });
+ expect(brunoConfig.version).toBeUndefined();
+ });
+});
+
+describe('brunoToOpenCollection (export): writes the collection version', () => {
+ it('uses the agnostic version for a bru collection', () => {
+ const oc = brunoToOpenCollection({ name: 'API', brunoConfig: { version: 'v2.3.4' }, items: [] });
+ expect(oc.info.version).toBe('v2.3.4');
+ });
+
+ it('uses the agnostic version for a yml collection', () => {
+ const oc = brunoToOpenCollection({ name: 'API', brunoConfig: { opencollection: '1.0.0', version: 'v9.9' }, items: [] });
+ expect(oc.info.version).toBe('v9.9');
+ });
+
+ it('writes no version when the collection has none', () => {
+ const oc = brunoToOpenCollection({ name: 'API', brunoConfig: {}, items: [] });
+ expect(oc.info.version).toBeUndefined();
+ });
+});
+
+describe('collection version: export then import keeps it the same', () => {
+ it('keeps the same version after exporting and importing again', () => {
+ const oc = brunoToOpenCollection({ name: 'API', brunoConfig: { version: '1.2.3-beta' }, items: [] });
+ const { brunoConfig } = openCollectionToBruno(oc);
+ expect(brunoConfig.version).toBe('1.2.3-beta');
+ });
+});
diff --git a/packages/bruno-electron/src/app/collections.js b/packages/bruno-electron/src/app/collections.js
index f5c8a8080db..e1691e80467 100644
--- a/packages/bruno-electron/src/app/collections.js
+++ b/packages/bruno-electron/src/app/collections.js
@@ -19,8 +19,7 @@ const registerScratchCollectionPath = (scratchPath) => {
const configSchema = Yup.object({
name: Yup.string().max(256, 'name must be 256 characters or less').required('name is required'),
type: Yup.string().oneOf(['collection']).required('type is required'),
- // For BRU format collections
- version: Yup.string().oneOf(['1']).notRequired(),
+ version: Yup.string().notRequired(),
// For YAML format collections (opencollection)
opencollection: Yup.string().notRequired(),
// OpenAPI sync configuration (array, one entry per synced spec)
diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js
index bc2b759c60d..eecd3e0cc4c 100644
--- a/packages/bruno-electron/src/ipc/collection.js
+++ b/packages/bruno-electron/src/ipc/collection.js
@@ -76,7 +76,7 @@ const { getProcessEnvVars } = require('../store/process-env');
const { getOAuth2TokenUsingAuthorizationCode, getOAuth2TokenUsingClientCredentials, getOAuth2TokenUsingPasswordCredentials, getOAuth2TokenUsingImplicitGrant, refreshOauth2Token } = require('../utils/oauth2');
const { getCertsAndProxyConfig } = require('./network/cert-utils');
const collectionWatcher = require('../app/collection-watcher');
-const { transformBrunoConfigBeforeSave } = require('../utils/transformBrunoConfig');
+const { transformBrunoConfigBeforeSave, transformBrunoConfigAfterRead } = require('../utils/transformBrunoConfig');
const { REQUEST_TYPES } = require('../utils/constants');
const { cancelOAuth2AuthorizationRequest, isOauth2AuthorizationRequestInProgress } = require('../utils/oauth2-protocol-handler');
const { findUniqueFolderName } = require('../utils/collection-import');
@@ -214,7 +214,6 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
name: collectionName
}
};
- // For YAML collections, set opencollection instead of version
brunoConfig = {
opencollection: '1.0.0',
name: collectionName,
@@ -232,12 +231,15 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
await writeFile(path.join(dirPath, '.gitignore'), DEFAULT_GITIGNORE);
+ let persistedConfig = await getCollectionConfigFile(dirPath);
+ persistedConfig = await transformBrunoConfigAfterRead(persistedConfig, dirPath);
+
const { size, filesCount } = await getCollectionStats(dirPath);
- brunoConfig.size = size;
- brunoConfig.filesCount = filesCount;
+ persistedConfig.size = size;
+ persistedConfig.filesCount = filesCount;
- mainWindow.webContents.send('main:collection-opened', dirPath, uid, brunoConfig);
- ipcMain.emit('main:collection-opened', mainWindow, dirPath, uid, brunoConfig);
+ mainWindow.webContents.send('main:collection-opened', dirPath, uid, persistedConfig);
+ ipcMain.emit('main:collection-opened', mainWindow, dirPath, uid, persistedConfig);
} catch (error) {
return Promise.reject(error);
}
@@ -313,7 +315,7 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
brunoConfig.filesCount = filesCount;
mainWindow.webContents.send('main:collection-opened', dirPath, uid, brunoConfig);
- ipcMain.emit('main:collection-opened', mainWindow, dirPath, uid);
+ ipcMain.emit('main:collection-opened', mainWindow, dirPath, uid, brunoConfig);
}
);
@@ -1385,7 +1387,6 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
if (!brunoConfig) {
brunoConfig = {
- version: '1',
name: collection.name,
type: 'collection',
ignore: ['node_modules', '.git']
@@ -1416,7 +1417,11 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
const collectionContent = await stringifyCollection(coll.root, brunoConfig, { format });
await writeFile(path.join(collectionPath, 'opencollection.yml'), collectionContent);
} else if (format === 'bru') {
- const stringifiedBrunoConfig = await stringifyJson(brunoConfig);
+ const bruJsonConfig = { ...brunoConfig, version: '1' };
+ if (brunoConfig.version) {
+ bruJsonConfig.collectionVersion = brunoConfig.version;
+ }
+ const stringifiedBrunoConfig = await stringifyJson(bruJsonConfig);
await writeFile(path.join(collectionPath, 'bruno.json'), stringifiedBrunoConfig);
const collectionContent = await stringifyCollection(coll.root, brunoConfig, { format });
@@ -1692,7 +1697,22 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
const content = await stringifyJson(transformedBrunoConfig);
await writeFile(brunoConfigPath, content);
} else if (format === 'yml') {
- const content = await stringifyCollection(collectionRoot, transformedBrunoConfig, { format });
+ // opencollection.yml holds both config AND the collection root. If the caller
+ // didn't supply a root (e.g. a config-only update before the tree finished
+ // loading), recover it from disk so request defaults/docs/scripts aren't wiped.
+ let rootToWrite = collectionRoot;
+ if (!rootToWrite) {
+ const ocYmlPath = path.join(collectionPath, 'opencollection.yml');
+ if (fs.existsSync(ocYmlPath)) {
+ try {
+ const existing = fs.readFileSync(ocYmlPath, 'utf8');
+ rootToWrite = parseCollection(existing, { format }).collectionRoot;
+ } catch (e) {
+ rootToWrite = collectionRoot;
+ }
+ }
+ }
+ const content = await stringifyCollection(rootToWrite, transformedBrunoConfig, { format });
await writeFile(path.join(collectionPath, 'opencollection.yml'), content);
} else {
throw new Error(`Invalid collection format: ${format}`);
@@ -2623,6 +2643,7 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
}
const uid = generateUidBasedOnHash(finalCollectionPath);
+ brunoConfig = await transformBrunoConfigAfterRead(brunoConfig, finalCollectionPath);
const { size, filesCount } = await getCollectionStats(finalCollectionPath);
brunoConfig.size = size;
brunoConfig.filesCount = filesCount;
@@ -2667,8 +2688,13 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
}
const ymlBrunoConfig = { ...brunoConfig };
- delete ymlBrunoConfig.version;
+ delete ymlBrunoConfig.version; // drop the bru format marker
ymlBrunoConfig.opencollection = '1.0.0';
+ // Carry the user-facing version: bru's collectionVersion becomes yml's info.version.
+ if (ymlBrunoConfig.collectionVersion) {
+ ymlBrunoConfig.version = ymlBrunoConfig.collectionVersion;
+ }
+ delete ymlBrunoConfig.collectionVersion;
const ocYmlPath = path.join(collectionPathname, 'opencollection.yml');
const ymlCollectionContent = stringifyCollection(collectionRoot, ymlBrunoConfig, { format: 'yml' });
diff --git a/packages/bruno-electron/src/utils/collection-import.js b/packages/bruno-electron/src/utils/collection-import.js
index 4d541d60f07..2246dfd78cc 100644
--- a/packages/bruno-electron/src/utils/collection-import.js
+++ b/packages/bruno-electron/src/utils/collection-import.js
@@ -87,7 +87,6 @@ async function importCollection(collection, collectionLocation, mainWindow, uniq
if (!brunoConfig) {
brunoConfig = {
- version: '1',
name: collection.name,
type: 'collection',
ignore: ['node_modules', '.git']
@@ -107,10 +106,17 @@ async function importCollection(collection, collectionLocation, mainWindow, uniq
let brunoConfig = getBrunoJsonConfig(collection);
if (format === 'yml') {
+ brunoConfig.opencollection = '1.0.0';
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);
+ const bruJsonConfig = { ...brunoConfig, version: '1' };
+ if (brunoConfig.version) {
+ bruJsonConfig.collectionVersion = brunoConfig.version;
+ } else {
+ delete bruJsonConfig.collectionVersion;
+ }
+ const stringifiedBrunoConfig = await stringifyJson(bruJsonConfig);
await writeFile(path.join(collectionPath, 'bruno.json'), stringifiedBrunoConfig);
const collectionContent = await stringifyCollection(collection.root, brunoConfig, { format });
diff --git a/packages/bruno-electron/src/utils/transformBrunoConfig.js b/packages/bruno-electron/src/utils/transformBrunoConfig.js
index 60b59fd7f75..37b639a4568 100644
--- a/packages/bruno-electron/src/utils/transformBrunoConfig.js
+++ b/packages/bruno-electron/src/utils/transformBrunoConfig.js
@@ -3,6 +3,16 @@ const { isFile, isDirectory } = require('./filesystem');
const { transformProxyConfig } = require('@usebruno/requests');
function transformBrunoConfigBeforeSave(brunoConfig) {
+ if (brunoConfig && !brunoConfig.opencollection) {
+ const userVersion = brunoConfig.version;
+ brunoConfig.version = '1'; // bru schema marker
+ if (userVersion) {
+ brunoConfig.collectionVersion = userVersion;
+ } else {
+ delete brunoConfig.collectionVersion;
+ }
+ }
+
// remove exists from importPaths and protoFiles
if (brunoConfig.protobuf?.importPaths) {
brunoConfig.protobuf.importPaths = brunoConfig.protobuf.importPaths.map((importPath) => {
@@ -33,6 +43,15 @@ function transformBrunoConfigBeforeSave(brunoConfig) {
}
async function transformBrunoConfigAfterRead(brunoConfig, collectionPathname) {
+ if (brunoConfig && !brunoConfig.opencollection) {
+ if (brunoConfig.collectionVersion) {
+ brunoConfig.version = brunoConfig.collectionVersion;
+ } else {
+ delete brunoConfig.version;
+ }
+ delete brunoConfig.collectionVersion;
+ }
+
// add exists to importPaths and protoFiles by checking actual file/directory existence
if (brunoConfig.protobuf?.importPaths) {
brunoConfig.protobuf.importPaths = await Promise.all(brunoConfig.protobuf.importPaths.map(async (importPath) => {
diff --git a/packages/bruno-filestore/src/formats/yml/parseCollection.spec.ts b/packages/bruno-filestore/src/formats/yml/parseCollection.spec.ts
index 93c169be5e1..826dba04ac9 100644
--- a/packages/bruno-filestore/src/formats/yml/parseCollection.spec.ts
+++ b/packages/bruno-filestore/src/formats/yml/parseCollection.spec.ts
@@ -51,3 +51,20 @@ request:
expect(reqVars[5]).toMatchObject({ name: 'cfg', value: 'not-json', dataType: 'object' });
});
});
+
+describe('parseCollection — reading the collection version', () => {
+ it('reads the version from the file as text', () => {
+ const { brunoConfig } = parseCollection('opencollection: "1.0.0"\ninfo:\n name: c\n version: v1.0.0\n');
+ expect(brunoConfig.version).toBe('v1.0.0');
+ });
+
+ it('turns a number version into text (2 becomes "2")', () => {
+ const { brunoConfig } = parseCollection('opencollection: "1.0.0"\ninfo:\n name: c\n version: 2\n');
+ expect(brunoConfig.version).toBe('2');
+ });
+
+ it('has no version when the file does not have one', () => {
+ const { brunoConfig } = parseCollection('opencollection: "1.0.0"\ninfo:\n name: c\n');
+ expect(brunoConfig.version).toBeUndefined();
+ });
+});
diff --git a/packages/bruno-filestore/src/formats/yml/parseCollection.ts b/packages/bruno-filestore/src/formats/yml/parseCollection.ts
index ecb57bbf24b..da3789fc513 100644
--- a/packages/bruno-filestore/src/formats/yml/parseCollection.ts
+++ b/packages/bruno-filestore/src/formats/yml/parseCollection.ts
@@ -26,6 +26,10 @@ const parseCollection = (ymlString: string): ParsedCollection => {
ignore: []
};
+ if (oc.info?.version != null && oc.info.version !== '') {
+ brunoConfig.version = ensureString(oc.info.version, '');
+ }
+
const brunoExtension = (oc.extensions as any)?.bruno;
if (brunoExtension?.ignore && Array.isArray(brunoExtension.ignore)) {
brunoConfig.ignore = brunoExtension.ignore;
diff --git a/packages/bruno-filestore/src/formats/yml/stringifyCollection.spec.ts b/packages/bruno-filestore/src/formats/yml/stringifyCollection.spec.ts
index fddb8985bbd..f6f1608dcc8 100644
--- a/packages/bruno-filestore/src/formats/yml/stringifyCollection.spec.ts
+++ b/packages/bruno-filestore/src/formats/yml/stringifyCollection.spec.ts
@@ -47,3 +47,31 @@ describe('stringifyCollection — typed request.variables', () => {
expect(reqVars[4].dataType).toBeUndefined();
});
});
+
+describe('stringifyCollection — writing the collection version', () => {
+ const baseRoot = {
+ meta: null,
+ request: { headers: [], auth: { mode: 'none' }, script: { req: null, res: null }, tests: null, vars: { req: [], res: [] } },
+ docs: null
+ } as any;
+
+ it('writes the version as-is and reads back the same value', () => {
+ const yml = stringifyCollection(baseRoot, { name: 'c', version: '2' });
+ expect(yml).toMatch(/version:\s*['"]?2['"]?/);
+ expect(parseCollection(yml).brunoConfig.version).toBe('2');
+ });
+
+ it('writes no version when the collection has none', () => {
+ const yml = stringifyCollection(baseRoot, { name: 'c' });
+ expect(parseCollection(yml).brunoConfig.version).toBeUndefined();
+ });
+
+ it('accepts any version text — there is no check on the format', () => {
+ // The version is free-form: users can set whatever they like. Each of these should be
+ // saved and read back exactly the same, without changing the format or rejecting it.
+ ['v1.0.0', '2', '1.2.3-beta', '2024.01.15', 'release-2024-Q3', 'anything-goes'].forEach((version) => {
+ const yml = stringifyCollection(baseRoot, { name: 'c', version });
+ expect(parseCollection(yml).brunoConfig.version).toBe(version);
+ });
+ });
+});
diff --git a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts
index d006510d433..a313e93f3dc 100644
--- a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts
+++ b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts
@@ -73,6 +73,10 @@ const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
name: brunoConfig.name || 'Untitled Collection'
};
+ if (brunoConfig.version != null && brunoConfig.version !== '') {
+ oc.info.version = String(brunoConfig.version);
+ }
+
// collection config
if (hasCollectionConfig(brunoConfig)) {
oc.config = {};
diff --git a/tests/collection/change-version-bru/change-version-bru.spec.ts b/tests/collection/change-version-bru/change-version-bru.spec.ts
new file mode 100644
index 00000000000..50abbbbb488
--- /dev/null
+++ b/tests/collection/change-version-bru/change-version-bru.spec.ts
@@ -0,0 +1,63 @@
+import fs from 'fs';
+import path from 'path';
+import { test, expect } from '../../../playwright';
+import { closeAllCollections, openCollectionSettings, selectCollectionPaneTab } from '../../utils/page';
+
+const COLLECTION_NAME = 'BruVersionTest';
+
+test.describe('Change Collection Version (bru collection)', () => {
+ test.afterEach(async ({ page }) => {
+ await closeAllCollections(page);
+ });
+
+ test('a bru collection with no version shows "Not Set", and saving writes it to bruno.json', async ({
+ pageWithUserData: page,
+ collectionFixturePath
+ }) => {
+ const collectionPath = collectionFixturePath!;
+ const brunoJsonPath = path.join(collectionPath, 'bruno.json');
+
+ await test.step('the collection has no version yet (only the internal "1" marker)', async () => {
+ const config = JSON.parse(fs.readFileSync(brunoJsonPath, 'utf-8'));
+ expect(config.collectionVersion).toBeUndefined();
+ expect(config.version).toBe('1'); // the format marker is untouched
+ });
+
+ await test.step('the overview shows the version as "Not Set"', async () => {
+ await openCollectionSettings(page, COLLECTION_NAME);
+ await selectCollectionPaneTab(page, 'overview');
+ await expect(page.getByTestId('info-version-value')).toHaveText('Not Set');
+ });
+
+ await test.step('a new version can be set in the popup', async () => {
+ await page.getByTestId('info-version-change').click();
+ await expect(page.getByTestId('change-version-current')).toHaveText('Not Set');
+ await expect(page.getByTestId('change-version-input')).toHaveValue('');
+
+ await page.getByTestId('change-version-input').fill('v2.3.4');
+ await page.getByTestId('change-version-submit-btn').click();
+ await expect(page.getByText('Collection version updated')).toBeVisible();
+ });
+
+ await test.step('the screen shows the new version and bruno.json now has it (the "1" marker stays)', async () => {
+ await expect(page.getByTestId('info-version-value')).toHaveText('v2.3.4');
+
+ await expect
+ .poll(async () => JSON.parse(fs.readFileSync(brunoJsonPath, 'utf-8')), { timeout: 5000 })
+ .toMatchObject({ version: '1', collectionVersion: 'v2.3.4' });
+ });
+ });
+
+ test('limits the version input at 50 characters', async ({ pageWithUserData: page }) => {
+ await openCollectionSettings(page, COLLECTION_NAME);
+ await selectCollectionPaneTab(page, 'overview');
+ await page.getByTestId('info-version-change').click();
+
+ const input = page.getByTestId('change-version-input');
+ await expect(input).toHaveAttribute('maxlength', '50');
+
+ await input.fill('');
+ await input.pressSequentially('9'.repeat(55));
+ await expect(input).toHaveValue('9'.repeat(50));
+ });
+});
diff --git a/tests/collection/change-version-bru/fixtures/collection/bruno.json b/tests/collection/change-version-bru/fixtures/collection/bruno.json
new file mode 100644
index 00000000000..225d3b4cbaa
--- /dev/null
+++ b/tests/collection/change-version-bru/fixtures/collection/bruno.json
@@ -0,0 +1,5 @@
+{
+ "version": "1",
+ "name": "BruVersionTest",
+ "type": "collection"
+}
diff --git a/tests/collection/change-version-bru/init-user-data/preferences.json b/tests/collection/change-version-bru/init-user-data/preferences.json
new file mode 100644
index 00000000000..ec5499c273e
--- /dev/null
+++ b/tests/collection/change-version-bru/init-user-data/preferences.json
@@ -0,0 +1,3 @@
+{
+ "lastOpenedCollections": ["{{collectionPath}}"]
+}
diff --git a/tests/collection/change-version/change-version.spec.ts b/tests/collection/change-version/change-version.spec.ts
new file mode 100644
index 00000000000..6bfe4c12016
--- /dev/null
+++ b/tests/collection/change-version/change-version.spec.ts
@@ -0,0 +1,60 @@
+import fs from 'fs';
+import path from 'path';
+import { test, expect } from '../../../playwright';
+import { closeAllCollections, openCollectionSettings, selectCollectionPaneTab } from '../../utils/page';
+
+const COLLECTION_NAME = 'VersionEditTest';
+
+test.describe('Change Collection Version (yml collection)', () => {
+ test.afterEach(async ({ page }) => {
+ await closeAllCollections(page);
+ });
+
+ test('changing the version updates the yml file and the screen', async ({
+ pageWithUserData: page,
+ collectionFixturePath
+ }) => {
+ const collectionPath = collectionFixturePath!;
+ const ymlPath = path.join(collectionPath, 'opencollection.yml');
+
+ await test.step('the collection starts at version 1.0.0 on disk', async () => {
+ expect(fs.readFileSync(ymlPath, 'utf-8')).toMatch(/version:\s*["']?1\.0\.0["']?/);
+ });
+
+ await test.step('open the collection overview and read the current version', async () => {
+ await openCollectionSettings(page, COLLECTION_NAME);
+ await selectCollectionPaneTab(page, 'overview');
+ await expect(page.getByTestId('info-version-value')).toHaveText('1.0.0');
+ });
+
+ await test.step('open the Change Collection Version modal', async () => {
+ await page.getByTestId('info-version-change').click();
+ await expect(page.getByTestId('change-version-current')).toHaveText('1.0.0');
+ await expect(page.getByTestId('change-version-input')).toHaveValue('1.0.0');
+ });
+
+ await test.step('the Update button stays off until the version is changed', async () => {
+ const submit = page.getByTestId('change-version-submit-btn');
+ await expect(submit).toBeDisabled();
+ await page.getByTestId('change-version-input').fill('2.0.0');
+ await expect(submit).toBeEnabled();
+ });
+
+ await test.step('the preview shows the old version changing to the new one', async () => {
+ const preview = page.getByTestId('change-version-preview');
+ await expect(preview).toContainText('info.version');
+ await expect(preview.locator('.old')).toHaveText('1.0.0');
+ await expect(preview.locator('.new')).toHaveText('2.0.0');
+ });
+
+ await test.step('saving updates both the file on disk and the screen', async () => {
+ await page.getByTestId('change-version-submit-btn').click();
+ await expect(page.getByText('Collection version updated')).toBeVisible();
+ await expect(page.getByTestId('info-version-value')).toHaveText('2.0.0');
+
+ await expect
+ .poll(async () => fs.readFileSync(ymlPath, 'utf-8'), { timeout: 5000 })
+ .toMatch(/version:\s*["']?2\.0\.0["']?/);
+ });
+ });
+});
diff --git a/tests/collection/change-version/fixtures/collection/opencollection.yml b/tests/collection/change-version/fixtures/collection/opencollection.yml
new file mode 100644
index 00000000000..3173cff5f2a
--- /dev/null
+++ b/tests/collection/change-version/fixtures/collection/opencollection.yml
@@ -0,0 +1,4 @@
+opencollection: "1.0.0"
+info:
+ name: VersionEditTest
+ version: 1.0.0
diff --git a/tests/collection/change-version/init-user-data/preferences.json b/tests/collection/change-version/init-user-data/preferences.json
new file mode 100644
index 00000000000..e8528c5e91e
--- /dev/null
+++ b/tests/collection/change-version/init-user-data/preferences.json
@@ -0,0 +1,10 @@
+{
+ "maximized": false,
+ "lastOpenedCollections": ["{{collectionPath}}"],
+ "preferences": {
+ "onboarding": {
+ "hasLaunchedBefore": true,
+ "hasSeenWelcomeModal": true
+ }
+ }
+}
diff --git a/tests/collection/create/create-collection.spec.ts b/tests/collection/create/create-collection.spec.ts
index 0dc68ed16ea..72cdfae05fa 100644
--- a/tests/collection/create/create-collection.spec.ts
+++ b/tests/collection/create/create-collection.spec.ts
@@ -1,5 +1,5 @@
import { test, expect } from '../../../playwright';
-import { closeAllCollections, createCollection, createRequest } from '../../utils/page';
+import { closeAllCollections, createCollection, createRequest, openCollectionSettings, selectCollectionPaneTab } from '../../utils/page';
test.describe('Create collection', () => {
test.afterEach(async ({ page }) => {
@@ -76,4 +76,13 @@ test.describe('Create collection', () => {
// Verify the response
await expect(page.getByRole('main')).toContainText('200 OK');
});
+
+ test('a newly created collection has no version set (shows "Not Set")', async ({ page, createTmpDir }) => {
+ const collectionName = 'versioned-collection';
+ await createCollection(page, collectionName, await createTmpDir(collectionName));
+
+ await openCollectionSettings(page, collectionName);
+ await selectCollectionPaneTab(page, 'overview');
+ await expect(page.getByTestId('info-version-value')).toHaveText('Not Set');
+ });
});
diff --git a/tests/collection/generate-docs/fixtures/collection/bruno.json b/tests/collection/generate-docs/fixtures/collection/bruno.json
index 6d5f1edfb2e..35709f5c98e 100644
--- a/tests/collection/generate-docs/fixtures/collection/bruno.json
+++ b/tests/collection/generate-docs/fixtures/collection/bruno.json
@@ -1,5 +1,6 @@
{
"version": "1",
+ "collectionVersion": "2.5",
"name": "GenerateDocsOrder",
"type": "collection"
}
diff --git a/tests/collection/generate-docs/generate-docs.spec.ts b/tests/collection/generate-docs/generate-docs.spec.ts
index 308ee66e78a..956f7778bf7 100644
--- a/tests/collection/generate-docs/generate-docs.spec.ts
+++ b/tests/collection/generate-docs/generate-docs.spec.ts
@@ -164,7 +164,7 @@ test.describe('Generate Documentation', () => {
await expect(modal).toBeHidden();
});
- test('shows the collection name alongside the raw collection version', async ({
+ test('shows the current collection version verbatim, consistent with the settings page', async ({
pageWithUserData: page
}) => {
const locators = buildCommonLocators(page);
@@ -178,8 +178,8 @@ test.describe('Generate Documentation', () => {
await expect(locators.generateDocs.collectionName()).toHaveText(COLLECTION_NAME);
- // The version is shown exactly as the collection sets it.
- await expect(locators.generateDocs.versionValue()).toHaveText('Version: 1');
+ // The user-facing collection version (bruno.json `collectionVersion`), not the schema `version`.
+ await expect(locators.generateDocs.versionValue()).toHaveText('Version: 2.5');
// The fixture has 2 folders (Zoo, Aviary) and 5 requests (Lion, Bear, Parrot,
// ReqAlpha, ReqBeta), counted recursively across the whole tree.
diff --git a/tests/collection/migrate-to-yml/fixtures/collection/bruno.json b/tests/collection/migrate-to-yml/fixtures/collection/bruno.json
index ae83c17ca72..51ea9994a57 100644
--- a/tests/collection/migrate-to-yml/fixtures/collection/bruno.json
+++ b/tests/collection/migrate-to-yml/fixtures/collection/bruno.json
@@ -2,6 +2,7 @@
"version": "1",
"name": "migration-test",
"type": "collection",
+ "collectionVersion": "v9.9.9",
"ignore": [
"node_modules",
".git"
diff --git a/tests/collection/migrate-to-yml/migrate-to-yml.spec.ts b/tests/collection/migrate-to-yml/migrate-to-yml.spec.ts
index 6abec54e0b8..4c4a54715d1 100644
--- a/tests/collection/migrate-to-yml/migrate-to-yml.spec.ts
+++ b/tests/collection/migrate-to-yml/migrate-to-yml.spec.ts
@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
+import jsyaml from 'js-yaml';
import { test, expect } from '../../../playwright';
import { closeAllCollections, openCollection, selectEnvironment, sendRequestAndWaitForResponse } from '../../utils/page';
@@ -81,6 +82,9 @@ test.describe('Migrate collection from bru to yml format', () => {
const ocContent = fs.readFileSync(path.join(collectionPath, 'opencollection.yml'), 'utf8');
expect(ocContent).toContain('opencollection');
expect(ocContent).toContain('migration-test');
+
+ const oc = jsyaml.load(ocContent) as { info?: { version?: string } };
+ expect(oc.info?.version).toBe('v9.9.9');
});
await test.step('Verify request yml files preserve data', async () => {