Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update media toolbar insertion tests
  • Loading branch information
derekblank committed Jun 29, 2023
commit 5eefcd700e406cc2ec3a4976cdc9245fc94b2849
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,41 @@ describe( 'when title is focused', () => {
screen.getAllByLabelText( /Paragraph Block. Row 3/ )[ 0 ]
).toBeDefined();
} );

it( 'media blocks should be displayed', async () => {
const screen = await initializeEditor( {
initialHtml,
} );

// Focus first block
fireEvent.press(
screen.getAllByLabelText( /Paragraph Block. Row 1/ )[ 0 ]
);

// Focus title
fireEvent(
screen.getAllByLabelText( 'Post title. test' )[ 0 ],
'select'
);

// Focus last block
fireEvent.press(
screen.getAllByLabelText( /Paragraph Block. Row 2/ )[ 0 ]
);

// Assert that the media buttons are not visible
const imageButtons = screen.queryAllByTestId( 'image-button' );
expect( imageButtons ).toBeDefined();

const videoButtons = screen.queryAllByTestId( 'video-button' );
expect( videoButtons ).toBeDefined();

const galleryButtons = screen.queryAllByTestId( 'gallery-button' );
expect( galleryButtons ).toBeDefined();

const audioButtons = screen.queryAllByTestId( 'audio-button' );
expect( audioButtons ).toBeDefined();
} );
} );

describe( 'when title is no longer focused', () => {
Expand Down Expand Up @@ -101,4 +136,39 @@ describe( 'when title is no longer focused', () => {
screen.getAllByLabelText( /Heading Block. Row 3/ )[ 0 ]
).toBeDefined();
} );

it( 'media blocks should not be displayed', async () => {
const screen = await initializeEditor( {
initialHtml,
} );

// Focus first block
fireEvent.press(
screen.getAllByLabelText( /Paragraph Block. Row 1/ )[ 0 ]
);

// Focus title
fireEvent(
screen.getAllByLabelText( 'Post title. test' )[ 0 ],
'select'
);

// Focus last block
fireEvent.press(
screen.getAllByLabelText( /Paragraph Block. Row 2/ )[ 0 ]
);

// Assert that the media buttons are not visible
const imageButtons = screen.queryAllByTestId( 'image-button' );
expect( imageButtons ).toHaveLength( 0 );

const videoButtons = screen.queryAllByTestId( 'video-button' );
expect( videoButtons ).toHaveLength( 0 );

const galleryButtons = screen.queryAllByTestId( 'gallery-button' );
expect( galleryButtons ).toHaveLength( 0 );

const audioButtons = screen.queryAllByTestId( 'audio-button' );
expect( audioButtons ).toHaveLength( 0 );
} );
} );