test: cover the Connect option's not-yet-available state

The dialog test caught the new option immediately, which is what it is for.
Updated for five backends, plus checks specific to Connect: it must be offered,
disabled, labelled so the reason is visible rather than just greyed out, carry
no credential field while unusable, and point at the free equivalent that works
today.

connect is left out of the per-type field-swap loop on purpose — a disabled
option cannot be selected, which is the behaviour we want and is asserted
directly instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
librelad 2026-08-28 12:27:30 +01:00
parent 99e81e9ab8
commit 7b0cf0bbba

View File

@ -89,6 +89,21 @@ read -r -d '' DRIVE <<'JS'
}
}
// Connect is offered but cannot be picked until the service exists. The
// option must be disabled AND say why — an option that is merely greyed out
// with no explanation reads as something broken.
{
const opt = [...type.options].find(o => o.value === 'connect');
out.connectPresent = !!opt;
out.connectDisabled = opt ? opt.disabled : null;
out.connectLabel = opt ? opt.text : null;
type.value = 'connect'; type.dispatchEvent(new Event('change'));
await wait(150);
const panel = document.querySelector('[data-bk-group="connect"]');
out.connectPanel = panel ? panel.innerText.replace(/\s+/g, ' ') : '';
out.connectHasToken = !!document.getElementById('bk-cn-token');
}
// Each type shows only its own fields.
out.swap = {};
for (const want of ['sftp','s3','b2','local']) {
@ -134,21 +149,32 @@ fi
echo "--- the dialog opens, styled ---"
chk "dialog open" "$(jq -r .dialogOpen <<< "$OUT")" "true"
chk "type enhanced" "$(jq -r .typeEnhanced <<< "$OUT")" "true"
chk "all four backends" "$(jq -r '.typeOptions | join(",")' <<< "$OUT")" "local,sftp,s3,b2"
chk "every backend offered" "$(jq -r '.typeOptions | join(",")' <<< "$OUT")" "local,sftp,s3,b2,connect"
chk "labels styled" "$(jq -r .labelsStyled <<< "$OUT")" "true"
chk "opens on local" "$(jq -r '.groupsAtOpen | join(",")' <<< "$OUT")" "local"
chk "add button is styled" "$(jq -r .addButtonStyled <<< "$OUT")" "true"
echo "--- the dropdown is reachable, not just enhanced ---"
chk "popup opens" "$(jq -r .popupOpens <<< "$OUT")" "true"
chk "four options" "$(jq -r .popupOptions <<< "$OUT")" "4"
chk "five options" "$(jq -r .popupOptions <<< "$OUT")" "5"
chk "popup above modal" "$(jq -r 'if .popupZ > .modalZ then "true" else "false" end' <<< "$OUT")" "true"
chk "popup is on top" "$(jq -r .popupOnTop <<< "$OUT")" "true"
chk "picking applies" "$(jq -r .pickedValue <<< "$OUT")" "sftp"
chk "button label" "$(jq -r .pickedLabel <<< "$OUT")" "SFTP"
chk "fields followed" "$(jq -r '.pickedGroups | join(",")' <<< "$OUT")" "sftp"
echo "--- Connect is offered, and honest about not being ready ---"
chk "offered" "$(jq -r .connectPresent <<< "$OUT")" "true"
chk "cannot be picked" "$(jq -r .connectDisabled <<< "$OUT")" "true"
chk "label says so" "$(jq -r '.connectLabel | test("not available") ' <<< "$OUT")" "true"
chk "no credential field" "$(jq -r .connectHasToken <<< "$OUT")" "false"
chk "points at the free equivalent" \
"$(jq -r '.connectPanel | test("SFTP and S3")' <<< "$OUT")" "true"
echo "--- each type shows only its own fields ---"
# connect is deliberately absent: its option is disabled while the service does
# not exist, and a disabled option cannot be selected — which is the behaviour we
# want, and is asserted directly above rather than through this loop.
for ty in local sftp s3 b2; do
chk "$ty" "$(jq -r --arg t "$ty" '.swap[$t] | join(",")' <<< "$OUT")" "$ty"
done