Skip to content

Commit

Permalink
Improve e2e test (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano authored Mar 6, 2024
1 parent e15099a commit 12f3e45
Showing 1 changed file with 36 additions and 39 deletions.
75 changes: 36 additions & 39 deletions test/e2e/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,61 @@ test.describe( 'Block', () => {
await admin.createNewPost();
} );

test( 'should update attributes related to sound using only keyboard.', async ( {
test( 'should update attributes related to sound using only keyboard', async ( {
editor,
page,
pageUtils,
} ) => {
await editor.insertBlock( { name: 'piano-block/piano' } );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'ArrowRight' );
// Volume
for ( let i = 0; i < 3; i++ ) {
await page.keyboard.press( 'ArrowLeft' );
}
await pageUtils.pressKeys( 'ArrowRight', { times: 2 } );
await expect( page.getByRole( 'slider', { name: 'Volume' } ) ).toBeFocused();
await pageUtils.pressKeys( 'ArrowLeft', { times: 3 } );
// Octave Offset
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Enter' );
await pageUtils.pressKeys( 'Tab', { times: 2 } );
await expect( page.getByRole( 'button', { name: '-2' } ) ).toBeFocused();
await pageUtils.pressKeys( 'ArrowRight' );
await pageUtils.pressKeys( 'Enter' );
// Pressing a piano key should not remove focus.
await page.keyboard.press( 'z' );
await pageUtils.pressKeys( 'z' );
// Instrument
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Enter' );
for ( let index = 0; index < 14; index++ ) {
await page.keyboard.press( 'ArrowDown' );
}
await page.keyboard.press( 'Enter' );
await pageUtils.pressKeys( 'ArrowRight', { times: 4 } );
await expect( page.getByRole( 'combobox', { name: 'Insturment' } ) ).toBeFocused();
await pageUtils.pressKeys( 'Enter' );
await pageUtils.pressKeys( 'ArrowDown', { times: 14 } );
await pageUtils.pressKeys( 'Enter' );
// Pressing a piano key should not remove focus.
await page.keyboard.press( 'z' );
await pageUtils.pressKeys( 'z' );
// Synthesizer Setting
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.press( 'ArrowDown' );
await pageUtils.pressKeys( 'ArrowRight' );
await expect( page.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 } );
for ( let index = 0; index < 4; index++ ) {
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'ArrowRight' );
await pageUtils.pressKeys( 'Tab' );
await pageUtils.pressKeys( 'ArrowRight', { times: 2 } );
}
await page.keyboard.press( 'Escape' );
await pageUtils.pressKeys( 'Escape' );
// Pressing a piano key should not remove focus.
await page.keyboard.press( 'z' );
await pageUtils.pressKeys( 'z' );
// Key Layout
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.press( 'Enter' );
await pageUtils.pressKeys( 'ArrowRight' );
await expect( page.getByRole( 'combobox', { name: 'Key Layout' } ) ).toBeFocused();
await pageUtils.pressKeys( 'Enter' );
await pageUtils.pressKeys( 'ArrowDown' );
await pageUtils.pressKeys( 'Enter' );
// Key Indicator
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.press( 'Enter' );
await pageUtils.pressKeys( 'ArrowRight' );
await expect( page.getByRole( 'combobox', { name: 'Key Indicator' } ) ).toBeFocused();
await pageUtils.pressKeys( 'Enter' );
await pageUtils.pressKeys( 'ArrowDown' );
await pageUtils.pressKeys( 'Enter' );

expect( await editor.getEditedPostContent() ).toMatchSnapshot();
} );

test( 'should update attributes in the block sidebar.', async ( { editor, page } ) => {
test.skip( '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();
Expand Down

0 comments on commit 12f3e45

Please sign in to comment.