@@ -615,3 +615,119 @@ describe("PropertyPanel — flat Layout currentPct basis (currentPct follow-up f
615615 RENDER_TIMEOUT_MS ,
616616 ) ;
617617} ) ;
618+
619+ // Media fixtures (Plan 4 Task 7): the three tag values resolveEditingSections
620+ // turns `media` on for (video/audio/img). Each carries no text fields (so the
621+ // Text group never renders) and sets `element` to a real media node so the
622+ // FlatMediaSection reads a live media element. `as never` casts around the
623+ // element-type mismatch with baseElement()'s HTMLDivElement.
624+ function videoElement ( ) {
625+ return {
626+ ...baseElement ( ) ,
627+ id : "s1-bg" ,
628+ selector : "#s1-bg" ,
629+ label : "S1 Background" ,
630+ tagName : "video" ,
631+ textFields : [ ] ,
632+ element : document . createElement ( "video" ) ,
633+ } ;
634+ }
635+
636+ function imageElement ( ) {
637+ return {
638+ ...baseElement ( ) ,
639+ id : "s1-img" ,
640+ selector : "#s1-img" ,
641+ label : "S1 Image" ,
642+ tagName : "img" ,
643+ textFields : [ ] ,
644+ element : document . createElement ( "img" ) ,
645+ } ;
646+ }
647+
648+ function audioElement ( ) {
649+ return {
650+ ...baseElement ( ) ,
651+ id : "s1-audio" ,
652+ selector : "#s1-audio" ,
653+ label : "S1 Audio" ,
654+ tagName : "audio" ,
655+ textFields : [ ] ,
656+ element : document . createElement ( "audio" ) ,
657+ } ;
658+ }
659+
660+ // All FlatGroup titles currently mounted (open row + every collapsed row).
661+ function flatGroupTitles ( host : HTMLElement ) : string [ ] {
662+ const open = Array . from (
663+ host . querySelectorAll ( '[data-flat-group-open="true"] .text-panel-text-0' ) ,
664+ ) . map ( ( el ) => el . textContent ?? "" ) ;
665+ const collapsed = Array . from (
666+ host . querySelectorAll ( '[data-flat-group-collapsed="true"] .text-panel-text-2' ) ,
667+ ) . map ( ( el ) => el . textContent ?? "" ) ;
668+ return [ ...open , ...collapsed ] ;
669+ }
670+
671+ describe ( "PropertyPanel — Media group (Plan 4)" , ( ) => {
672+ it (
673+ "renders the flat Media group and not the legacy MediaSection, for a video element" ,
674+ async ( ) => {
675+ const { host, root } = await renderPanel ( true , videoElement ( ) as never ) ;
676+ // A Media FlatGroup exists (open or collapsed).
677+ expect ( flatGroupTitles ( host ) ) . toContain ( "Media" ) ;
678+ // The legacy MediaSection renders its rows inside a `Section` whose
679+ // data-panel-section slug is the media title ("video"/"image"/"audio").
680+ // On the flat path it's fully replaced, so none of those may appear.
681+ expect ( host . querySelector ( '[data-panel-section="video"]' ) ) . toBeNull ( ) ;
682+ expect ( host . querySelector ( '[data-panel-section="image"]' ) ) . toBeNull ( ) ;
683+ expect ( host . querySelector ( '[data-panel-section="audio"]' ) ) . toBeNull ( ) ;
684+ act ( ( ) => root . unmount ( ) ) ;
685+ } ,
686+ RENDER_TIMEOUT_MS ,
687+ ) ;
688+
689+ it (
690+ "one-open accordion: opening Media closes whichever other group was open, and vice versa (5-way exclusivity)" ,
691+ async ( ) => {
692+ // videoElement() has canEditStyles: true and no text fields, so Style is
693+ // the default-open group; Layout and Media render collapsed alongside it.
694+ const { host, root } = await renderPanel ( true , videoElement ( ) as never ) ;
695+ expect ( openGroupText ( host ) ) . toContain ( "Style" ) ;
696+
697+ // Opening Media closes Style.
698+ openFlatGroup ( host , "Media" ) ;
699+ const afterMedia = openGroupText ( host ) ;
700+ expect ( afterMedia ) . toContain ( "Media" ) ;
701+ expect ( afterMedia ) . not . toContain ( "Style" ) ;
702+
703+ // Reverse direction: opening Layout closes Media — same shared openGroupId.
704+ openFlatGroup ( host , "Layout" ) ;
705+ const afterLayout = openGroupText ( host ) ;
706+ expect ( afterLayout ) . toContain ( "Layout" ) ;
707+ expect ( afterLayout ) . not . toContain ( "Media" ) ;
708+ act ( ( ) => root . unmount ( ) ) ;
709+ } ,
710+ RENDER_TIMEOUT_MS ,
711+ ) ;
712+
713+ it (
714+ "gates the Media group exactly like the legacy MediaSection: present for video/img/audio, absent for a plain div/text element" ,
715+ async ( ) => {
716+ for ( const fixture of [ videoElement , imageElement , audioElement ] ) {
717+ const { host, root } = await renderPanel ( true , fixture ( ) as never ) ;
718+ expect ( flatGroupTitles ( host ) ) . toContain ( "Media" ) ;
719+ act ( ( ) => root . unmount ( ) ) ;
720+ }
721+
722+ // baseElement() is a plain <div> with text — sections.media is false, so
723+ // no Media group (flat or legacy) may render.
724+ const { host, root } = await renderPanel ( true ) ;
725+ expect ( flatGroupTitles ( host ) ) . not . toContain ( "Media" ) ;
726+ expect ( host . querySelector ( '[data-panel-section="video"]' ) ) . toBeNull ( ) ;
727+ expect ( host . querySelector ( '[data-panel-section="image"]' ) ) . toBeNull ( ) ;
728+ expect ( host . querySelector ( '[data-panel-section="audio"]' ) ) . toBeNull ( ) ;
729+ act ( ( ) => root . unmount ( ) ) ;
730+ } ,
731+ RENDER_TIMEOUT_MS ,
732+ ) ;
733+ } ) ;
0 commit comments