fix: resolve merge test regressions — openSession connect POST and cycleViewMode mock
This commit is contained in:
@@ -1254,14 +1254,12 @@ async function openSession(name, opts = {}) {
|
||||
// Always spawn ttyd for this session — ensures correct session after service restart or page restore
|
||||
var _sourceUrl = opts.sourceUrl || '';
|
||||
try {
|
||||
if (!opts.skipConnect) {
|
||||
if (_sourceUrl) {
|
||||
var remoteConnectUrl = _sourceUrl.replace(/\/+$/, '') + '/api/sessions/' + encodeURIComponent(name) + '/connect';
|
||||
await fetch(remoteConnectUrl, { method: 'POST', credentials: 'include' });
|
||||
} else {
|
||||
await api('POST', '/api/sessions/' + encodeURIComponent(name) + '/connect');
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
showToast(err.message || 'Connection failed');
|
||||
return closeSession();
|
||||
|
||||
@@ -3317,7 +3317,7 @@ test('openSession always POSTs to connect even when skipConnect option is passed
|
||||
const origQS = globalThis.document.querySelector;
|
||||
const origSetTimeout = globalThis.setTimeout;
|
||||
globalThis.fetch = async (url, opts) => { fetchCalls.push({ url, opts }); return { ok: true }; };
|
||||
globalThis.document.getElementById = () => ({ textContent: '', style: {}, classList: { remove: () => {}, add: () => {} } });
|
||||
globalThis.document.getElementById = () => ({ textContent: '', style: { removeProperty: () => {} }, classList: { remove: () => {}, add: () => {} } });
|
||||
globalThis.document.querySelector = () => null;
|
||||
globalThis.setTimeout = () => {};
|
||||
globalThis.window._openTerminal = () => {};
|
||||
|
||||
Reference in New Issue
Block a user