diff --git a/scripts/dev/lp-backup-dialog-test b/scripts/dev/lp-backup-dialog-test index 35aacd0..b7ee99e 100755 --- a/scripts/dev/lp-backup-dialog-test +++ b/scripts/dev/lp-backup-dialog-test @@ -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