-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34fcd8c
commit 583b7d9
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
packages/dashboard/e2e/tests/assistant/assistant.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters