diff --git a/src/block.json b/src/block.json index 46e75b5..1761318 100644 --- a/src/block.json +++ b/src/block.json @@ -1,6 +1,6 @@ { "$schema": "https://schemas.wp.org/trunk/block.json", - "apiVersion": 2, + "apiVersion": 3, "name": "piano-block/piano", "title": "Piano", "description": "Play the melody.", diff --git a/src/components/controls/style.scss b/src/components/controls/style.scss index 80bb1d2..34502b7 100644 --- a/src/components/controls/style.scss +++ b/src/components/controls/style.scss @@ -50,7 +50,11 @@ } // Backwards compatible styles for WordPress 6.6 and below - .components-base-control:has(.components-button-group) .components-base-control__label { - display: block; + .components-base-control:has(.components-button-group), + .components-range-control { + + .components-base-control__label { + display: block; + } } } diff --git a/test/e2e/test.spec.ts b/test/e2e/test.spec.ts index a0cc1f1..3cd902a 100644 --- a/test/e2e/test.spec.ts +++ b/test/e2e/test.spec.ts @@ -16,26 +16,31 @@ test.describe( 'Block', () => { await editor.insertBlock( { name: 'piano-block/piano' } ); // Volume await pageUtils.pressKeys( 'ArrowRight', { times: 2 } ); - await expect( page.getByRole( 'slider', { name: 'Volume' } ) ).toBeFocused(); + await expect( editor.canvas.getByRole( 'slider', { name: 'Volume' } ) ).toBeFocused(); await pageUtils.pressKeys( 'ArrowLeft', { times: 3 } ); + // Octave Offset await pageUtils.pressKeys( 'Tab', { times: 2 } ); - await expect( page.getByRole( 'button', { name: '-2' } ) ).toBeFocused(); + await expect( editor.canvas.getByRole( 'button', { name: '-2' } ) ).toBeFocused(); await pageUtils.pressKeys( 'ArrowRight' ); await pageUtils.pressKeys( 'Enter' ); // Pressing a piano key should not remove focus. await pageUtils.pressKeys( 'z' ); + // Instrument await pageUtils.pressKeys( 'ArrowRight', { times: 4 } ); - await expect( page.getByRole( 'combobox', { name: 'Instrument' } ) ).toBeFocused(); + await expect( editor.canvas.getByRole( 'combobox', { name: 'Instrument' } ) ).toBeFocused(); await pageUtils.pressKeys( 'Enter' ); await pageUtils.pressKeys( 'ArrowDown', { times: 14 } ); await pageUtils.pressKeys( 'Enter' ); // Pressing a piano key should not remove focus. await pageUtils.pressKeys( 'z' ); + // Synthesizer Setting await pageUtils.pressKeys( 'ArrowRight' ); - await expect( page.getByRole( 'button', { name: 'Synthesizer Setting' } ) ).toBeFocused(); + await expect( + editor.canvas.getByRole( 'button', { name: 'Synthesizer Setting' } ) + ).toBeFocused(); await pageUtils.pressKeys( 'Enter' ); await expect( page.getByRole( 'combobox', { name: 'Oscillator Type' } ) ).toBeFocused(); await pageUtils.pressKeys( 'ArrowDown', { times: 2 } ); @@ -44,17 +49,23 @@ test.describe( 'Block', () => { await pageUtils.pressKeys( 'ArrowRight', { times: 2 } ); } await pageUtils.pressKeys( 'Escape' ); + // Pressing the escape key in a popover rendered in the iframe editor does not + // return focus to the anchor element, so explicitly focus the anchor element. + // see: https://github.com/WordPress/gutenberg/issues/55413 + await editor.canvas.getByRole( 'button', { name: 'Synthesizer Setting' } ).focus(); // Pressing a piano key should not remove focus. await pageUtils.pressKeys( 'z' ); + // Key Layout await pageUtils.pressKeys( 'ArrowRight' ); - await expect( page.getByRole( 'combobox', { name: 'Key Layout' } ) ).toBeFocused(); + await expect( editor.canvas.getByRole( 'combobox', { name: 'Key Layout' } ) ).toBeFocused(); await pageUtils.pressKeys( 'Enter' ); await pageUtils.pressKeys( 'ArrowDown' ); await pageUtils.pressKeys( 'Enter' ); + // Key Indicator await pageUtils.pressKeys( 'ArrowRight' ); - await expect( page.getByRole( 'combobox', { name: 'Key Indicator' } ) ).toBeFocused(); + await expect( editor.canvas.getByRole( 'combobox', { name: 'Key Indicator' } ) ).toBeFocused(); await pageUtils.pressKeys( 'Enter' ); await pageUtils.pressKeys( 'ArrowDown' ); await pageUtils.pressKeys( 'Enter' ); @@ -62,7 +73,7 @@ test.describe( 'Block', () => { expect( await editor.getEditedPostContent() ).toMatchSnapshot(); } ); - test.skip( 'should update attributes in the block sidebar', async ( { editor, page } ) => { + test( 'should update attributes in the block sidebar', async ( { editor, page } ) => { await editor.insertBlock( { name: 'piano-block/piano' } ); await editor.openDocumentSettingsSidebar(); await page.getByLabel( 'Display on the front end' ).click();