import { Rule , Diagnostic } from "@siteimprove/alfa-act" ; import { Element } from "@siteimprove/alfa-dom" ; import { Predicate } from "@siteimprove/alfa-predicate" ; import { Ok , Err } from "@siteimprove/alfa-result" ; import { Style } from "@siteimprove/alfa-style" ; import { Page } from "@siteimprove/alfa-web" ; import { expectation } from "../common/expectation" ; import { hasRole , isVisible } from "../common/predicate" ; import { Scope } from "../tags" ; const { isElement } = Element ; const { and } = Predicate ; export default Rule . Atomic . of < Page , Element > ( { uri : "https://alfa.siteimprove.com/rules/sia-r72" , tags : [ Scope . Component ] , evaluate ( { device , document } ) { return { applicability ( ) { return document . descendants ( { flattened : true , nested : true , } ) . filter ( isElement ) . filter ( and ( hasRole ( device , "paragraph" ) , isVisible ( device ) ) ) ; } , expectations ( target ) { const { value : transform } = Style . from ( target , device ) . computed ( "text-transform" ) ; return { 1 : expectation ( transform . value !== "uppercase" , ( ) => Outcomes . IsNotUppercased , ( ) => Outcomes . IsUppercased ) , } ; } , } ; } , } ) ; export namespace Outcomes { export const IsNotUppercased = Ok . of ( Diagnostic . of ( `The text of the paragraph is not uppercased` ) ) ; export const IsUppercased = Err . of ( Diagnostic . of ( `The text of the paragraph is uppercased` ) ) ; }