Skip to content

Commit

Permalink
feat: assistant dashboard e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Pauer authored and corteggiano committed Nov 20, 2024
1 parent 34fcd8c commit 583b7d9
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
103 changes: 103 additions & 0 deletions packages/dashboard/e2e/tests/assistant/assistant.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { test, expect } from '@playwright/test';

const TEST_PAGE = '/iframe.html?id=dashboard-mocked-data--view-only';

test('dashboard has assistant enabled', async ({ page }) => {
await page.goto(TEST_PAGE);

await expect(
page.getByTestId('assistant-menu-buttons-container')
).toBeVisible();
});

test('enable assistant mode and selects widgets', async ({ page }) => {
await page.goto(TEST_PAGE);

const assistantBtn = await page.getByRole('button', {
name: /AI Assistant/i,
});

await assistantBtn.click();

await page.getByRole('checkbox').nth(3).check();
await page.getByRole('checkbox').nth(4).check();

await expect(page.getByText('2/3 items selected')).toBeVisible();

const summaryBtn = await page.getByRole('button', {
name: /Generate summary/i,
});

expect(await summaryBtn.isDisabled()).toBeFalsy();
});

test('disable assistant buttons when selects more than 3 widgets', async ({
page,
}) => {
await page.goto(TEST_PAGE);

const assistantBtn = await page.getByRole('button', {
name: /AI Assistant/i,
});

await assistantBtn.click();

await page.getByRole('checkbox').nth(1).check();
await page.getByRole('checkbox').nth(2).check();
await page.getByRole('checkbox').nth(3).check();
await page.getByRole('checkbox').nth(4).check();

await expect(page.getByText('4/3 items selected')).toBeVisible();

const summaryBtn = await page.getByRole('button', {
name: '4/3 items selected',
});

await summaryBtn.click();

await expect(page.getByText('Property limit reached')).toBeVisible();
});

test('open assistant chatbot when generate summary is clicked', async ({
page,
}) => {
await page.goto(TEST_PAGE);

const assistantBtn = await page.getByRole('button', {
name: /AI Assistant/i,
});

await assistantBtn.click();

await page.getByRole('checkbox').nth(3).check();

await expect(page.getByText('1/3 items selected')).toBeVisible();

const summaryBtn = await page.getByRole('button', {
name: /Generate summary/i,
});

await summaryBtn.click();

await expect(
page.getByPlaceholder('Ask me anything about your IoT data')
).toBeVisible();
});

test('open and close chatbot', async ({ page }) => {
await page.goto(TEST_PAGE);

const chatbotOpenBtn = await page.getByTestId('collapsed-right-panel-icon');

await chatbotOpenBtn.click();

await expect(
page.getByPlaceholder('Ask me anything about your IoT data')
).toBeVisible();

const chatbotCloseBtn = await page.getByTestId(
'assistant-chatbot-close-button'
);

await chatbotCloseBtn.click();
});
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const AssistantFloatingMenu = ({
) : null}
<div
className='iot-app-kit-assistant-menu-buttons-container'
data-testid='assistant-menu-buttons-container'
style={{ gap: `${spaceStaticS}`, marginLeft: spaceStaticXs }}
>
{assistantState.mode === 'on' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export const ViewOnly: ComponentStory<typeof Dashboard> = () => (
<DashboardView
{...emptyDashboardConfiguration}
dashboardConfiguration={MOCK_DASHBOARD_CONFIG}
assistantConfiguration={{
state: 'PASSIVE',
}}
/>
);

Expand Down

0 comments on commit 583b7d9

Please sign in to comment.