Skip to content

Commit

Permalink
test(e2e): editable custom actions for AI Toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Jul 30, 2024
1 parent abc0d0f commit f1ae012
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/blocks/test/e2e/blocks/dashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test.describe( 'Dashboard', () => {
await admin.visitAdminPage( 'admin.php?page=otter' );
});

test( 'toggle AI Block Toolbar', async({ editor, page }) => {
test( 'toggle AI Block Toolbar', async({ page }) => {

const toggle = page.getByLabel( 'Enable AI Block Toolbar Module' );
const initialToggleValue = await toggle.isChecked();
Expand All @@ -23,4 +23,30 @@ test.describe( 'Dashboard', () => {
await page.waitForTimeout( 1000 );
expect( await toggle.isChecked() ).toEqual( initialToggleValue );
});

test( 'edit editable custom actions', async({ page }) => {

const actionTitleValue = 'Fix Spelling';
const actionPromptValue = 'Fix spelling mistakes in the content.';

await page.getByRole( 'button', { name: 'Integrations' }).click();

const firstAction = page.locator( '.otter-ai-toolbar-actions .components-panel__body:first-child button' );
await firstAction.click();

await page.locator( '.otter-ai-toolbar-actions .components-panel__body:first-child' ).getByPlaceholder( 'Action Name' ).fill( actionTitleValue );
await page.locator( '.otter-ai-toolbar-actions .components-panel__body:first-child' ).getByPlaceholder( 'Prompt' ).fill( actionPromptValue );

const requestPromise = page.waitForRequest( request =>
request.url().includes( 'settings' )
);
await page.locator( 'div' ).filter({ hasText: /^SaveMore Info↗$/ }).getByRole( 'button' ).click();
await requestPromise;

await page.reload();

await page.getByRole( 'button', { name: 'Integrations' }).click();

await expect( page.getByRole( 'button', { name: actionTitleValue }) ).toBeVisible();
});
});

0 comments on commit f1ae012

Please sign in to comment.