mirror of https://github.com/buster-so/buster.git
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
|
import { Page } from '@playwright/test';
|
||
|
import { expect } from '@playwright/test';
|
||
|
|
||
|
export const askQuestion = async (page: Page, question: string) => {
|
||
|
await page.goto('http://localhost:3000/app/home');
|
||
|
await page.getByRole('textbox', { name: 'Ask Buster a question...' }).click();
|
||
|
await page
|
||
|
.getByRole('textbox', { name: 'Ask Buster a question...' })
|
||
|
.fill('Who is my top customer?');
|
||
|
|
||
|
await expect(page.getByRole('main').getByRole('button')).toBeVisible();
|
||
|
await page.getByRole('textbox', { name: 'Ask Buster a question...' }).dblclick();
|
||
|
await page.getByRole('textbox', { name: 'Ask Buster a question...' }).press('ControlOrMeta+a');
|
||
|
await page.getByRole('textbox', { name: 'Ask Buster a question...' }).fill('');
|
||
|
await expect(page.getByRole('main').getByRole('button')).toBeDisabled();
|
||
|
await page.getByRole('textbox', { name: 'Ask Buster a question...' }).click();
|
||
|
await page
|
||
|
.getByRole('textbox', { name: 'Ask Buster a question...' })
|
||
|
.fill('Who is my top customer?');
|
||
|
|
||
|
// Submit the question
|
||
|
await page.getByRole('main').getByRole('button').click();
|
||
|
};
|
||
|
|
||
|
export const checkThatPageWasRedirected = async (
|
||
|
page: Page,
|
||
|
redirectPath: ('metrics' | 'reasoning' | 'dashboard')[]
|
||
|
) => {
|
||
|
for (const path of redirectPath) {
|
||
|
await page.waitForURL((url) => url.toString().includes(path), {
|
||
|
timeout: 180000
|
||
|
});
|
||
|
expect(page.url()).toContain(path);
|
||
|
}
|
||
|
};
|