Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dashboard): assistant dashboard e2e #3051

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading