Skip to content

Commit 0a84b06

Browse files
committed
Topic messages
1 parent d97292e commit 0a84b06

File tree

5 files changed

+191
-0
lines changed

5 files changed

+191
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Feature: Produce Messages page
2+
Scenario: TopicName ui
3+
Given Topics is visible
4+
When click on Topics link
5+
Given Topics AddATopic clicked
6+
Given TopicCreate heading visible is: "true"
7+
When TopicCreate Topic name starts with: "ANewAutoTopic"
8+
When TopicCreate Number of partitons: 1
9+
When TopicCreate Time to retain data one day
10+
When TopicCreate Create topic clicked
11+
Then Header starts with: "ANewAutoTopic"
12+
Given Topics TopicName partitions is: 1
13+
Given Topics TopicName Overview visible is: "true"
14+
Given Topics TopicName Messages visible is: "true"
15+
Given Topics TopicName Consumers visible is: "true"
16+
Given Topics TopicName Settings visible is: "true"
17+
Given Topics TopicName Statistics visible is: "true"
18+
19+
Scenario: Produce Message
20+
Given Topics is visible
21+
When click on Topics link
22+
Given Topics AddATopic clicked
23+
Given TopicCreate heading visible is: "true"
24+
When TopicCreate Topic name starts with: "ANewAutoTopic"
25+
When TopicCreate Number of partitons: 1
26+
When TopicCreate Time to retain data one day
27+
When TopicCreate Create topic clicked
28+
Then Header starts with: "ANewAutoTopic"
29+
Given Produce message clicked
30+
Then ProduceMessage header visible
31+
Given ProduceMessage Key input is: "keyFromAutotest"
32+
Given ProduceMessage Value input is: "ValueFromAutotest"
33+
Given ProduceMessage Headers input key is: "headerKey", value is: "headerValue"
34+
Given ProduceMessage Produce Message button clicked
35+
When Topics TopicName Messages clicked
36+
Then TopicName messages contains key: "keyFromAutotest"
37+
Then TopicName messages contains value: "ValueFromAutotest"
38+
Then TopicName messages contains headers key is: "headerKey", value is: "headerValue"

e2e-playwright/src/pages/Locators.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import SchemaRegistryLocators from "./SchemaRegistry/SchemaRegistryLocators";
88
import ConnectorsLocators from "./Connectors/ConnectorsLocators";
99
import ksqlDbLocators from "./KSQLDB/ksqldbLocators";
1010
import DashboardLocators from "./Dashboard/DashboardLocators";
11+
import TopicsTopickNameLocators from "./Topics/TopicsTopickNameLocators"
12+
import ProduceMessageLocators from "./Topics/ProduceMessageLocators"
1113

1214
export class Locators {
1315
private readonly page: Page;
@@ -16,6 +18,8 @@ export class Locators {
1618
private _brokers?: BrokersLocators;
1719
private _topics?: TopicsLocators;
1820
private _topicsCreate?: TopicCreateLocators;
21+
private _topicTopicName?: TopicsTopickNameLocators;
22+
private _produceMessage?: ProduceMessageLocators;
1923
private _consumers?: ConsumersLocators;
2024
private _schemaRegistry?: SchemaRegistryLocators;
2125
private _connectors?: ConnectorsLocators;
@@ -42,6 +46,14 @@ export class Locators {
4246
return (this._topicsCreate ??= new TopicCreateLocators(this.page));
4347
}
4448

49+
get topicTopicName() {
50+
return (this._topicTopicName ??= new TopicsTopickNameLocators(this.page));
51+
}
52+
53+
get produceMessage() {
54+
return (this._produceMessage ??= new ProduceMessageLocators(this.page));
55+
}
56+
4557
get consumers() {
4658
return (this._consumers ??= new ConsumersLocators(this.page));
4759
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Page, Locator } from "@playwright/test";
2+
3+
export default class ProduceMessageLocators {
4+
private readonly page: Page;
5+
6+
constructor(page: Page) {
7+
this.page = page;
8+
}
9+
10+
get heading(): Locator { return this.page.getByText('Produce Message').nth(1); }
11+
get keySerdeDropdown(): Locator { return this.page.locator('#selectKeySerdeOptions').getByRole('img'); }
12+
get valueSerdeDropdown(): Locator { return this.page.locator('#selectValueSerdeOptions path'); }
13+
get keyTextbox(): Locator { return this.page.locator('#key').getByRole('textbox'); }
14+
get valueTextbox(): Locator { return this.page.locator('#content').getByRole('textbox'); }
15+
get headersTextbox(): Locator { return this.page.locator('#headers').getByRole('textbox'); }
16+
get produceMessage():Locator { return this.page.locator('form').getByRole('button', { name: 'Produce Message' }); }
17+
18+
partitionDropdown(vakue:string = 'Partition #'): Locator { return this.page.getByRole('listbox', { name: vakue }); }
19+
partitionDropdownElement(value: string): Locator { return this.page.getByRole('list').getByRole('option', { name: value }); }
20+
keySerdeDropdownElement(value: string): Locator { return this.page.getByRole('list').getByRole('option', { name: value }); }
21+
valueSerdeDropdownElement(value: string): Locator { return this.page.getByRole('list').getByRole('option', { name: value }); }
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Page, Locator } from "@playwright/test";
2+
3+
export default class TopicsTopickNameLocators {
4+
private readonly page: Page;
5+
6+
constructor(page: Page) {
7+
this.page = page;
8+
}
9+
10+
get overview():Locator { return this.page.getByRole('link', { name: 'Overview' }); }
11+
get messages():Locator { return this.page.getByRole('link', { name: 'Messages' }); }
12+
get consumers():Locator { return this.page.getByRole('main').getByRole('navigation').getByRole('link', { name: 'Consumers' }); }
13+
get settings():Locator { return this.page.getByRole('link', { name: 'Settings' }); }
14+
get statistics():Locator { return this.page.getByRole('link', { name: 'Statistics' }); }
15+
get produceMessage():Locator { return this.page.getByRole('button', { name: 'Produce Message' }).first(); }
16+
get keyButton():Locator { return this.page.getByRole('button', { name: 'Key' }); }
17+
get valueButton():Locator { return this.page.getByRole('button', { name: 'Value' }); }
18+
get headersButton():Locator { return this.page.getByRole('button', { name: 'Headers' }); }
19+
20+
heading(topicName: string): Locator { return this.page.getByText(`Topics${topicName}`); }
21+
partitions(value: string):Locator { return this.page.getByRole('group').getByText(value).first(); }
22+
messageKey(value: string):Locator { return this.page.getByText(value, { exact: true }); }
23+
messageValue(value: string):Locator { return this.page.getByText(value).first(); }
24+
25+
messageKeyTextbox(value: string):Locator { return this.page.locator('#schema div').filter({ hasText: value }).nth(1); }
26+
messageValueTextbox(value: string):Locator { return this.page.locator('div').filter({ hasText:value }).nth(1); }
27+
messageHeadersTextbox(value: string):Locator { return this.page.locator('div').filter({ hasText: value }).nth(1); }
28+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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

Comments
 (0)