972 lines
51 KiB
Python
972 lines
51 KiB
Python
"""Tests for annual health-check form content and client-side behavior."""
|
|
|
|
from pathlib import Path
|
|
import re
|
|
import unittest
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def read_static(name):
|
|
"""Return the text of one static asset."""
|
|
return (ROOT / "static" / name).read_text(encoding="utf-8")
|
|
|
|
|
|
class HealthCheckFormTests(unittest.TestCase):
|
|
def test_form_includes_privacy_notice_and_review_without_save_claim(self):
|
|
html = read_static("health-check.html")
|
|
self.assertIn('<html lang="en">', html)
|
|
self.assertIn("Never enter seed phrases", html)
|
|
self.assertIn('id="health-check-form"', html)
|
|
self.assertIn("Review check", html)
|
|
self.assertIn("No data from this form has been stored", html)
|
|
|
|
def test_form_selects_one_key_and_one_wallet_software(self):
|
|
html = read_static("health-check.html")
|
|
self.assertIn('id="key-select"', html)
|
|
self.assertIn('name="wallet_software"', html)
|
|
self.assertIn('id="next-check-preview"', html)
|
|
self.assertNotIn("next_check_due", html)
|
|
self.assertIn('name="contact_info_verified"', html)
|
|
|
|
def test_the_form_sections_follow_the_agreed_order(self):
|
|
html = read_static("health-check.html")
|
|
eyebrows = re.findall(r'<p class="eyebrow">([^<]+)</p>', html)
|
|
|
|
# The page heading comes first, and the form is renumbered with
|
|
# 04 / Standards gone (section 24.3). The blocked-keys note adds no
|
|
# section of its own (section 26.1).
|
|
self.assertEqual(
|
|
eyebrows,
|
|
[
|
|
"Annual security check",
|
|
"01 / Schedule",
|
|
"02 / Key",
|
|
"03 / Compatibility",
|
|
"04 / External research",
|
|
"05 / Contact confirmation",
|
|
"06 / Notes",
|
|
"Review",
|
|
],
|
|
)
|
|
|
|
def test_form_script_covers_the_checklist_fields_and_status_values(self):
|
|
script = read_static("health-check.js")
|
|
for field in (
|
|
"hardware_works",
|
|
"address_path",
|
|
"seed_backup_verified",
|
|
):
|
|
self.assertIn(field, script)
|
|
for status in ("SECURE", "PATCHED", "VULNERABLE", "COMPROMISED"):
|
|
self.assertIn(status, script)
|
|
self.assertIn("formatLocalDate", script)
|
|
# The summary lists the results that need follow-up. The list of the
|
|
# checks that were still awaiting an answer was removed, because the form
|
|
# itself already shows what is missing (section 32.2 point 11).
|
|
self.assertIn("Results requiring follow-up", script)
|
|
self.assertNotIn("Needs assessment", script)
|
|
|
|
def test_the_bip327_and_slip39_function_is_gone(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
history = read_static("history.js")
|
|
# The whole function is removed (section 24.2), so neither the form, the
|
|
# script, nor the history view mentions it any more.
|
|
self.assertNotIn("BIP327", html)
|
|
self.assertNotIn("SLIP39", html)
|
|
self.assertNotIn("tool-checks", html)
|
|
self.assertNotIn("toolChecks", script)
|
|
self.assertNotIn("standardsStatuses", script)
|
|
self.assertNotIn("tool_checks", script)
|
|
self.assertNotIn("BIP327", history)
|
|
self.assertNotIn("tool_checks", history)
|
|
|
|
def test_form_script_no_longer_uses_the_removed_fields(self):
|
|
script = read_static("health-check.js")
|
|
for removed in ("seed_backup_status", "address_verified", "derivation_height"):
|
|
self.assertNotIn(removed, script)
|
|
|
|
def test_the_wallet_software_choices_come_from_the_settings_and_the_cloud_keys(self):
|
|
script = read_static("health-check.js")
|
|
html = read_static("health-check.html")
|
|
self.assertIn("walletSoftwareChoices", script)
|
|
self.assertIn("renderWalletSoftwareOptions", script)
|
|
# The settings list plus the name of every configured cloud key
|
|
# (section 25.4).
|
|
self.assertIn("/api/settings", script)
|
|
self.assertIn("walletSoftwareList", script)
|
|
self.assertIn('key.type === "cloud"', script)
|
|
self.assertIn("key.name", script)
|
|
# The old fixed list and the built-in Sparrow constant are gone from both
|
|
# the markup and the script.
|
|
self.assertNotIn('option value="Nunchuk"', html)
|
|
self.assertNotIn("KEY_PRODUCTS", script)
|
|
self.assertNotIn("SPARROW_SOFTWARE", script)
|
|
|
|
def test_form_script_uses_the_configured_key_name(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn("expectedLabels", script)
|
|
self.assertIn("key.name", script)
|
|
self.assertNotIn("keyProductFor", script)
|
|
self.assertNotIn("CLOUD_KEY_NUMBER", script)
|
|
|
|
def test_form_script_derives_from_availability(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn("/api/previous-values", script)
|
|
self.assertIn("derivedSummary", script)
|
|
self.assertIn("Derived from availability and the address path", script)
|
|
self.assertIn('key.type === "cloud"', script)
|
|
# The section 20 carry-forward of a third provider is gone (section 23.3).
|
|
self.assertNotIn("carriedSecurity", script)
|
|
self.assertNotIn("Carried forward from the last saved check", script)
|
|
# The cloud key no longer renders the cloud results as form fields, and
|
|
# the derived values themselves are gone (section 25.6).
|
|
self.assertNotIn('makeField("Cloud health check"', script)
|
|
self.assertNotIn('makeField("Provider operational"', script)
|
|
self.assertNotIn("cloud_health_status", script)
|
|
self.assertNotIn("cloud_provider_operational", script)
|
|
|
|
def test_form_prefills_the_saved_values_as_input_values(self):
|
|
script = read_static("health-check.js")
|
|
# A previous value is a real input value, not an HTML placeholder, so an
|
|
# untouched field is saved as it stands (section 23.1).
|
|
self.assertIn("previousText", script)
|
|
self.assertIn("input.value = value", script)
|
|
self.assertNotIn("input.placeholder", script)
|
|
self.assertIn('previousText(previous, "firmware_version")', script)
|
|
# The address path is prefilled from the key profile, because that is the
|
|
# stored path it is compared with (section 25.1).
|
|
self.assertIn("key.address_path", script)
|
|
self.assertIn("updateSoftwareVersionValue", script)
|
|
self.assertIn("softwareVersionInput.value = reusable", script)
|
|
self.assertIn("previous.wallet_software === walletSoftwareSelect.value", script)
|
|
|
|
def test_form_requires_an_explicit_compatibility_status(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
self.assertIn('id="software-compatibility"', html)
|
|
self.assertIn('<option value="">Select status</option>', html)
|
|
self.assertIn('name="software_compatibility_status" required', html)
|
|
self.assertNotIn('value="NOT_ASSESSED"', html)
|
|
# The hidden control carries the derived value for the cloud key and is
|
|
# not required for a key that was not available (sections 20 and 22).
|
|
self.assertIn("softwareCompatibilitySelect.required", script)
|
|
self.assertIn("compatibilityDerived", script)
|
|
self.assertIn('softwareCompatibilitySelect.value = "OK"', script)
|
|
|
|
def test_form_requires_hardware_works_and_the_contact_confirmation(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
# Hardware works is a required choice for an available hardware key
|
|
# (section 24.1), so the placeholder is not an answer.
|
|
self.assertIn("hardwareWorksOptions", script)
|
|
self.assertIn('["", "Select status"]', script)
|
|
self.assertIn('makeSelect(hardwareWorksOptions, "hardware_works")', script)
|
|
self.assertNotIn("booleanOptions", script)
|
|
# The required flag is cleared when the key was not available, because a
|
|
# hidden required control would block the submission. The address path is
|
|
# no longer a field of its own (section 25.1).
|
|
self.assertIn('["hardware_works", "seed_backup_verified"]', script)
|
|
self.assertNotIn("address_path_verified", script)
|
|
# The confirmation is required in the markup, with the same placeholder,
|
|
# and it has no "not assessed" value.
|
|
self.assertIn('name="contact_info_verified" required', html)
|
|
self.assertNotIn("Not assessed", html)
|
|
|
|
def test_form_asks_about_the_selected_key_holder_and_reminds_about_updates(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
self.assertIn("this key holder's contact details are current?", html)
|
|
self.assertIn('<option value="Confirmed current">', html)
|
|
self.assertIn('<option value="Needs external update">', html)
|
|
self.assertIn('id="contact-reminder"', html)
|
|
self.assertIn("syncContactReminder", script)
|
|
self.assertIn("contactReminder.hidden", script)
|
|
self.assertIn('CONTACT_NEEDS_UPDATE = "Needs external update"', script)
|
|
# Only the status is recorded, and the old flag is gone (section 23.1).
|
|
self.assertIn('statusValue(data, "contact_info_verified")', script)
|
|
|
|
def test_form_can_hide_the_compatibility_grid_for_the_cloud_key(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
self.assertIn('id="software-section"', html)
|
|
self.assertIn('id="software-grid"', html)
|
|
self.assertIn("softwareGrid.hidden = isCloud", script)
|
|
|
|
def test_form_uses_the_english_status_values(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn("NOT_ASSESSED", script)
|
|
self.assertNotIn("IKKJE_VURDERT", script)
|
|
# The seed backup result keeps OK and PROBLEM.
|
|
self.assertIn('["OK", "OK"]', script)
|
|
self.assertIn('["PROBLEM", "Problem"]', script)
|
|
|
|
def test_form_requires_availability_without_a_not_assessed_value(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn("availabilityOptions", script)
|
|
self.assertIn('["", "Select availability"]', script)
|
|
self.assertIn('makeSelect(availabilityOptions, "available")', script)
|
|
self.assertIn("available.required = true", script)
|
|
|
|
def test_form_hides_the_rest_of_the_check_for_an_unavailable_key(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn("keyIsUnavailable", script)
|
|
self.assertIn("syncUncheckableState", script)
|
|
self.assertIn("softwareSection.hidden", script)
|
|
self.assertIn("securityChecksSection.hidden", script)
|
|
self.assertIn("walletSoftwareSelect.required", script)
|
|
self.assertIn("UNAVAILABLE_MESSAGE", script)
|
|
# The hidden parts render an empty state instead of required fields, so a
|
|
# hidden required control can never block the submission.
|
|
self.assertIn("emptyState(UNAVAILABLE_MESSAGE)", script)
|
|
|
|
def test_form_sends_nothing_else_for_an_unavailable_key(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn("uncheckable ? null : data.get", script)
|
|
self.assertIn("uncheckable ? [] : expectedLabels", script)
|
|
self.assertIn('uncheckable\\n ? "NOT_ASSESSED"', script)
|
|
|
|
def test_form_records_the_address_path_and_warns_when_it_does_not_match(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
# The user records the path only, and the browser compares it with the
|
|
# stored one before it submits (section 25.1).
|
|
self.assertIn('makeField(\\n "Address path"', script)
|
|
self.assertIn('[name="address_path"]', script)
|
|
self.assertIn("addressPathMismatch", script)
|
|
self.assertIn("key.address_path", script)
|
|
self.assertIn('id="address-path-warning"', html)
|
|
self.assertIn("does not match the one stored for this key", html)
|
|
self.assertIn("Check it against your BSMS", html)
|
|
self.assertIn('id="address-path-confirmed"', html)
|
|
self.assertIn("Record this check anyway", html)
|
|
self.assertIn("addressPathWarning.hidden", script)
|
|
self.assertIn("addressPathConfirmed.required = mismatch", script)
|
|
# The choice to save anyway is marked in the review summary.
|
|
self.assertIn("Recorded as a key that could not be checked", script)
|
|
self.assertIn("Address path verified: PROBLEM", script)
|
|
# The old verification field is gone from the form.
|
|
self.assertNotIn('"address_path_verified"', script)
|
|
self.assertNotIn("Address path verified", html)
|
|
|
|
def test_form_hides_the_address_path_for_an_unavailable_key(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn("syncAddressPathState", script)
|
|
# The path is not asked for when the key was not available (section 22).
|
|
self.assertIn("field.hidden = keyIsUnavailable()", script)
|
|
self.assertIn("#key-details", script)
|
|
self.assertIn("details.hidden = keyIsUncheckable()", script)
|
|
|
|
def test_form_records_the_software_version_for_every_key(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
# The label lost its "(if used)" wording (section 25.5).
|
|
self.assertIn("<span>Software version</span>", html)
|
|
self.assertNotIn("(if used)", html)
|
|
# The version stays visible while the grid with the software and the
|
|
# compatibility result is hidden for a cloud key (section 25.5).
|
|
self.assertIn('id="software-version"', html)
|
|
self.assertIn("updateSoftwareVersionValue", script)
|
|
self.assertNotIn('key.type === "hardware"\\n && previous', script)
|
|
# The help next to the field is written by the script, because its wording
|
|
# depends on the selected key (section 32.3).
|
|
self.assertIn('id="software-help"', html)
|
|
self.assertIn("softwareHelp.textContent", script)
|
|
|
|
def test_form_marks_the_keys_that_an_open_alert_blocks(self):
|
|
html = read_static("health-check.html")
|
|
script = read_static("health-check.js")
|
|
# The form names the alert that stands in the way, the action that closes
|
|
# it, and the keys that are still free (section 26.1).
|
|
self.assertIn('id="blocked-keys-note"', html)
|
|
self.assertIn('id="blocked-keys-list"', html)
|
|
self.assertIn("Open the dashboard to close the alerts", html)
|
|
# The note is the one place that explains the blocking, so the form does
|
|
# not repeat it in a help line of its own (section 32.3).
|
|
self.assertNotIn("A blocked key is marked in the list", html)
|
|
self.assertIn("/api/alerts", script)
|
|
self.assertIn("blockingAlerts", script)
|
|
self.assertIn("blockedKeyIds", script)
|
|
self.assertIn("renderBlockedKeysNote", script)
|
|
self.assertIn("blocked by an open alert", script)
|
|
self.assertIn("option.disabled = true", script)
|
|
self.assertIn("Close it with:", script)
|
|
self.assertIn("Keys that can still be checked:", script)
|
|
self.assertIn("No key can be checked until an alert is closed.", script)
|
|
# The action that closes an alert has its own wording (section 26.4).
|
|
self.assertIn("ACTION_LABELS", script)
|
|
self.assertIn('rotate: "Rotate key"', script)
|
|
self.assertIn('replace_hardware: "Replace hardware"', script)
|
|
self.assertIn('ignore: "Ignore alert"', script)
|
|
self.assertIn('contact_updated: "Contact details updated"', script)
|
|
# The server refuses the submission as well, so the form and the API agree.
|
|
self.assertIn("open alert and cannot be checked until", script)
|
|
|
|
def test_dashboard_shows_every_alert_with_its_check_date(self):
|
|
script = read_static("app.js")
|
|
styles = read_static("styles.css")
|
|
self.assertIn("alert.check_id", script)
|
|
self.assertIn("alert.checked_at", script)
|
|
self.assertIn(".alert-origin", styles)
|
|
|
|
def test_dashboard_key_card_shows_an_open_alert(self):
|
|
script = read_static("app.js")
|
|
styles = read_static("styles.css")
|
|
# A key with an open alert shows a message instead of its ordinary status
|
|
# (section 26.5).
|
|
self.assertIn("alertsForKey", script)
|
|
self.assertIn('status.className = "status status-alert"', script)
|
|
self.assertIn("Needs action", script)
|
|
self.assertIn("cannot be checked until", script)
|
|
self.assertIn("createKeyAlertNote", script)
|
|
self.assertIn("Close it with:", script)
|
|
self.assertIn("#alerts-list", script)
|
|
self.assertIn("Open the alert list", script)
|
|
self.assertIn(".status-alert", styles)
|
|
self.assertIn(".key-alert-note", styles)
|
|
self.assertIn(".key-alert-message", styles)
|
|
self.assertIn(".key-alert-detail", styles)
|
|
|
|
def test_dashboard_key_card_shows_the_number_the_type_and_the_next_date(self):
|
|
script = read_static("app.js")
|
|
styles = read_static("styles.css")
|
|
# The number and the type share the top line, so the card has no line of
|
|
# its own for the type (section 32.2 point 6).
|
|
self.assertIn("keyTypeLabel", script)
|
|
self.assertIn('`${String(entry.key_number).padStart(2, "0")} · ${keyTypeLabel(entry.type)}`', script)
|
|
self.assertNotIn("Hardware key", script)
|
|
self.assertNotIn("Cloud key", script)
|
|
# The path stands alone and in italics, without a label
|
|
# (section 32.2 point 7).
|
|
self.assertIn('path.className = "key-path";', script)
|
|
self.assertIn("path.textContent = entry.address_path;", script)
|
|
self.assertNotIn("Address path:", script)
|
|
self.assertIn(".key-path { font-style: italic; }", styles)
|
|
# The model is shown under the name with no label, and a model that only
|
|
# repeats the key's own name is left out (section 32.2 point 8).
|
|
self.assertIn("sameLabel(entry.model, entry.name)", script)
|
|
self.assertNotIn('entry.type === "cloud" ? "Service" : "Model"', script)
|
|
# Only the next due date stays; the last checked date is gone
|
|
# (section 32.2 point 9).
|
|
self.assertNotIn('appendDateRow(dates, "Last checked"', script)
|
|
self.assertIn('appendDateRow(dates, "Next check due", entry.next_check_due)', script)
|
|
self.assertIn("card.append(dates);", script)
|
|
|
|
def test_dashboard_key_card_keeps_the_next_date_with_an_open_alert(self):
|
|
script = read_static("app.js")
|
|
# The alert note comes in addition to the date, not instead of it, so a
|
|
# key whose only alert is the informational contact one keeps its next
|
|
# due date (sections 27 and 32.2 point 9).
|
|
dates_index = script.index('appendDateRow(dates, "Next check due"')
|
|
note_index = script.index("card.append(createKeyAlertNote(entry, open))")
|
|
self.assertLess(dates_index, note_index)
|
|
|
|
def test_dashboard_offers_the_closing_action_of_every_alert(self):
|
|
script = read_static("app.js")
|
|
# Every alert names the actions that close it, and each action has its own
|
|
# button text and confirmation step (section 26.4).
|
|
self.assertIn("alert.actions", script)
|
|
self.assertIn("alert.key_id", script)
|
|
self.assertIn("ACTION_LABELS", script)
|
|
self.assertIn('rotate: "Rotate key"', script)
|
|
self.assertIn('replace_hardware: "Replace hardware"', script)
|
|
self.assertIn('remove_software: "Remove software"', script)
|
|
self.assertIn('ignore: "Ignore alert"', script)
|
|
self.assertIn('contact_updated: "Contact details updated"', script)
|
|
self.assertIn("ACTION_CONFIRMATIONS", script)
|
|
self.assertIn("I have replaced the hardware wallet and restored the same seed on the new device.", script)
|
|
self.assertIn("I have updated the contact details in my external documentation.", script)
|
|
self.assertIn("createConfirmControl", script)
|
|
self.assertIn("/settings?rotate=", script)
|
|
self.assertIn("/api/alerts/acknowledge", script)
|
|
self.assertIn("acknowledgeAlert", script)
|
|
# The removed generic acknowledgement is gone.
|
|
self.assertNotIn("Close alert", script)
|
|
self.assertNotIn("Confirm close", script)
|
|
self.assertNotIn("Reason for closing this alert", script)
|
|
self.assertNotIn("acknowledge: ", script)
|
|
|
|
def test_dashboard_removes_the_failing_software_from_the_settings(self):
|
|
script = read_static("app.js")
|
|
# Removing the failing software closes a software alert, and the alert
|
|
# points at the right settings entry (section 26.7).
|
|
self.assertIn("/api/settings", script)
|
|
self.assertIn("walletSoftware", script)
|
|
self.assertIn("createRemoveSoftwareControl", script)
|
|
self.assertIn("removeSoftware", script)
|
|
self.assertIn("/api/settings/wallet-software", script)
|
|
self.assertIn("from the settings", script)
|
|
self.assertIn("Open the settings", script)
|
|
self.assertIn("walletSoftware.length > 1", script)
|
|
|
|
def test_the_settings_link_has_one_wording(self):
|
|
# The dashboard, the locked setup page and the top bar all point at the
|
|
# same page, so the two call-to-action links use the same words
|
|
# (section 32.3).
|
|
self.assertIn('link.textContent = "Open the settings"', read_static("app.js"))
|
|
self.assertIn('link.textContent = "Open the settings"', read_static("setup.js"))
|
|
|
|
def test_dashboard_sends_to_the_key_setup_when_it_is_missing(self):
|
|
script = read_static("app.js")
|
|
self.assertIn("redirectWhenSetupIsMissing", script)
|
|
self.assertIn('/api/setup', script)
|
|
self.assertIn('window.location.assign("/setup")', script)
|
|
|
|
def test_the_dashboard_heading_names_the_configured_setup(self):
|
|
html = read_static("index.html")
|
|
script = read_static("app.js")
|
|
# The heading under the title is built from the stored threshold and key
|
|
# count, and the line in the markup is the fallback until they arrive
|
|
# (section 32.2 point 3). The setup card and the description line that
|
|
# stood beside it are gone (points 4 and 5).
|
|
self.assertIn('id="setup-shape"', html)
|
|
self.assertIn("Bitcoin Health Monitor for a Multisig Setup.", html)
|
|
self.assertIn("renderSetupHeading", script)
|
|
self.assertIn("Bitcoin Health Monitor for a ${setup.threshold}-of-${setup.key_count} Multisig Setup.", script)
|
|
self.assertNotIn("An overview of your multisig setup and annual checks.", html)
|
|
self.assertNotIn("setup-card", html)
|
|
self.assertNotIn("setup-title", html)
|
|
self.assertNotIn("setup-description", html)
|
|
self.assertNotIn("setupTitle", script)
|
|
self.assertNotIn("setupDescription", script)
|
|
self.assertNotIn("renderSetupShape", script)
|
|
|
|
def test_the_dashboard_has_no_setup_block_and_no_key_count(self):
|
|
# The key cards stand under the dashboard heading now, with no section of
|
|
# their own, and the counter that stood beside the section heading is
|
|
# gone with it (section 32.7 point 2).
|
|
html = read_static("index.html")
|
|
script = read_static("app.js")
|
|
|
|
self.assertIn('id="key-list"', html)
|
|
self.assertIn('aria-live="polite"', html)
|
|
# The grid sits inside the page heading, right after the setup line.
|
|
self.assertLess(html.index('id="setup-shape"'), html.index('id="key-list"'))
|
|
for gone in ("Configured setup", "Your keys", 'id="key-count"', 'aria-labelledby="keys-title"'):
|
|
self.assertNotIn(gone, html, gone)
|
|
# No script points at an element that no longer exists.
|
|
self.assertNotIn("keyCount", script)
|
|
self.assertNotIn("#key-count", script)
|
|
|
|
def test_the_dashboard_has_no_next_check_card_and_no_history_block(self):
|
|
# The earliest due date reads inside the Attention card, and the history,
|
|
# the export and the note that explains it live on their own page
|
|
# (section 32.7 points 3 and 5, and follow-up points 1 and 4). The
|
|
# dashboard note that carried the same sentence is gone as well
|
|
# (follow-up point 5).
|
|
#
|
|
# The removed card is named by its own markup, not by the bare phrase: a
|
|
# bare substring also catches a comment, which is how this test failed
|
|
# once already (see the traps in ai-note.md).
|
|
html = read_static("index.html")
|
|
script = read_static("app.js")
|
|
|
|
self.assertIn('id="overdue-title"', html)
|
|
self.assertIn('id="overdue-detail"', html)
|
|
for gone in (
|
|
'id="next-check-title"',
|
|
'id="next-check-detail"',
|
|
'<p class="eyebrow">Next check</p>',
|
|
"history-card",
|
|
"Previous checks",
|
|
"Open history",
|
|
"Download CSV",
|
|
"workflow-note",
|
|
):
|
|
self.assertNotIn(gone, html, gone)
|
|
for gone in ("nextCheckTitle", "nextCheckDetail", "#next-check-title", "#next-check-detail"):
|
|
self.assertNotIn(gone, script, gone)
|
|
|
|
def test_the_summary_reports_the_earliest_next_check(self):
|
|
# The Attention card lists the overdue keys when something is overdue,
|
|
# and otherwise names the earliest due date, because the Next check card
|
|
# is gone (section 32.7 point 3).
|
|
script = read_static("app.js")
|
|
|
|
self.assertIn('"Nothing overdue"', script)
|
|
self.assertIn('"1 key overdue"', script)
|
|
self.assertIn(
|
|
'`Key ${entry.key_number}: ${entry.name} (due ${entry.next_check_due})`',
|
|
script,
|
|
)
|
|
self.assertIn(
|
|
'`Earliest next check ${earliest.next_check_due}, for Key ${earliest.key_number}: ${earliest.name}.`',
|
|
script,
|
|
)
|
|
self.assertIn(
|
|
'"No key has a next check date yet. Save a health check to schedule one."',
|
|
script,
|
|
)
|
|
# The two lines that stood there before are gone.
|
|
self.assertNotIn("No key has passed its next check date.", script)
|
|
self.assertNotIn("Earliest next check, for key", script)
|
|
|
|
def test_an_empty_alert_list_carries_no_placeholder(self):
|
|
# The count beside the heading is what says there is nothing to follow
|
|
# up, so an empty list renders no text of its own (section 32.7 point 4).
|
|
script = read_static("app.js")
|
|
html = read_static("index.html")
|
|
|
|
self.assertIn("alertsList.replaceChildren();", script)
|
|
self.assertIn('alertCount.textContent = "No alerts";', script)
|
|
self.assertNotIn("No alerts. No saved check has a result that needs follow-up.", script)
|
|
# The placeholder in the markup and the failure branch stay, so a page
|
|
# that is still loading and one that failed still say so.
|
|
self.assertIn("Loading alerts…", html)
|
|
self.assertIn('"Alerts could not be loaded. Please reload the page."', script)
|
|
self.assertIn('addEventListener("offline"', script)
|
|
|
|
def test_the_top_bar_menu_lists_the_dashboard_and_the_pages(self):
|
|
# The menu replaced the lone Sign out button on every application page.
|
|
# The dashboard comes first, then the three pages, then a separator, then
|
|
# Sign out (section 32.7 point 1 and follow-up point 2).
|
|
script = read_static("session.js")
|
|
html = read_static("index.html")
|
|
|
|
for item in (
|
|
'{ label: "Dashboard", href: "/" },',
|
|
'{ label: "Start health check", href: "/health-check" },',
|
|
'{ label: "Settings", href: "/settings" },',
|
|
'{ label: "History", href: "/history" },',
|
|
):
|
|
self.assertIn(item, script)
|
|
# The destinations are links and Sign out is a button, after a separator.
|
|
self.assertIn('separator.className = "menu-separator";', script)
|
|
self.assertIn('signOutButton.type = "button";', script)
|
|
self.assertIn('signOutButton.textContent = "Sign out";', script)
|
|
self.assertIn('window.fetch("/api/logout"', script)
|
|
# The panel is hidden until it is opened, and it is wired to the button.
|
|
self.assertIn("panel.hidden = true;", script)
|
|
self.assertIn('button.setAttribute("aria-haspopup", "true");', script)
|
|
self.assertIn('button.setAttribute("aria-expanded", "false");', script)
|
|
self.assertIn('button.setAttribute("aria-controls", MENU_PANEL_ID);', script)
|
|
# It closes on Escape, on a click outside it, and after a choice.
|
|
self.assertIn('event.key === "Escape"', script)
|
|
self.assertIn("menu.contains(event.target)", script)
|
|
self.assertIn("setMenuOpen(menu, false)", script)
|
|
# The dashboard markup carries no navigation link of its own, and the
|
|
# wrapper the script fills is built by the script.
|
|
self.assertNotIn("topbar-actions", html)
|
|
for gone in ("Start annual health check", 'href="/settings"', 'href="/history"', 'href="/health-check"'):
|
|
self.assertNotIn(gone, html, gone)
|
|
|
|
def test_the_menu_marks_the_page_you_are_on_and_greys_it_out(self):
|
|
# The page the user is already on is marked and greyed out, and it is not
|
|
# clickable at all: it is rendered as a span instead of a link, so the menu
|
|
# never reloads the page it is showing, and aria-current says where the
|
|
# user is (section 32.7 follow-up point 2).
|
|
script = read_static("session.js")
|
|
styles = read_static("styles.css")
|
|
|
|
self.assertIn("currentPath", script)
|
|
self.assertIn("window.location.pathname", script)
|
|
self.assertIn("currentPath() === item.href", script)
|
|
self.assertIn('document.createElement("span")', script)
|
|
self.assertIn('current.className = "menu-item menu-item-current";', script)
|
|
self.assertIn('current.setAttribute("aria-current", "page");', script)
|
|
# The stylesheet greys the current item out and leaves it out of the hover
|
|
# and focus rule, so it never lights up like a link.
|
|
self.assertIn(".menu-item-current { color: var(--line); cursor: default; }", styles)
|
|
self.assertIn(".menu-item:not(.menu-item-current):hover", styles)
|
|
|
|
def test_stylesheet_covers_the_menu(self):
|
|
styles = read_static("styles.css")
|
|
|
|
for rule in (".menu {", ".menu-button", ".menu-panel", ".menu-item", ".menu-separator"):
|
|
self.assertIn(rule, styles)
|
|
# The panel is hidden by the hidden attribute, not by an inline style, so
|
|
# the CSP needs no exception (section 32.7 point 1).
|
|
self.assertIn(".menu-panel[hidden] { display: none; }", styles)
|
|
|
|
def test_every_page_refuses_to_be_indexed(self):
|
|
# No page is meant to be found by a crawler, so each of the six carries
|
|
# the robots meta (section 32.7 point 6).
|
|
for name in (
|
|
"index.html",
|
|
"setup.html",
|
|
"settings.html",
|
|
"health-check.html",
|
|
"history.html",
|
|
"login.html",
|
|
):
|
|
self.assertIn(
|
|
'<meta name="robots" content="noindex, nofollow">',
|
|
read_static(name),
|
|
name,
|
|
)
|
|
|
|
def test_health_check_page_sends_to_the_key_setup_when_it_is_missing(self):
|
|
script = read_static("health-check.js")
|
|
self.assertIn('window.location.assign("/setup")', script)
|
|
|
|
def test_the_setup_page_asks_for_a_name_a_type_and_an_address_path(self):
|
|
html = read_static("setup.html")
|
|
script = read_static("setup.js")
|
|
self.assertIn('id="setup-form"', html)
|
|
self.assertIn("Never enter seed phrases", html)
|
|
for number in (1, 2, 3):
|
|
self.assertIn(f'name="key_{number}_name"', html)
|
|
self.assertIn(f'name="key_{number}_type"', html)
|
|
# The setup records the address path of every key (section 25.1).
|
|
self.assertIn(f'name="key_{number}_address_path"', html)
|
|
self.assertIn('<option value="hardware">Hardware</option>', html)
|
|
self.assertIn('<option value="cloud">Cloud</option>', html)
|
|
self.assertIn("KEY_COUNT = 3", script)
|
|
self.assertIn('/api/setup', script)
|
|
self.assertIn("collectSetup", script)
|
|
self.assertIn("address_path", script)
|
|
self.assertIn("_address_path", script)
|
|
# The type and the address path are locked once the setup is saved, while
|
|
# the name may be changed in the settings (sections 25.1 and 25.2).
|
|
self.assertIn("lockForm", script)
|
|
self.assertIn("/settings", script)
|
|
|
|
def test_the_settings_page_has_the_two_sections(self):
|
|
html = read_static("settings.html")
|
|
self.assertIn('<html lang="en">', html)
|
|
self.assertIn("Never enter seed phrases", html)
|
|
eyebrows = re.findall(r'<p class="eyebrow">([^<]+)</p>', html)
|
|
# The key names, the address paths and the type are changed in the
|
|
# rotation section, so the page has no separate keys section
|
|
# (section 28). The page heading is the h1 on its own, without an eyebrow
|
|
# that repeats it (section 32.3).
|
|
self.assertEqual(eyebrows, ["01 / Wallet software", "02 / Key rotation"])
|
|
self.assertIn("<h1>Settings</h1>", html)
|
|
self.assertNotIn("01 / Keys", html)
|
|
self.assertNotIn('id="keys-list"', html)
|
|
self.assertIn('id="wallet-software-list"', html)
|
|
self.assertIn('id="rotation-list"', html)
|
|
self.assertIn('id="add-software"', html)
|
|
self.assertIn('id="save-software"', html)
|
|
self.assertIn('id="save-keys"', html)
|
|
self.assertIn("Save keys", html)
|
|
|
|
def test_the_settings_page_warns_about_moving_the_funds_and_changing_the_path(self):
|
|
html = read_static("settings.html")
|
|
# Rotating a key creates a new wallet, so the funds have to be moved
|
|
# (section 25.2), and the key is a new one, so its path has to change
|
|
# (section 26.3).
|
|
self.assertIn("Rotating a key creates a new wallet", html)
|
|
self.assertIn("Move your funds from the old multisig setup to the new one", html)
|
|
self.assertIn("Do not discard the old keys", html)
|
|
self.assertIn("The address path must change", html)
|
|
self.assertIn("Every key needs its own new path", html)
|
|
self.assertIn('id="rotation-replaced"', html)
|
|
self.assertIn("I confirm that each selected key has been replaced", html)
|
|
# The unchanged-path confirmation is gone (section 26.3).
|
|
self.assertNotIn('id="rotation-path-unchanged"', html)
|
|
self.assertNotIn("address path of each selected key is unchanged", html)
|
|
# Removing an entry closes the alerts that software raised (section 26.7),
|
|
# and the two removal helps are one paragraph (section 32.3).
|
|
self.assertIn("Removing an entry also closes the alerts that software raised", html)
|
|
self.assertNotIn("Removing an entry never changes a saved check</p>", html)
|
|
self.assertIn(
|
|
"Removing an entry never changes a saved check: the software selected "
|
|
"in an earlier check stays as it was recorded. Removing an entry also "
|
|
"closes the alerts that software raised",
|
|
html,
|
|
)
|
|
|
|
def test_the_settings_script_stores_the_list_whole_and_saves_the_keys(self):
|
|
script = read_static("settings.js")
|
|
self.assertIn("/api/settings/keys", script)
|
|
self.assertIn("/api/settings/wallet-software", script)
|
|
self.assertIn("/api/keys/", script)
|
|
self.assertIn("rotate", script)
|
|
self.assertIn("wallet_software", script)
|
|
self.assertIn("collectSoftware", script)
|
|
# One action saves both the renamed keys and the rotated ones, and the
|
|
# confirmation is only asked for when something is rotated (section 28).
|
|
self.assertIn("collectKeys", script)
|
|
self.assertIn("saveKeys", script)
|
|
self.assertIn("keep_name", script)
|
|
self.assertIn("replaced", script)
|
|
self.assertIn("rotationReplaced.checked", script)
|
|
# The address path is locked as soon as the key has a saved check, and the
|
|
# name may always be changed (sections 25.1 and 25.2).
|
|
self.assertIn("has_checks", script)
|
|
self.assertIn("pathInput.disabled", script)
|
|
# A link from the dashboard pre-selects the key it points at.
|
|
self.assertIn("requestedRotation", script)
|
|
# The rotation records a new, unique address path (sections 26.2 and 26.3).
|
|
self.assertIn("rotation-path", script)
|
|
self.assertIn("rotation_path_", script)
|
|
self.assertIn("address_path: entry.address_path", script)
|
|
self.assertIn("Write the new address path of every key you mark for rotation", script)
|
|
# The name field starts on the name the key has now (section 26.3).
|
|
self.assertIn("makeTextInput(key.name, 60)", script)
|
|
# The type is only offered together with a rotation, because a type change
|
|
# means the key is a new one (section 28).
|
|
self.assertIn("rotation-type", script)
|
|
self.assertIn("makeSelect", script)
|
|
self.assertIn('["hardware", "Hardware"]', script)
|
|
self.assertIn("type: entry.type", script)
|
|
self.assertIn("typeSelect.disabled", script)
|
|
# The removed confirmation is gone.
|
|
self.assertNotIn("address_path_unchanged", script)
|
|
self.assertNotIn("rotationPathUnchanged", script)
|
|
# Removing an entry closes the alerts that software raised (section 26.7).
|
|
self.assertIn("acknowledged", script)
|
|
self.assertIn("raised by the removed software were closed", script)
|
|
|
|
def test_history_shows_a_note_when_no_security_status_was_recorded(self):
|
|
script = read_static("history.js")
|
|
self.assertIn("securityTable", script)
|
|
self.assertIn("No security statuses were recorded", script)
|
|
|
|
def test_history_shows_the_contact_status_as_text(self):
|
|
script = read_static("history.js")
|
|
self.assertIn("Contact details confirmed", script)
|
|
self.assertIn("record.contact_info_verified", script)
|
|
|
|
def test_history_shows_the_derived_address_path_result(self):
|
|
script = read_static("history.js")
|
|
# The result is derived by the server, so it is shown as a derived value
|
|
# (sections 9 and 25.1).
|
|
self.assertIn("Address path verified (derived)", script)
|
|
self.assertIn("keyCheck.address_path_verified", script)
|
|
self.assertIn("keyCheck.address_path", script)
|
|
# The removed cloud results are no longer shown (section 25.6).
|
|
self.assertNotIn("Cloud health check", script)
|
|
self.assertNotIn("Provider operational", script)
|
|
self.assertNotIn("cloud_health_status", script)
|
|
self.assertNotIn("cloud_provider_operational", script)
|
|
|
|
def test_history_shows_the_follow_up_that_was_closed(self):
|
|
script = read_static("history.js")
|
|
# Every closure is shown as a card, with the source of the alert it
|
|
# closed, the code, the action written out, and the date (section 27).
|
|
# The source has a column of its own, because it is what tells the key
|
|
# form and the software form of the same code apart (section 32.9
|
|
# point 1).
|
|
self.assertIn("Follow-up closed", script)
|
|
self.assertIn("closed_alerts", script)
|
|
self.assertIn("closedAlertsTable", script)
|
|
self.assertIn("acknowledged_at", script)
|
|
self.assertIn("No follow-up was closed on this check.", script)
|
|
self.assertIn('["Source", "Alert", "Action", "Closed"]', script)
|
|
self.assertIn("entry.source", script)
|
|
# The action labels are duplicated here, which is the existing pattern.
|
|
self.assertIn("ACTION_LABELS", script)
|
|
self.assertIn('rotate: "Rotate key"', script)
|
|
self.assertIn('replace_hardware: "Replace hardware"', script)
|
|
self.assertIn('contact_updated: "Contact details updated"', script)
|
|
|
|
def test_history_card_shows_the_key_and_a_short_status(self):
|
|
script = read_static("history.js")
|
|
# The card shows the date, the key by its number and name, and the state
|
|
# of the check as it stands now, in three steps: nothing raised, something
|
|
# still open, or everything closed (sections 32.2 point 14 and 32.9
|
|
# point 2). The next due date and the software text are gone.
|
|
self.assertIn("check.checked_at", script)
|
|
self.assertIn("keyNamesText(check)", script)
|
|
self.assertIn("check.key_names", script)
|
|
self.assertIn("followUpText(check)", script)
|
|
self.assertIn("check.needs_follow_up", script)
|
|
self.assertIn("check.follow_up_open", script)
|
|
self.assertIn('return "All OK";', script)
|
|
self.assertIn(
|
|
'return check.follow_up_open ? "Needs follow-up" : "Follow-up closed";',
|
|
script,
|
|
)
|
|
self.assertNotIn("Next check due ${check.next_check_due}", script)
|
|
self.assertNotIn("Software ${check.software_compatibility_status}", script)
|
|
self.assertNotIn("keyNumbersText", script)
|
|
|
|
def test_history_merges_the_software_and_the_hardware_lines(self):
|
|
# The wallet software and its version share one line, and so do the
|
|
# hardware model and the firmware version (section 32.1).
|
|
script = read_static("history.js")
|
|
|
|
self.assertIn("mergedLine", script)
|
|
self.assertIn(
|
|
'["Wallet software", mergedLine(record.wallet_software, record.software_version)]',
|
|
script,
|
|
)
|
|
self.assertIn("mergedLine(keyCheck.model, keyCheck.firmware_version)", script)
|
|
# The two separate lines are gone.
|
|
self.assertNotIn('["Software version", record.software_version]', script)
|
|
self.assertNotIn('["Firmware version", keyCheck.firmware_version]', script)
|
|
|
|
def test_the_pages_offer_one_way_back_to_the_dashboard(self):
|
|
# The brand mark is the way back to the dashboard, so the pages carry no
|
|
# extra "Back to dashboard" link in the top bar. The blocked-keys note
|
|
# keeps its own link, which points at the dashboard for another reason
|
|
# (sections 26.1 and 32.1).
|
|
for name in ("history.html", "settings.html", "setup.html", "health-check.html"):
|
|
self.assertNotIn("Back to dashboard", read_static(name), name)
|
|
self.assertIn(
|
|
"Open the dashboard to close the alerts", read_static("health-check.html")
|
|
)
|
|
|
|
def test_the_history_page_starts_no_check(self):
|
|
# A check is started from the dashboard, so the history page carries no
|
|
# button of its own (section 32.1).
|
|
html = read_static("history.html")
|
|
|
|
self.assertNotIn("Start annual health check", html)
|
|
self.assertIn("Saved health checks", html)
|
|
|
|
def test_the_history_page_offers_the_export_in_its_own_section(self):
|
|
# The export moved from the dashboard to the history page, and it has a
|
|
# section of its own there, after the saved-check list: a title bar, the
|
|
# button, and the line that explains what the file holds (section 32.7
|
|
# point 5 and follow-up points 1 and 4).
|
|
html = read_static("history.html")
|
|
styles = read_static("styles.css")
|
|
|
|
link = '<a class="secondary-button" href="/api/export">Download CSV</a>'
|
|
self.assertIn(link, html)
|
|
# No download attribute, so the dated filename from Content-Disposition is
|
|
# the one that wins (section 31 point 3).
|
|
self.assertNotIn("download=", html)
|
|
# The section stands after the list and before the detail section, and it
|
|
# carries a title bar of its own.
|
|
self.assertLess(html.index('id="history-list-title"'), html.index('id="export-title"'))
|
|
self.assertLess(html.index('id="export-title"'), html.index('id="history-detail"'))
|
|
self.assertLess(html.index('id="export-title"'), html.index(link))
|
|
self.assertIn('<p class="eyebrow">Export</p>', html)
|
|
self.assertIn('<h2 id="export-title">Download the report</h2>', html)
|
|
# The line that explains the file stands under the button, and the
|
|
# free-standing note the dashboard used to carry is gone with the section
|
|
# that held it (follow-up points 4 and 5).
|
|
self.assertIn(
|
|
'<p class="workflow-note">Every saved key check is exported', html
|
|
)
|
|
self.assertIn("one row per key check, as a dated CSV file.", html)
|
|
self.assertLess(html.index(link), html.index("one row per key check"))
|
|
self.assertNotIn('id="workflow-note"', html)
|
|
self.assertNotIn("Save a health check to see it in the history.", html)
|
|
# The button no longer needs the rule that gave it room inside the page
|
|
# heading, because it has a section of its own now.
|
|
self.assertNotIn(".page-heading > .secondary-button", styles)
|
|
|
|
def test_the_history_links_to_the_detail_section(self):
|
|
# Both entry points land on the detail section of the history page: the
|
|
# View link carries its anchor, and the form opens the check it has just
|
|
# saved there (section 32.7 follow-up point 3).
|
|
page = read_static("history.html")
|
|
history = read_static("history.js")
|
|
form = read_static("health-check.js")
|
|
|
|
# The anchor the two links point at is the detail section itself.
|
|
self.assertIn('id="history-detail"', page)
|
|
self.assertIn("link.href = `/history?id=${check.id}#history-detail`;", history)
|
|
self.assertIn("const target = `/history?id=${encodeURIComponent(saved.id)}#history-detail`;", form)
|
|
# The section is hidden until a check is opened, and a hidden element has
|
|
# no box to scroll to, so the page reveals it first and then moves to it.
|
|
self.assertIn("revealDetail", history)
|
|
self.assertIn(
|
|
'detailSection.scrollIntoView({ behavior: "smooth", block: "start" });',
|
|
history,
|
|
)
|
|
|
|
def test_stylesheet_makes_the_hidden_attribute_work_on_grid_containers(self):
|
|
styles = read_static("styles.css")
|
|
self.assertIn(".form-stack[hidden]", styles)
|
|
self.assertIn(".field-grid[hidden]", styles)
|
|
self.assertIn(".form-section[hidden]", styles)
|
|
|
|
def test_stylesheet_separates_the_rotation_note_from_the_list(self):
|
|
html = read_static("settings.html")
|
|
styles = read_static("styles.css")
|
|
# Only the spacing between the warning note and the rotation list changes
|
|
# (section 26.6).
|
|
self.assertIn('class="form-stack rotation-list"', html)
|
|
self.assertIn(".rotation-list { margin-top: 22px; }", styles)
|
|
|
|
def test_stylesheet_gives_the_help_line_room_before_its_block(self):
|
|
styles = read_static("styles.css")
|
|
# A help line is followed by its block with a little more air, on the
|
|
# three pages that put a block right under one (section 32.2 point 1).
|
|
self.assertIn(".field-help + .field-grid,", styles)
|
|
self.assertIn(".field-help + .form-stack { margin-top: 12px; }", styles)
|
|
# The block is a field grid on the setup page and a stack on the check
|
|
# form and the settings page, and all three put a help line above it.
|
|
for name, block in (
|
|
("setup.html", 'class="field-grid"'),
|
|
("health-check.html", 'class="form-stack"'),
|
|
("settings.html", 'class="form-stack"'),
|
|
):
|
|
html = read_static(name)
|
|
self.assertIn('<p class="field-help"', html)
|
|
self.assertIn(block, html, name)
|
|
|
|
def test_stylesheet_keeps_the_history_tables_inside_the_page(self):
|
|
styles = read_static("styles.css")
|
|
# The two history tables are a grid of 1px rules with a fixed layout and
|
|
# a word break, so a long value cannot push them out of a narrow page
|
|
# (section 32.2 point 15). The fix is CSS only, with no new script.
|
|
self.assertIn("table-layout: fixed", styles)
|
|
self.assertIn("overflow-wrap: break-word", styles)
|
|
self.assertIn(".detail-table { font-size: 11px; }", styles)
|
|
|
|
def test_stylesheet_covers_the_new_elements(self):
|
|
styles = read_static("styles.css")
|
|
for rule in (
|
|
".warning-note",
|
|
".checkbox-field",
|
|
".software-row",
|
|
".alert-actions",
|
|
".topbar-actions",
|
|
".status-alert",
|
|
".key-alert-note",
|
|
".secret-warning",
|
|
):
|
|
self.assertIn(rule, styles)
|
|
|
|
def test_stylesheet_is_the_retro_theme(self):
|
|
styles = read_static("styles.css")
|
|
# The mid-1990s look of section 32.2: the grey desktop, the navy title
|
|
# bar, the two bevels, and no shadow or gradient in the styling itself.
|
|
self.assertIn("background: #c0c0c0", styles)
|
|
self.assertIn("--title: #000080", styles)
|
|
self.assertIn("border-color: #ffffff #000000 #000000 #ffffff", styles)
|
|
self.assertIn("border-color: #808080 #ffffff #ffffff #808080", styles)
|
|
self.assertIn("outline: 1px dotted #000000", styles)
|
|
self.assertIn('"MS Sans Serif", Tahoma, Verdana, Geneva, sans-serif', styles)
|
|
# The declarations are what matter: the header comment names the shadow
|
|
# and the gradient it rules out, so the words alone prove nothing.
|
|
self.assertNotIn("box-shadow:", styles)
|
|
for function in ("linear-gradient(", "radial-gradient(", "conic-gradient("):
|
|
self.assertNotIn(function, styles)
|
|
# Every corner is square: the sheet may carry a border-radius only as an
|
|
# explicit reset to 0, which keeps a browser's own rounded button from
|
|
# showing through.
|
|
radii = re.findall(r"border-radius:\s*([^;]+);", styles)
|
|
self.assertTrue(radii)
|
|
for radius in radii:
|
|
self.assertEqual(radius.strip(), "0", radius)
|
|
|
|
def test_stylesheet_sticks_the_top_bar_to_the_top(self):
|
|
styles = read_static("styles.css")
|
|
# The bar stays in view while the page scrolls, because the page is a
|
|
# flex column with no overflow, so `position: sticky` works. It is kept
|
|
# over the page content and under the menu panel, and the depth still
|
|
# comes from the bevels alone (section 32.8 point 4).
|
|
block = re.search(r"\.topbar \{[^}]*\}", styles).group(0)
|
|
self.assertIn("position: sticky;", block)
|
|
self.assertIn("top: 0;", block)
|
|
self.assertIn("z-index: 5;", block)
|
|
# No inline style is involved, so the CSP needs no exception, and the
|
|
# panel it must not cover keeps its higher z-index.
|
|
self.assertIn(".menu-panel { position: absolute; right: 0; z-index: 10;", styles)
|
|
self.assertNotIn("box-shadow:", styles)
|
|
self.assertNotIn("linear-gradient(", styles)
|
|
|
|
def test_the_form_bounds_the_check_date_to_today(self):
|
|
script = read_static("health-check.js")
|
|
# The server refuses a check date in the future, because a check that has
|
|
# not happened yet cannot be recorded, so the date picker is bounded to
|
|
# today as well (section 32.8 point 3). The due preview is unchanged.
|
|
self.assertIn("const today = formatLocalDate(new Date());", script)
|
|
self.assertIn("checkedAt.value = today;", script)
|
|
self.assertIn("checkedAt.max = today;", script)
|
|
self.assertIn("nextCheckDate", script)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|