@@ -677,12 +677,40 @@ def test_autostart_retention_prompt_supports_link_button_variant():
677677 }
678678
679679
680+ def _rule_bodies (source : str , selector : str ) -> list [str ]:
681+ pattern = re .compile (re .escape (selector ) + r"[^{]*\{(?P<body>[^}]*)\}" , re .S )
682+ bodies = [m .group ("body" ) for m in pattern .finditer (source )]
683+ assert bodies , f"selector not found in common_dialogs.js: { selector } "
684+ return bodies
685+
686+
687+ def _assert_in_any (bodies : list [str ], prop : str , selector : str ) -> None :
688+ assert any (prop in b for b in bodies ), (
689+ f"property `{ prop } ` not declared under `{ selector } `"
690+ )
691+
692+
680693@pytest .mark .unit
681694def test_autostart_retention_button_style_contract_is_scoped ():
682695 source = COMMON_DIALOGS_PATH .read_text (encoding = "utf-8" )
683696
684- assert ".modal-dialog-autostart-retention .modal-btn-link" in source
685- assert "flex-wrap: wrap;" in source
686- assert "padding: 22px 0 0;" in source
687- assert "padding: 38px 0 34px;" in source
688- assert "translateY(-2px)" in source
697+ header_sel = ".modal-dialog-autostart-retention .modal-header"
698+ header = _rule_bodies (source , header_sel )
699+ _assert_in_any (header , "padding: 22px 0 0;" , header_sel )
700+
701+ footer_sel = ".modal-dialog-autostart-retention .modal-footer"
702+ footer = _rule_bodies (source , footer_sel )
703+ _assert_in_any (footer , "flex-wrap: wrap;" , footer_sel )
704+ _assert_in_any (footer , "padding: 38px 0 34px;" , footer_sel )
705+
706+ link_sel = ".modal-dialog-autostart-retention .modal-btn-link"
707+ link = _rule_bodies (source , link_sel )
708+ _assert_in_any (link , "position: absolute;" , link_sel )
709+ _assert_in_any (link , "right: 0;" , link_sel )
710+ _assert_in_any (link , "bottom: 0;" , link_sel )
711+
712+ hover_sel = (
713+ ".modal-dialog-autostart-retention .modal-btn:not(.modal-btn-link):hover"
714+ )
715+ hover = _rule_bodies (source , hover_sel )
716+ _assert_in_any (hover , "translateY(-2px)" , hover_sel )
0 commit comments