2025-05-31 01:16:48 +08:00
import { expect , test } from '@playwright/test' ;
2025-05-08 02:38:35 +08:00
2025-05-31 01:16:48 +08:00
test . describe
. serial ( 'Create a scatter plot with a question' , ( ) = > {
const question = ` I want to understand if there's a relationship between how much an employee sells and the number of orders they process. Can you generate a scatter plot showing each employee's total sales amount on one axis and their total number of orders on the other axis for the last 12 months? ` ;
let scatterURL = '' ;
test . skip ( ` I can create a scatter plot with a question: ${ question } ` , async ( { page } ) = > {
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 ( question ) ;
await page . getByRole ( 'main' ) . getByRole ( 'button' ) . click ( ) ;
await page . waitForTimeout ( 4000 ) ;
await page . waitForLoadState ( 'networkidle' ) ;
await page . waitForLoadState ( 'domcontentloaded' ) ;
await expect ( page . getByRole ( 'link' , { name : 'Reasoning link' } ) ) . toBeVisible ( ) ;
2025-05-10 02:25:55 +08:00
2025-05-31 01:16:48 +08:00
await expect ( page . getByTestId ( 'metric-view-chart-content' ) . getByRole ( 'img' ) ) . toBeVisible ( {
timeout : 240000 // 4 minutes
} ) ;
await expect ( page . getByTestId ( 'share-button' ) ) . toBeVisible ( ) ;
await expect ( page . getByTestId ( 'save-to-dashboard-button' ) ) . toBeVisible ( ) ;
await expect ( page . getByTestId ( 'edit-chart-button' ) . getByRole ( 'button' ) ) . toBeVisible ( ) ;
2025-05-08 02:38:35 +08:00
2025-05-31 01:16:48 +08:00
await page . getByTestId ( 'edit-chart-button' ) . getByRole ( 'button' ) . click ( ) ;
await expect ( page . getByTestId ( 'select-chart-type-scatter' ) ) . toBeVisible ( ) ;
await expect ( page . getByTestId ( 'select-chart-type-scatter' ) ) . toHaveAttribute (
'data-state' ,
'selected'
) ;
2025-05-08 02:38:35 +08:00
2025-05-31 01:16:48 +08:00
const url = page . url ( ) ;
2025-05-08 03:03:15 +08:00
2025-05-31 01:16:48 +08:00
scatterURL = url ;
} ) ;
2025-05-08 02:38:35 +08:00
2025-05-31 01:16:48 +08:00
// scatterURL =
// 'http://localhost:3000/app/chats/84c1d148-4056-4aca-8741-29f2d11619c2/metrics/8c1e2db2-1cbb-532a-bf36-040c2431c7f3/chart?metric_version_number=1&secondary_view=chart-edit';
2025-05-08 03:03:15 +08:00
2025-05-31 01:16:48 +08:00
test . skip ( 'I can update the scatter plot' , async ( { page } ) = > {
await page . goto ( scatterURL ) ;
await expect ( page . getByTestId ( 'edit-chart-button' ) . getByRole ( 'button' ) ) . toBeVisible ( ) ;
await page . getByTestId ( 'edit-chart-button' ) . getByRole ( 'button' ) . click ( ) ;
await page . waitForTimeout ( 250 ) ;
await page . waitForLoadState ( 'domcontentloaded' ) ;
await page . waitForLoadState ( 'load' ) ;
await page . waitForTimeout ( 1000 ) ;
await expect ( page . getByTestId ( 'select-chart-type-scatter' ) ) . not . toBeVisible ( ) ;
await page . getByTestId ( 'edit-chart-button' ) . getByRole ( 'button' ) . click ( ) ;
await page . waitForTimeout ( 250 ) ;
await expect ( page . getByTestId ( 'select-chart-type-scatter' ) ) . toHaveAttribute (
'data-state' ,
'selected'
) ;
await page . getByTestId ( 'segmented-trigger-Styling' ) . click ( ) ;
await expect ( page . getByText ( 'Dot size' ) ) . toBeVisible ( ) ;
} ) ;
2025-05-08 06:37:32 +08:00
2025-05-31 01:16:48 +08:00
// scatterURL =
// 'http://localhost:3000/app/metrics/8c1e2db2-1cbb-532a-bf36-040c2431c7f3/chart?secondary_view=chart-edit';
2025-05-08 07:19:35 +08:00
2025-05-31 01:16:48 +08:00
test . skip ( 'I can add a trend line' , async ( { page } ) = > {
await page . goto ( scatterURL ) ;
await page . waitForTimeout ( 100 ) ;
await page . getByTestId ( 'segmented-trigger-Styling' ) . click ( ) ;
await page . getByRole ( 'button' , { name : 'Add trend line' } ) . click ( ) ;
2025-05-08 07:19:35 +08:00
2025-05-31 01:16:48 +08:00
await expect (
page
. locator ( 'div' )
. filter ( { hasText : /^Linear$/ } )
. nth ( 1 )
) . toBeVisible ( ) ;
2025-05-08 07:19:35 +08:00
2025-05-31 01:16:48 +08:00
await page . locator ( '.relative > button' ) . first ( ) . click ( ) ;
await expect (
page
. locator ( 'div' )
. filter ( { hasText : /^Linear$/ } )
. nth ( 1 )
) . toBeHidden ( ) ;
} ) ;
2025-05-08 06:37:32 +08:00
} ) ;