Harden Galaxy version picker

This commit is contained in:
AngusBell97
2026-09-13 21:40:03 -05:00
committed by firestar5683
parent 4d585dbcbc
commit 9677a3bd78
5 changed files with 17 additions and 3 deletions
@@ -36,7 +36,7 @@ export const GalaxySelect = {
if (this.disabled && this.open) this.close()
},
async show(event) {
if (this.disabled) return
if (this.disabled || this.open) return
this.sync()
this.open = true
await this.$nextTick()
@@ -73,7 +73,7 @@ export const VersionHistoryPicker = {
this.expanded = expanded
},
async show() {
if (this.disabled) return
if (this.disabled || this.open) return
const selectedDay = this.groups.find(group => group.commits.some(commit => commit.sha === this.value))
if (selectedDay) this.expanded[selectedDay.key] = true
this.open = true
@@ -168,6 +168,14 @@ test('GalaxySelect reads optional option descriptions without adding them to col
assert.equal(instance.label, 'Dom')
})
test('GalaxySelect ignores a second open request while its menu is open', async () => {
const context = vm.createContext({document: {getElementById() {}}})
vm.runInContext(fs.readFileSync(js + 'components/GalaxySelect.js', 'utf8').replace('export const GalaxySelect =', 'globalThis.component ='), context)
const instance = {...context.component.data(), open: true, disabled: false, sync() { throw new Error('menu reopened') }}
await context.component.methods.show.call(instance)
assert.equal(instance.open, true)
})
test('unavailable branch and navigation values cannot become install targets', async () => {
const {instance, calls, confirmations} = fixture()
for (const branch of ['other:', '', 'deleted-branch']) instance.selectTargetBranch(branch)
@@ -41,6 +41,13 @@ test('newly appended days stay collapsed while the current day keeps its state',
assert.equal(instance.expanded['2026-09-10'], true)
assert.equal(instance.expanded['2026-09-09'], false)
})
test('history picker ignores a second open request while its dialog is open', async () => {
const instance = {disabled: false, open: true}
await context.picker.methods.show.call(instance)
assert.equal(instance.open, true)
})
test('selection emits only an available exact SHA and disabled selection emits nothing', () => {
assert.ok(context.picker)
const calls = []
@@ -9,7 +9,6 @@ import inspect
from contextlib import contextmanager
from contextvars import ContextVar
from datetime import datetime, timezone
import hashlib
import json
import os
from pathlib import Path