|
1 | 1 | describe('Drawer Demo Test', () => { |
| 2 | + afterEach(() => { |
| 3 | + cy.document().then((doc) => { |
| 4 | + doc.documentElement.classList.remove('pf-v6-theme-glass'); |
| 5 | + }); |
| 6 | + }); |
| 7 | + |
2 | 8 | it('Navigate to the drawer demo', () => { |
3 | 9 | cy.visit('http://localhost:3000/drawer-demo-nav-link'); |
4 | 10 | }); |
5 | 11 |
|
| 12 | + // Known PatternFly CSS bug: when `pf-v6-theme-glass`, `pf-m-glass` (isGlass), and `pf-m-plain` are all active, |
| 13 | + // `pf-m-no-plain-on-glass` does not take effect — plain-under-glass wins and no-plain-on-glass cannot restore |
| 14 | + // the intended glass panel treatment. This test asserts the corrected outcome (semi-transparent background) |
| 15 | + // and fails until Core CSS fixes selector/specificity for that combination. |
| 16 | + it('glass theme + plain + glass: no-plain-on-glass should yield semi-transparent panel background (fails until CSS fix)', () => { |
| 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-panel-glass-plain-combo.pf-v6-c-drawer__panel') |
| 23 | + .should('be.visible') |
| 24 | + .should('have.class', 'pf-m-glass') |
| 25 | + .and('have.class', 'pf-m-plain') |
| 26 | + .and('have.class', 'pf-m-no-plain-on-glass'); |
| 27 | + |
| 28 | + cy.get('#drawer-panel-glass-plain-combo').within(() => { |
| 29 | + cy.contains('Glass theme plain / no-plain-on-glass combo'); |
| 30 | + }); |
| 31 | + |
| 32 | + // When the bug is fixed, no-plain-on-glass should override plain-under-glass and surface a non-opaque background. |
| 33 | + cy.get('#drawer-panel-glass-plain-combo').should(($el) => { |
| 34 | + const bg = window.getComputedStyle($el[0]).backgroundColor; |
| 35 | + |
| 36 | + const rgbaAlpha = (color: string): number | undefined => { |
| 37 | + if (color === 'transparent') { |
| 38 | + return 0; |
| 39 | + } |
| 40 | + if (!color.startsWith('rgba(') || !color.endsWith(')')) { |
| 41 | + return undefined; |
| 42 | + } |
| 43 | + const inner = color.slice('rgba('.length, -1); |
| 44 | + const parts = inner.split(',').map((p) => p.trim()); |
| 45 | + if (parts.length !== 4) { |
| 46 | + return undefined; |
| 47 | + } |
| 48 | + return parseFloat(parts[3]); |
| 49 | + }; |
| 50 | + |
| 51 | + const alpha = rgbaAlpha(bg); |
| 52 | + const hasSemiTransparentBackground = alpha !== undefined && alpha < 1; |
| 53 | + if (!hasSemiTransparentBackground) { |
| 54 | + throw new Error( |
| 55 | + `expected no-plain-on-glass to win over plain+glass under theme (semi-transparent background, alpha < 1); got backgroundColor=${bg}` |
| 56 | + ); |
| 57 | + } |
| 58 | + }); |
| 59 | + }); |
| 60 | + |
6 | 61 | it('Verify focus is automatically handled with focus trap enabled', () => { |
7 | 62 | cy.get('#toggleFocusTrapButton').click(); |
8 | 63 | cy.get('#focusTrap-panelContent .pf-v6-c-button.pf-m-plain').should('have.focus'); |
|
0 commit comments