1
+ /* eslint-disable no-unused-vars */
2
+ import { Given , When , Then , setDefaultTimeout } from "@cucumber/cucumber" ;
3
+ import { expect } from "@playwright/test" ;
4
+ import { expectVisibility , refreshPageAfterDelay } from "../services/uiHelper" ;
5
+ import { PlaywrightWorld } from "../support/PlaywrightWorld" ;
6
+ import { createStreamQuery , createTableQuery } from "../services/KsqlScripts" ;
7
+ import { generateName , Delete } from "../services/commonFunctions" ;
8
+
9
+ setDefaultTimeout ( 60 * 1000 * 4 ) ;
10
+
11
+ Given ( 'KSQL DB Tables header visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
12
+ await expectVisibility ( this . locators . ksqlDb . tablesHeader , visible ) ;
13
+ } ) ;
14
+
15
+ Given ( 'KSQL DB Streams header visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
16
+ await expectVisibility ( this . locators . ksqlDb . streamsHeader , visible ) ;
17
+ } ) ;
18
+
19
+ Given ( 'KSQL DB Tables link visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
20
+ await expectVisibility ( this . locators . ksqlDb . tablesLink , visible ) ;
21
+ } ) ;
22
+
23
+ Given ( 'KSQL DB Streams link visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
24
+ await expectVisibility ( this . locators . ksqlDb . streamsLink , visible ) ;
25
+ } ) ;
26
+
27
+ When ( 'KSQL DB ExecuteKSQLRequest click' , async function ( this : PlaywrightWorld ) {
28
+ await this . locators . ksqlDb . executeKSQLREquestButton . click ( ) ;
29
+ } ) ;
30
+
31
+ Given ( 'KSQL DB Clear visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
32
+ await expectVisibility ( this . locators . ksqlDb . clear , visible ) ;
33
+ } ) ;
34
+
35
+ Given ( 'KSQL DB Execute visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
36
+ await expectVisibility ( this . locators . ksqlDb . execute , visible ) ;
37
+ } ) ;
38
+
39
+ Given ( 'KSQL DB textbox visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
40
+ await expectVisibility ( this . locators . ksqlDb . textField , visible ) ;
41
+ } ) ;
42
+
43
+ Given ( 'KSQL DB KSQL for stream starts with: {string}, kafka_topic starts with: {string}, value_format: {string}' ,
44
+ async function ( this : PlaywrightWorld , stream : string , topic : string , format : string ) {
45
+ const topicName = generateName ( topic ) ;
46
+ const streamName = generateName ( stream ) . toUpperCase ( ) ;
47
+ const query = createStreamQuery ( streamName , topicName , format ) ;
48
+
49
+ await this . locators . ksqlDb . clear . click ( ) ;
50
+ const textbox = this . locators . ksqlDb . textField ;
51
+ await textbox . click ( ) ;
52
+ await textbox . type ( query ) ;
53
+ await Delete ( this . page ) ;
54
+ await this . locators . ksqlDb . execute . click ( ) ;
55
+
56
+ this . setValue ( `topicName-${ topic } ` , topicName ) ;
57
+ this . setValue ( `streamName-${ stream } ` , streamName ) ;
58
+ }
59
+ ) ;
60
+
61
+ Then ( 'KSQL DB stream created' , async function ( this : PlaywrightWorld ) {
62
+ await expectVisibility ( this . locators . ksqlDb . success , "true" ) ;
63
+ await expectVisibility ( this . locators . ksqlDb . streamCSreated , "true" ) ;
64
+ } ) ;
65
+
66
+ Then (
67
+ 'KSQL DB KSQL for table starts with: {string}, stream starts with: {string}' ,
68
+ async function ( this : PlaywrightWorld , table : string , stream : string ) {
69
+
70
+ const tableName = generateName ( table ) ;
71
+ const streamName = this . getValue < string > ( `streamName-${ stream } ` ) ;
72
+ const query = createTableQuery ( tableName , streamName ) ;
73
+
74
+ await this . locators . ksqlDb . clear . click ( ) ;
75
+ const textbox = this . locators . ksqlDb . textField ;
76
+ await textbox . click ( ) ;
77
+ await textbox . type ( query ) ;
78
+ await Delete ( this . page ) ;
79
+ await this . locators . ksqlDb . execute . click ( ) ;
80
+
81
+ this . setValue ( `tableName-${ table } ` , tableName ) ;
82
+ }
83
+ ) ;
84
+
85
+ Then ( 'KSQL DB table created' , async function ( this : PlaywrightWorld ) {
86
+ await expectVisibility ( this . locators . ksqlDb . success , "true" ) ;
87
+ } ) ;
88
+
89
+ When ( 'KSQL DB Stream clicked' , async function ( this : PlaywrightWorld ) {
90
+ await this . locators . ksqlDb . streamsLink . click ( ) ;
91
+ } ) ;
92
+
93
+ When ( 'KSQL DB Table clicked' , async function ( this : PlaywrightWorld ) {
94
+ await this . locators . ksqlDb . tablesLink . click ( ) ;
95
+ } ) ;
96
+
97
+ Then ( 'KSQL DB stream starts with: {string} visible is: {string}' , async function ( this : PlaywrightWorld , name : string , visible : string ) {
98
+ const streamName = this . getValue < string > ( `streamName-${ name } ` ) ;
99
+ await refreshPageAfterDelay ( this . page ) ;
100
+ await expectVisibility ( this . page . getByRole ( 'cell' , { name : streamName } ) , visible ) ;
101
+ } ) ;
102
+
103
+ Then ( 'KSQL DB table starts with: {string} visible is: {string}' , async function ( this : PlaywrightWorld , name : string , visible : string ) {
104
+ const tableName = this . getValue < string > ( `tableName-${ name } ` ) ;
105
+ await refreshPageAfterDelay ( this . page ) ;
106
+ await expectVisibility ( this . page . getByRole ( 'cell' , { name : tableName } ) . first ( ) , visible ) ;
107
+ } ) ;
0 commit comments