1+ const visitDrawerDemoWithGlassTheme = ( ) => {
2+ cy . visit ( 'http://localhost:3000/drawer-demo-nav-link' ) ;
3+ cy . viewport ( 1280 , 800 ) ;
4+ cy . document ( ) . then ( ( doc ) => {
5+ doc . documentElement . classList . add ( 'pf-v6-theme-glass' ) ;
6+ } ) ;
7+ cy . get ( 'html' ) . should ( 'have.class' , 'pf-v6-theme-glass' ) ;
8+ } ;
9+
10+ const assertGlassPlainPanel = ( testId : string , headlineSnippet : string ) => {
11+ cy . get ( `[data-testid="${ testId } "]` ) . should ( ( $el ) => {
12+ expect ( $el , testId ) . to . have . length ( 1 ) ;
13+ expect ( $el ) . to . not . have . attr ( 'hidden' ) ;
14+ expect ( $el ) . to . not . have . attr ( 'inert' ) ;
15+ expect ( $el ) . to . have . class ( 'pf-m-glass' ) ;
16+ expect ( $el ) . to . have . class ( 'pf-m-plain' ) ;
17+ expect ( $el ) . to . have . class ( 'pf-m-no-plain-on-glass' ) ;
18+ expect ( $el ) . to . contain . text ( headlineSnippet ) ;
19+ } ) ;
20+
21+ cy . get ( `[data-testid="${ testId } "]` ) . should ( ( $el ) => {
22+ const style = window . getComputedStyle ( $el [ 0 ] ) ;
23+ const bg = style . backgroundColor ;
24+ const backdrop = style . backdropFilter ;
25+
26+ const rgbaCommaAlpha = ( color : string ) : number | undefined => {
27+ if ( color === 'transparent' ) {
28+ return 0 ;
29+ }
30+ if ( ! color . startsWith ( 'rgba(' ) || ! color . endsWith ( ')' ) ) {
31+ return undefined ;
32+ }
33+ const inner = color . slice ( 'rgba(' . length , - 1 ) ;
34+ const parts = inner . split ( ',' ) . map ( ( p ) => p . trim ( ) ) ;
35+ if ( parts . length !== 4 ) {
36+ return undefined ;
37+ }
38+ return parseFloat ( parts [ 3 ] ) ;
39+ } ;
40+
41+ const rgbSlashAlpha = ( color : string ) : number | undefined => {
42+ if ( ! color . startsWith ( 'rgb(' ) ) {
43+ return undefined ;
44+ }
45+ const slash = color . indexOf ( '/' ) ;
46+ const close = color . lastIndexOf ( ')' ) ;
47+ if ( slash === - 1 || close === - 1 || slash >= close ) {
48+ return undefined ;
49+ }
50+ const a = parseFloat ( color . slice ( slash + 1 , close ) . trim ( ) ) ;
51+ return Number . isNaN ( a ) ? undefined : a ;
52+ } ;
53+
54+ const alpha = rgbaCommaAlpha ( bg ) ?? rgbSlashAlpha ( bg ) ;
55+ const hasSemiTransparentBackground = alpha !== undefined && alpha < 1 ;
56+ const hasBackdropBlur = Boolean ( backdrop && backdrop !== 'none' ) ;
57+
58+ if ( ! hasSemiTransparentBackground && ! hasBackdropBlur ) {
59+ throw new Error (
60+ `expected glass panel (semi-transparent background or backdrop-filter); got backgroundColor=${ bg } , backdropFilter=${ backdrop || '' } `
61+ ) ;
62+ }
63+ } ) ;
64+ } ;
65+
166describe ( 'Drawer Demo Test' , ( ) => {
267 afterEach ( ( ) => {
368 cy . document ( ) . then ( ( doc ) => {
@@ -9,72 +74,30 @@ describe('Drawer Demo Test', () => {
974 cy . visit ( 'http://localhost:3000/drawer-demo-nav-link' ) ;
1075 } ) ;
1176
12- it ( 'glass theme + plain + glass: panel shows glass treatment (transparent bg and/or backdrop-filter)' , ( ) => {
13- // Self-contained: do not rely on test order; other specs leave the page in various states.
14- cy . visit ( 'http://localhost:3000/drawer-demo-nav-link' ) ;
15- cy . viewport ( 1280 , 800 ) ;
77+ it ( 'glass theme + isInline drawer + plain/glass: panel shows glass treatment (transparent bg and/or backdrop-filter)' , ( ) => {
78+ visitDrawerDemoWithGlassTheme ( ) ;
1679
17- cy . document ( ) . then ( ( doc ) => {
18- doc . documentElement . classList . add ( 'pf-v6-theme-glass' ) ;
19- } ) ;
20- cy . get ( 'html' ) . should ( 'have.class' , 'pf-v6-theme-glass' ) ;
21-
22- cy . get ( '#drawer-glass-plain-combo.pf-v6-c-drawer' ) . should ( 'have.class' , 'pf-m-expanded' ) ;
23-
24- cy . get ( '[data-testid="drawer-glass-plain-panel"]' ) . should ( ( $el ) => {
25- expect ( $el , 'glass plain combo panel' ) . to . have . length ( 1 ) ;
26- expect ( $el ) . to . not . have . attr ( 'hidden' ) ;
27- expect ( $el ) . to . not . have . attr ( 'inert' ) ;
28- expect ( $el ) . to . have . class ( 'pf-m-glass' ) ;
29- expect ( $el ) . to . have . class ( 'pf-m-plain' ) ;
30- expect ( $el ) . to . have . class ( 'pf-m-no-plain-on-glass' ) ;
31- expect ( $el ) . to . contain . text ( 'Glass theme plain / no-plain-on-glass combo' ) ;
80+ cy . get ( '#drawer-glass-plain-inline.pf-v6-c-drawer' ) . should ( ( $drawer ) => {
81+ expect ( $drawer ) . to . have . length ( 1 ) ;
82+ expect ( $drawer ) . to . have . class ( 'pf-m-expanded' ) ;
83+ expect ( $drawer ) . to . have . class ( 'pf-m-inline' ) ;
84+ expect ( $drawer ) . to . not . have . class ( 'pf-m-static' ) ;
3285 } ) ;
3386
34- cy . get ( '[data-testid="drawer-glass-plain-panel"]' ) . should ( ( $el ) => {
35- const style = window . getComputedStyle ( $el [ 0 ] ) ;
36- const bg = style . backgroundColor ;
37- const backdrop = style . backdropFilter ;
38-
39- const rgbaCommaAlpha = ( color : string ) : number | undefined => {
40- if ( color === 'transparent' ) {
41- return 0 ;
42- }
43- if ( ! color . startsWith ( 'rgba(' ) || ! color . endsWith ( ')' ) ) {
44- return undefined ;
45- }
46- const inner = color . slice ( 'rgba(' . length , - 1 ) ;
47- const parts = inner . split ( ',' ) . map ( ( p ) => p . trim ( ) ) ;
48- if ( parts . length !== 4 ) {
49- return undefined ;
50- }
51- return parseFloat ( parts [ 3 ] ) ;
52- } ;
53-
54- // e.g. rgb(255 255 255 / 0.08) from getComputedStyle in some engines
55- const rgbSlashAlpha = ( color : string ) : number | undefined => {
56- if ( ! color . startsWith ( 'rgb(' ) ) {
57- return undefined ;
58- }
59- const slash = color . indexOf ( '/' ) ;
60- const close = color . lastIndexOf ( ')' ) ;
61- if ( slash === - 1 || close === - 1 || slash >= close ) {
62- return undefined ;
63- }
64- const a = parseFloat ( color . slice ( slash + 1 , close ) . trim ( ) ) ;
65- return Number . isNaN ( a ) ? undefined : a ;
66- } ;
67-
68- const alpha = rgbaCommaAlpha ( bg ) ?? rgbSlashAlpha ( bg ) ;
69- const hasSemiTransparentBackground = alpha !== undefined && alpha < 1 ;
70- const hasBackdropBlur = Boolean ( backdrop && backdrop !== 'none' ) ;
71-
72- if ( ! hasSemiTransparentBackground && ! hasBackdropBlur ) {
73- throw new Error (
74- `expected glass panel (semi-transparent background or backdrop-filter); got backgroundColor=${ bg } , backdropFilter=${ backdrop || '' } `
75- ) ;
76- }
87+ assertGlassPlainPanel ( 'drawer-glass-plain-panel-inline' , 'Glass theme plain / no-plain-on-glass combo (inline)' ) ;
88+ } ) ;
89+
90+ it ( 'glass theme + isStatic drawer + plain/glass: panel shows glass treatment (transparent bg and/or backdrop-filter)' , ( ) => {
91+ visitDrawerDemoWithGlassTheme ( ) ;
92+
93+ cy . get ( '#drawer-glass-plain-static.pf-v6-c-drawer' ) . should ( ( $drawer ) => {
94+ expect ( $drawer ) . to . have . length ( 1 ) ;
95+ expect ( $drawer ) . to . have . class ( 'pf-m-expanded' ) ;
96+ expect ( $drawer ) . to . have . class ( 'pf-m-static' ) ;
97+ expect ( $drawer ) . to . not . have . class ( 'pf-m-inline' ) ;
7798 } ) ;
99+
100+ assertGlassPlainPanel ( 'drawer-glass-plain-panel-static' , 'Glass theme plain / no-plain-on-glass combo (static)' ) ;
78101 } ) ;
79102
80103 it ( 'Verify focus is automatically handled with focus trap enabled' , ( ) => {
0 commit comments