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
|
// Always spawn ttyd for this session — ensures correct session after service restart or page restore
|
||||||
var _sourceUrl = opts.sourceUrl || '';
|
var _sourceUrl = opts.sourceUrl || '';
|
||||||
try {
|
try {
|
||||||
if (!opts.skipConnect) {
|
|
||||||
if (_sourceUrl) {
|
if (_sourceUrl) {
|
||||||
var remoteConnectUrl = _sourceUrl.replace(/\/+$/, '') + '/api/sessions/' + encodeURIComponent(name) + '/connect';
|
var remoteConnectUrl = _sourceUrl.replace(/\/+$/, '') + '/api/sessions/' + encodeURIComponent(name) + '/connect';
|
||||||
await fetch(remoteConnectUrl, { method: 'POST', credentials: 'include' });
|
await fetch(remoteConnectUrl, { method: 'POST', credentials: 'include' });
|
||||||
} else {
|
} else {
|
||||||
await api('POST', '/api/sessions/' + encodeURIComponent(name) + '/connect');
|
await api('POST', '/api/sessions/' + encodeURIComponent(name) + '/connect');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showToast(err.message || 'Connection failed');
|
showToast(err.message || 'Connection failed');
|
||||||
return closeSession();
|
return closeSession();
|
||||||
|
|||||||
@@ -3317,7 +3317,7 @@ test('openSession always POSTs to connect even when skipConnect option is passed
|
|||||||
const origQS = globalThis.document.querySelector;
|
const origQS = globalThis.document.querySelector;
|
||||||
const origSetTimeout = globalThis.setTimeout;
|
const origSetTimeout = globalThis.setTimeout;
|
||||||
globalThis.fetch = async (url, opts) => { fetchCalls.push({ url, opts }); return { ok: true }; };
|
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.document.querySelector = () => null;
|
||||||
globalThis.setTimeout = () => {};
|
globalThis.setTimeout = () => {};
|
||||||
globalThis.window._openTerminal = () => {};
|
globalThis.window._openTerminal = () => {};
|
||||||
|
|||||||
Reference in New Issue
Block a user