1+ /* eslint-disable no-unused-vars */
2+ import { Given , When , Then , setDefaultTimeout } from "@cucumber/cucumber" ;
3+ import { expect } from "@playwright/test" ;
4+ import { expectVisibility , ensureCheckboxState } from "../services/uiHelper" ;
5+ import { PlaywrightWorld } from "../support/PlaywrightWorld" ;
6+
7+ setDefaultTimeout ( 60 * 1000 * 2 ) ;
8+
9+ Given ( 'Topics TopicName partitions is: {int}' , async function ( this : PlaywrightWorld , count : number ) {
10+ await expectVisibility ( this . locators . topicTopicName . partitions ( count . toString ( ) ) , 'true' ) ;
11+ } ) ;
12+
13+ Given ( 'Topics TopicName Overview visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
14+ await expectVisibility ( this . locators . topicTopicName . overview , visible ) ;
15+ } ) ;
16+
17+ Given ( 'Topics TopicName Messages visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
18+ await expectVisibility ( this . locators . topicTopicName . messages , visible ) ;
19+ } ) ;
20+
21+ Given ( 'Topics TopicName Consumers visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
22+ await expectVisibility ( this . locators . topicTopicName . consumers , visible ) ;
23+ } ) ;
24+
25+ Given ( 'Topics TopicName Settings visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
26+ await expectVisibility ( this . locators . topicTopicName . settings , visible ) ;
27+ } ) ;
28+
29+ Given ( 'Topics TopicName Statistics visible is: {string}' , async function ( this : PlaywrightWorld , visible : string ) {
30+ await expectVisibility ( this . locators . topicTopicName . statistics , visible ) ;
31+ } ) ;
32+ //////////////
33+ Given ( 'Produce message clicked' , async function ( this : PlaywrightWorld ) {
34+ await this . locators . topicTopicName . produceMessage . click ( ) ;
35+ } ) ;
36+
37+ Then ( 'ProduceMessage header visible' , async function ( this : PlaywrightWorld ) {
38+ await expect ( this . locators . produceMessage . heading ) . toBeVisible ( ) ;
39+ } ) ;
40+
41+ Given ( 'ProduceMessage Key input is: {string}' , async function ( this : PlaywrightWorld , key : string ) {
42+ const textbox = this . locators . produceMessage . keyTextbox ;
43+ await textbox . fill ( key ) ;
44+
45+ const actualValue = await textbox . inputValue ( ) ;
46+ expect ( actualValue ) . toContain ( key ) ;
47+ } ) ;
48+
49+ Given ( 'ProduceMessage Value input is: {string}' , async function ( this : PlaywrightWorld , value : string ) {
50+ const textbox = this . locators . produceMessage . valueTextbox ;
51+ await textbox . fill ( value ) ;
52+
53+ const actualValue = await textbox . inputValue ( ) ;
54+ expect ( actualValue ) . toContain ( value ) ;
55+ } ) ;
56+
57+ Given ( 'ProduceMessage Headers input key is: {string}, value is: {string}' , async function ( this : PlaywrightWorld , key : string , value : string ) {
58+ const header = `{"${ key } ":"${ value } "}` ;
59+ const textbox = this . locators . produceMessage . headersTextbox ;
60+ await textbox . clear ( ) ;
61+ await textbox . fill ( header ) ;
62+
63+ const actualValue = await textbox . inputValue ( ) ;
64+ expect ( actualValue ) . toContain ( header ) ;
65+ }
66+ ) ;
67+
68+ Given ( 'ProduceMessage Produce Message button clicked' , async function ( this : PlaywrightWorld ) {
69+ await this . locators . produceMessage . produceMessage . click ( ) ;
70+ } ) ;
71+
72+ When ( 'Topics TopicName Messages clicked' , async function ( this : PlaywrightWorld ) {
73+ await this . locators . topicTopicName . messages . click ( ) ;
74+ } ) ;
75+
76+ Then ( 'TopicName messages contains key: {string}' , async function ( this : PlaywrightWorld , expectedKey : string ) {
77+ await this . locators . topicTopicName . messageValue ( expectedKey ) . click ( )
78+ await this . locators . topicTopicName . keyButton . click ( ) ;
79+ await expectVisibility ( this . locators . topicTopicName . messageKeyTextbox ( expectedKey ) , "true" ) ;
80+ } ) ;
81+
82+ Then ( 'TopicName messages contains value: {string}' , async function ( this : PlaywrightWorld , expectedValue : string ) {
83+ await this . locators . topicTopicName . valueButton . click ( )
84+ await expectVisibility ( this . locators . topicTopicName . messageValue ( expectedValue ) , "true" ) ;
85+ } ) ;
86+
87+ Then ( 'TopicName messages contains headers key is: {string}, value is: {string}' , async function ( this : PlaywrightWorld , headerKey : string , headerValue : string ) {
88+ const expectedHeader = `"${ headerKey } ":"${ headerValue } "` ;
89+ await this . locators . topicTopicName . headersButton . click ( )
90+ await expectVisibility ( this . locators . topicTopicName . messageHeadersTextbox ( expectedHeader ) , "true" ) ;
91+ } ) ;
0 commit comments