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:
Sid
2026-06-12 19:13:34 +05:30
committed by lohit
parent a09ddedf90
commit f05bb9c49d
9 changed files with 343 additions and 34 deletions

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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;
}