@@ -5,45 +5,48 @@ const EXPLORE_DATA = 'Explore';
55
66async function login ( page : Page ) {
77 await page . goto ( 'http://localhost:3000/login' ) ;
8- await page . getByLabel ( 'Username input field ') . fill ( 'admin' ) ;
9- await page . getByLabel ( 'Password input field ') . fill ( 'admin' ) ;
10- await page . getByLabel ( ' Login button') . click ( ) ;
11- await page . getByLabel ( 'Skip change password button' ) . click ( ) ;
8+ await page . getByPlaceholder ( 'email or username ') . fill ( 'admin' ) ;
9+ await page . getByPlaceholder ( 'password ') . fill ( 'admin' ) ;
10+ await page . getByRole ( 'button' , { name : ' Login button' } ) . or ( page . getByRole ( 'button' , { name : 'Log in' } ) ) . click ( ) ;
11+ await page . getByRole ( 'button' , { name : / s k i p / i } ) . click ( ) ;
1212}
1313
1414async function goToTrinoSettings ( page : Page ) {
15- await page . getByLabel ( 'Toggle menu' ) . click ( ) ;
16- await page . getByRole ( 'link' , { name : 'Connections' } ) . click ( ) ;
17- await page . getByRole ( 'link' , { name : 'Trino' } ) . click ( ) ;
18- await page . getByText ( 'Create a Trino data source' ) . click ( ) ;
15+ await page . getByRole ( 'button' , { name : / t o g g l e m e n u | o p e n m e n u / i } ) . click ( ) ;
16+ await page . getByText ( 'Connections' ) . click ( ) ;
17+ await page . getByText ( / a d d .* c o n n e c t i o n | c o n n e c t d a t a / i) . first ( ) . click ( ) ;
18+ await page . getByText ( 'Trino' ) . click ( ) ;
19+ await page . getByRole ( 'button' , { name : / a d d n e w d a t a s o u r c e | c r e a t e .* t r i n o .* d a t a s o u r c e / i } ) . click ( ) ;
1920}
2021
2122async function setupDataSourceWithAccessToken ( page : Page ) {
22- await page . getByLabel ( 'Datasource HTTP settings url ') . fill ( 'http://trino:8080' ) ;
23- await page . locator ( 'div' ) . filter ( { hasText : / ^ I m p e r s o n a t e l o g g e d i n u s e r A c c e s s t o k e n $ / } ) . getByLabel ( 'Toggle switch' ) . click ( ) ;
23+ await page . getByPlaceholder ( 'http://localhost:8080 ') . fill ( 'http://trino:8080' ) ;
24+ await page . locator ( 'div' ) . filter ( { hasText : / ^ I m p e r s o n a t e l o g g e d i n u s e r A c c e s s t o k e n $ / } ) . locator ( 'label' ) . nth ( 1 ) . click ( ) ;
2425 await page . locator ( 'div' ) . filter ( { hasText : / ^ A c c e s s t o k e n $ / } ) . locator ( 'input[type="password"]' ) . fill ( 'aaa' ) ;
25- await page . getByLabel ( 'Data source settings page Save and Test button' ) . click ( ) ;
26+ await page . getByRole ( 'button' , { name : / s a v e . * t e s t / i } ) . click ( ) ;
2627}
2728
2829async function setupDataSourceWithClientCredentials ( page : Page , clientId : string ) {
29- await page . getByLabel ( 'Datasource HTTP settings url ') . fill ( 'http://trino:8080' ) ;
30+ await page . getByPlaceholder ( 'http://localhost:8080 ') . fill ( 'http://trino:8080' ) ;
3031 await page . locator ( 'div' ) . filter ( { hasText : / ^ T o k e n U R L $ / } ) . locator ( 'input' ) . fill ( 'http://keycloak:8080/realms/trino-realm/protocol/openid-connect/token' ) ;
3132 await page . locator ( 'div' ) . filter ( { hasText : / ^ C l i e n t i d $ / } ) . locator ( 'input' ) . fill ( clientId ) ;
3233 await page . locator ( 'div' ) . filter ( { hasText : / ^ C l i e n t s e c r e t $ / } ) . locator ( 'input[type="password"]' ) . fill ( 'grafana-secret' ) ;
3334 await page . locator ( 'div' ) . filter ( { hasText : / ^ I m p e r s o n a t i o n u s e r $ / } ) . locator ( 'input' ) . fill ( 'service-account-grafana-client' ) ;
34- await page . getByLabel ( 'Data source settings page Save and Test button' ) . click ( ) ;
35+ await page . getByRole ( 'button' , { name : / s a v e . * t e s t / i } ) . click ( ) ;
3536}
3637
3738async function runQueryAndCheckResults ( page : Page ) {
3839 await page . getByText ( EXPLORE_DATA ) . click ( ) ;
40+ await page . locator ( 'textarea[aria-label*="Editor content"]' ) . click ( ) ;
3941 await page . getByTestId ( 'data-testid TimePicker Open Button' ) . click ( ) ;
40- await page . getByLabel ( 'Time Range from field' ) . fill ( '1995-01-01' ) ;
41- await page . getByLabel ( 'Time Range to field' ) . fill ( '1995-12-31' ) ;
42+ const timeInputs = page . locator ( 'input[value*="now"], input[value*="00:00:00"]' ) ;
43+ await timeInputs . first ( ) . fill ( '1995-01-01' ) ;
44+ await timeInputs . last ( ) . fill ( '1995-12-31' ) ;
4245 await page . getByTestId ( 'data-testid TimePicker submit button' ) . click ( ) ;
43- await page . getByLabel ( ' Format as') . click ( ) ;
44- await page . getByText ( 'Table' , { exact : true } ) . click ( ) ;
45- await page . getByTestId ( 'data-testid RefreshPicker run button ') . click ( ) ;
46- await expect ( page . getByTestId ( 'data-testid table body' ) ) . toContainText ( / . * 1 9 9 5 - 0 1 - 1 9 0 . : 0 0 : 0 0 . * / ) ;
46+ await page . locator ( '[role="combobox"][aria-label=" Format as"] ') . click ( ) ;
47+ await page . locator ( '[id^="react-select"][id$="option-1"]' ) . waitFor ( ) ;
48+ await page . locator ( '[id^="react-select"][id$="option-1"] ') . click ( ) ;
49+ await expect ( page . locator ( '[role="table"][aria-label="Explore Table"]' ) . getByText ( / 1 9 9 5 - 0 1 - \d + / ) . first ( ) ) . toBeVisible ( ) ;
4750}
4851
4952test ( 'test with access token' , async ( { page } ) => {
0 commit comments