@@ -974,6 +974,27 @@ test.describe("MIDI Studio V2", () => {
974974 await expect ( page . locator ( '.midi-studio-v2__timing-header-row-2.midi-studio-v2__note-table-column-header[data-step-index="1"]' ) ) . toHaveText ( "2" ) ;
975975 await expect ( page . locator ( '.midi-studio-v2__timing-header-row-2.midi-studio-v2__note-table-column-header[data-step-index="2"]' ) ) . toHaveText ( "3" ) ;
976976 await expect ( page . locator ( '.midi-studio-v2__timing-header-row-2.midi-studio-v2__note-table-column-header[data-step-index="3"]' ) ) . toHaveText ( "4" ) ;
977+ await expect ( page . locator ( "#instrumentGridSnapIndicator" ) ) . toContainText ( "Snap:" ) ;
978+ await expect ( page . locator ( "#instrumentGridZoomOutButton" ) ) . toHaveAttribute ( "aria-label" , "Zoom out octave grid" ) ;
979+ await expect ( page . locator ( "#instrumentGridZoomInButton" ) ) . toHaveAttribute ( "aria-label" , "Zoom in octave grid" ) ;
980+ const zoomControlsLayout = await page . locator ( ".midi-studio-v2__timeline-title" ) . evaluate ( ( header ) => {
981+ const snap = header . querySelector ( "#instrumentGridSnapIndicator" ) . getBoundingClientRect ( ) ;
982+ const zoomOut = header . querySelector ( "#instrumentGridZoomOutButton" ) . getBoundingClientRect ( ) ;
983+ const zoomIn = header . querySelector ( "#instrumentGridZoomInButton" ) . getBoundingClientRect ( ) ;
984+ return {
985+ zoomInAfterZoomOut : zoomIn . left > zoomOut . right ,
986+ zoomOutAfterSnap : zoomOut . left > snap . right ,
987+ zoomText : [
988+ header . querySelector ( "#instrumentGridZoomOutButton" ) . textContent ,
989+ header . querySelector ( "#instrumentGridZoomInButton" ) . textContent
990+ ]
991+ } ;
992+ } ) ;
993+ expect ( zoomControlsLayout ) . toEqual ( {
994+ zoomInAfterZoomOut : true ,
995+ zoomOutAfterSnap : true ,
996+ zoomText : [ "-" , "+" ]
997+ } ) ;
977998
978999 const output = page . locator ( "#instrumentGridOutput" ) ;
9791000 const gridLayout = await output . evaluate ( ( element ) => {
@@ -987,6 +1008,7 @@ test.describe("MIDI Studio V2", () => {
9871008 alternatingRowsDiffer : getComputedStyle ( firstRow ) . backgroundColor !== getComputedStyle ( secondRow ) . backgroundColor ,
9881009 borderRightWidth : getComputedStyle ( firstNote ) . borderRightWidth ,
9891010 cellCssWidth : getComputedStyle ( firstNote ) . width ,
1011+ cellHeight : firstNote . getBoundingClientRect ( ) . height ,
9901012 columnWidth : firstNote . getBoundingClientRect ( ) . width ,
9911013 columnTemplate : getComputedStyle ( grid ) . gridTemplateColumns ,
9921014 containsGrid : grid ?. parentElement === element ,
@@ -998,13 +1020,45 @@ test.describe("MIDI Studio V2", () => {
9981020 expect ( gridLayout . alternatingRowsDiffer ) . toBe ( true ) ;
9991021 expect ( Number . parseFloat ( gridLayout . borderRightWidth ) ) . toBeGreaterThanOrEqual ( 0.8 ) ;
10001022 expect ( Number . parseFloat ( gridLayout . borderRightWidth ) ) . toBeLessThanOrEqual ( 1 ) ;
1001- expect ( Number . parseFloat ( gridLayout . cellCssWidth ) ) . toBeGreaterThanOrEqual ( 0.8 ) ;
1002- expect ( Number . parseFloat ( gridLayout . cellCssWidth ) ) . toBeLessThanOrEqual ( 1 ) ;
1003- expect ( gridLayout . columnWidth ) . toBeLessThanOrEqual ( 1 ) ;
1004- expect ( gridLayout . columnTemplate ) . toContain ( "1px " ) ;
1023+ expect ( gridLayout . columnWidth ) . toBeGreaterThan ( 1 ) ;
1024+ expect ( Math . abs ( gridLayout . columnWidth - gridLayout . cellHeight ) ) . toBeLessThanOrEqual ( 1 ) ;
1025+ expect ( Number . parseFloat ( gridLayout . cellCssWidth ) ) . toBeGreaterThan ( 1 ) ;
1026+ expect ( gridLayout . columnTemplate ) . toContain ( "22px " ) ;
10051027 expect ( gridLayout . labelWidth ) . toBeGreaterThan ( 40 ) ;
10061028 expect ( gridLayout . topScrollbarHeight ) . toBeGreaterThanOrEqual ( 12 ) ;
10071029
1030+ await page . locator ( "#instrumentGridZoomInButton" ) . click ( ) ;
1031+ const zoomedInLayout = await output . evaluate ( ( element ) => {
1032+ const firstNote = element . querySelector ( '.midi-studio-v2__octave-note-cell[data-step-index="0"]' ) ;
1033+ const header = element . querySelector ( '.midi-studio-v2__grid-cell--beat-header[data-step-index="6"]' ) . getBoundingClientRect ( ) ;
1034+ const bodyCell = element . querySelector ( '.midi-studio-v2__octave-note-cell[data-row-token="C5"][data-step-index="6"]' ) . getBoundingClientRect ( ) ;
1035+ return {
1036+ bodyHeaderDelta : Math . abs ( header . left - bodyCell . left ) ,
1037+ height : firstNote . getBoundingClientRect ( ) . height ,
1038+ width : firstNote . getBoundingClientRect ( ) . width
1039+ } ;
1040+ } ) ;
1041+ expect ( zoomedInLayout . width ) . toBeGreaterThan ( gridLayout . columnWidth ) ;
1042+ expect ( Math . abs ( zoomedInLayout . width - zoomedInLayout . height ) ) . toBeLessThanOrEqual ( 1 ) ;
1043+ expect ( zoomedInLayout . bodyHeaderDelta ) . toBeLessThanOrEqual ( 1 ) ;
1044+
1045+ await page . locator ( "#instrumentGridZoomOutButton" ) . click ( ) ;
1046+ await page . locator ( "#instrumentGridZoomOutButton" ) . click ( ) ;
1047+ const zoomedOutLayout = await output . evaluate ( ( element ) => {
1048+ const firstNote = element . querySelector ( '.midi-studio-v2__octave-note-cell[data-step-index="0"]' ) ;
1049+ const header = element . querySelector ( '.midi-studio-v2__grid-cell--beat-header[data-step-index="6"]' ) . getBoundingClientRect ( ) ;
1050+ const bodyCell = element . querySelector ( '.midi-studio-v2__octave-note-cell[data-row-token="C5"][data-step-index="6"]' ) . getBoundingClientRect ( ) ;
1051+ return {
1052+ bodyHeaderDelta : Math . abs ( header . left - bodyCell . left ) ,
1053+ height : firstNote . getBoundingClientRect ( ) . height ,
1054+ width : firstNote . getBoundingClientRect ( ) . width
1055+ } ;
1056+ } ) ;
1057+ expect ( zoomedOutLayout . width ) . toBeLessThan ( zoomedInLayout . width ) ;
1058+ expect ( zoomedOutLayout . width ) . toBeGreaterThan ( 1 ) ;
1059+ expect ( Math . abs ( zoomedOutLayout . width - zoomedOutLayout . height ) ) . toBeLessThanOrEqual ( 1 ) ;
1060+ expect ( zoomedOutLayout . bodyHeaderDelta ) . toBeLessThanOrEqual ( 1 ) ;
1061+
10081062 await output . evaluate ( ( element ) => {
10091063 element . style . maxWidth = "80px" ;
10101064 element . dispatchEvent ( new Event ( "scroll" ) ) ;
@@ -1106,8 +1160,7 @@ test.describe("MIDI Studio V2", () => {
11061160 } ;
11071161 } ) ;
11081162 expect ( activeHighlight . content ) . not . toBe ( "none" ) ;
1109- expect ( Number . parseFloat ( activeHighlight . width ) ) . toBeGreaterThanOrEqual ( 0.8 ) ;
1110- expect ( Number . parseFloat ( activeHighlight . width ) ) . toBeLessThanOrEqual ( 1 ) ;
1163+ expect ( Number . parseFloat ( activeHighlight . width ) ) . toBeGreaterThan ( 1 ) ;
11111164 } finally {
11121165 await workspaceV2CoverageReporter . stop ( page ) ;
11131166 await server . close ( ) ;
0 commit comments