mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-30 16:14:06 +00:00
fix(snapshot): folder nested script tab interactivity and tests (#8225)
* fix(snapshot): folder script interactivity * fix: add tests for collection scripts
This commit is contained in:
@@ -22,7 +22,9 @@ const Script = ({ collection, folder }) => {
|
||||
const responseScript = folder.draft ? get(folder, 'draft.request.script.res', '') : get(folder, 'root.request.script.res', '');
|
||||
|
||||
const tabs = useSelector((state) => state.tabs.tabs);
|
||||
const focusedTab = find(tabs, (t) => t.uid === folder.uid);
|
||||
const focusedTab = find(tabs, (tab) => tab.type === 'folder-settings' && (tab.uid === folder.uid || tab.folderUid === folder.uid))
|
||||
|| find(tabs, (tab) => tab.type === 'folder-settings' && tab.pathname === folder.pathname);
|
||||
const tabUid = focusedTab?.uid || folder.uid;
|
||||
const scriptPaneTab = focusedTab?.scriptPaneTab;
|
||||
|
||||
// Default to post-response if pre-request script is empty (only when scriptPaneTab is null/undefined)
|
||||
@@ -34,7 +36,7 @@ const Script = ({ collection, folder }) => {
|
||||
const activeTab = scriptPaneTab || getDefaultTab();
|
||||
|
||||
const setActiveTab = (tab) => {
|
||||
dispatch(updateScriptPaneTab({ uid: folder.uid, scriptPaneTab: tab }));
|
||||
dispatch(updateScriptPaneTab({ uid: tabUid, scriptPaneTab: tab }));
|
||||
};
|
||||
|
||||
const { displayedTheme } = useTheme();
|
||||
|
||||
@@ -52,8 +52,9 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
|
||||
|| tab.type === 'graphql-request'
|
||||
|| tab.type === 'grpc-request'
|
||||
|| tab.type === 'ws-request';
|
||||
const shouldSyncUid = isRequestType || tab.type === 'folder-settings';
|
||||
|
||||
if (!isRequestType || !tab.pathname || !item?.uid || tab.uid === item.uid) {
|
||||
if (!shouldSyncUid || !tab.pathname || !item?.uid || tab.uid === item.uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -446,6 +446,9 @@ export const tabsSlice = createSlice({
|
||||
const tab = find(state.tabs, (t) => t.uid === oldUid);
|
||||
if (tab) {
|
||||
tab.uid = newUid;
|
||||
if (tab.type === 'folder-settings') {
|
||||
tab.folderUid = newUid;
|
||||
}
|
||||
if (state.activeTabUid === oldUid) {
|
||||
state.activeTabUid = newUid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user