1+ import { test , expect } from '../models/fixture-dashboard'
2+ import { getCellByColumnName } from '../helpers/table'
3+
4+ test . use ( { colorScheme : 'light' } )
5+ // reset storage state
6+ test . use ( { storageState : { cookies : [ ] , origins : [ ] } } ) ;
7+
8+ test ( 'Visit Kafka Order Service' , async ( { page } ) => {
9+
10+ await page . goto ( '/dashboard-demo' ) ;
11+ await page . getByText ( 'Kafka Order Service API' ) . click ( ) ;
12+
13+ await test . step ( 'Verify service info' , async ( ) => {
14+
15+ await expect ( page . getByLabel ( 'Name' ) ) . toHaveText ( 'Kafka Order Service API' ) ;
16+ await expect ( page . getByLabel ( 'Version' ) ) . toHaveText ( '1.0.0' ) ;
17+ await expect ( page . getByLabel ( 'Description' ) ) . toHaveText ( 'An API to process customer orders and notify about order status updates using Kafka.' )
18+
19+ } ) ;
20+
21+ await test . step ( 'Verify Brokers' , async ( ) => {
22+
23+ await expect ( page . getByRole ( 'region' , { name : 'Brokers' } ) ) . toBeVisible ( ) ;
24+ const table = page . getByRole ( 'table' , { name : 'Brokers' } ) ;
25+ const rows = table . locator ( 'tbody tr' ) ;
26+ await expect ( rows ) . toHaveCount ( 1 ) ;
27+ await expect ( await getCellByColumnName ( table , 'Name' , rows . nth ( 0 ) ) ) . toHaveText ( 'development' ) ;
28+ await expect ( await getCellByColumnName ( table , 'Host' , rows . nth ( 0 ) ) ) . toHaveText ( 'localhost:9092' ) ;
29+ await expect ( await getCellByColumnName ( table , 'Description' , rows . nth ( 0 ) ) ) . toHaveText ( 'Local development Kafka broker.' ) ;
30+
31+ } ) ;
32+
33+ await test . step ( 'Verify Topics' , async ( ) => {
34+
35+ await expect ( page . getByRole ( 'region' , { name : 'Topics' } ) ) . toBeVisible ( ) ;
36+ const table = page . getByRole ( 'table' , { name : 'Topics' } ) ;
37+ const rows = table . locator ( 'tbody tr' ) ;
38+ await expect ( rows ) . toHaveCount ( 1 ) ;
39+ await expect ( await getCellByColumnName ( table , 'Name' , rows . nth ( 0 ) ) ) . toHaveText ( 'order-topic' ) ;
40+ await expect ( await getCellByColumnName ( table , 'Description' , rows . nth ( 0 ) ) ) . toHaveText ( 'The Kafka topic for order events.' ) ;
41+ await expect ( await getCellByColumnName ( table , 'Last Message' , rows . nth ( 0 ) ) ) . not . toHaveText ( '-' ) ;
42+ await expect ( await getCellByColumnName ( table , 'Messages' , rows . nth ( 0 ) ) ) . toHaveText ( '1' ) ;
43+
44+ } ) ;
45+
46+ await test . step ( 'Verify Groups' , async ( ) => {
47+
48+ await expect ( page . getByRole ( 'region' , { name : 'Groups' } ) ) . toBeVisible ( ) ;
49+ const table = page . getByRole ( 'table' , { name : 'Groups' } ) ;
50+ const rows = table . locator ( 'tbody tr' ) ;
51+ await expect ( rows ) . toHaveCount ( 1 ) ;
52+ await expect ( await getCellByColumnName ( table , 'Name' , rows . nth ( 0 ) ) ) . toHaveText ( 'order-status-group-100' ) ;
53+ await expect ( await getCellByColumnName ( table , 'State' , rows . nth ( 0 ) ) ) . toHaveText ( 'Stable' ) ;
54+ await expect ( await getCellByColumnName ( table , 'Protocol' , rows . nth ( 0 ) ) ) . toHaveText ( 'RoundRobinAssigner' ) ;
55+ await expect ( await getCellByColumnName ( table , 'Coordinator' , rows . nth ( 0 ) ) ) . toHaveText ( 'localhost:9092' ) ;
56+ await expect ( await getCellByColumnName ( table , 'Leader' , rows . nth ( 0 ) ) ) . toHaveText ( / ^ p r o d u c e r / ) ;
57+ const members = await getCellByColumnName ( table , 'Members' , rows . nth ( 0 ) )
58+ await expect ( members ) . toHaveText ( / ^ p r o d u c e r / ) ;
59+
60+ await members . hover ( ) ;
61+ const tooltip = page . getByRole ( 'tooltip' )
62+ await expect ( tooltip ) . toBeVisible ( ) ;
63+ await expect ( tooltip . getByLabel ( 'Address' ) ) . not . toBeEmpty ( ) ;
64+ await expect ( tooltip . getByLabel ( 'Client Software' ) ) . toHaveText ( '-' ) ;
65+ await expect ( tooltip . getByLabel ( 'Last Heartbeat' ) ) . not . toBeEmpty ( ) ;
66+ await expect ( tooltip . getByLabel ( 'Topics' ) ) . toHaveText ( 'order-topic' ) ;
67+
68+ await rows . nth ( 0 ) . getByRole ( 'cell' ) . nth ( 0 ) . click ( ) ;
69+ const dialog = page . getByRole ( 'dialog' , { name : 'Group Details' } ) ;
70+ await expect ( dialog ) . toBeVisible ( ) ;
71+ await expect ( dialog . getByLabel ( 'Name' ) ) . toHaveText ( 'order-status-group-100' ) ;
72+ await expect ( dialog . getByLabel ( 'State' ) ) . toHaveText ( 'Stable' ) ;
73+ await expect ( dialog . getByLabel ( 'Protocol' ) ) . toHaveText ( 'RoundRobinAssigner' ) ;
74+ await expect ( dialog . getByLabel ( 'Coordinator' ) ) . toHaveText ( 'localhost:9092' ) ;
75+ await expect ( dialog . getByLabel ( 'Leader' ) ) . toHaveText ( / ^ p r o d u c e r / ) ;
76+
77+ await dialog . getByRole ( 'tab' , { name : 'Topics' } ) . click ( ) ;
78+ const topics = dialog . getByRole ( 'table' , { name : 'Topics' } ) ;
79+ await expect ( await getCellByColumnName ( topics , 'Topic' ) ) . toHaveText ( 'order-topic' ) ;
80+
81+ await dialog . getByRole ( 'tab' , { name : 'Members' } ) . click ( ) ;
82+ const membersPanel = dialog . getByRole ( 'tabpanel' , { name : 'Members' } ) ;
83+ await expect ( membersPanel ) . toBeVisible ( ) ;
84+ await expect ( membersPanel . getByRole ( 'tab' , { name : / ^ p r o d u c e r / } ) ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
85+ await expect ( membersPanel . getByLabel ( 'Address' ) ) . not . toBeEmpty ( ) ;
86+ await expect ( membersPanel . getByLabel ( 'Client Software' ) ) . toHaveText ( '-' ) ;
87+ await expect ( membersPanel . getByLabel ( 'Heartbeat' ) ) . not . toBeEmpty ( ) ;
88+ const memberPartitions = membersPanel . getByRole ( 'table' , { name : 'Member Partitions' } )
89+ await expect ( await getCellByColumnName ( memberPartitions , 'Topic' ) ) . toHaveText ( 'order-topic' ) ;
90+ await expect ( await getCellByColumnName ( memberPartitions , 'Partitions' ) ) . toHaveText ( '0' ) ;
91+
92+ await dialog . getByRole ( 'button' , { name : 'Close' } ) . click ( ) ;
93+
94+ } ) ;
95+
96+ await test . step ( 'Verify Configs' , async ( ) => {
97+ const table = page . getByRole ( 'table' , { name : 'Configs' } ) ;
98+ await expect ( await getCellByColumnName ( table , 'URL' ) ) . toContainText ( '/webui/scripts/dashboard-demo/demo-configs/asyncapi.yaml' ) ;
99+ await expect ( await getCellByColumnName ( table , 'Provider' ) ) . toHaveText ( 'file' ) ;
100+ } ) ;
101+
102+ await test . step ( 'Verify Recent Messages' , async ( ) => {
103+
104+ const region = page . getByRole ( 'region' , { name : 'Recent Messages' } ) ;
105+ await expect ( region ) . toBeVisible ( ) ;
106+
107+ const table = region . getByRole ( 'table' , { name : 'Recent Messages' } ) ;
108+ const rows = table . locator ( 'tbody tr' ) ;
109+ await expect ( rows ) . toHaveCount ( 1 ) ;
110+ await expect ( await getCellByColumnName ( table , 'Key' , rows . nth ( 0 ) ) ) . toHaveText ( 'a914817b-c5f0-433e-8280-1cd2fe44234e' ) ;
111+ await expect ( await getCellByColumnName ( table , 'Value' , rows . nth ( 0 ) ) ) . toContainText ( '{"orderId":"a914817b-c5f0-433e-8280-1cd2fe44234e","productId":"2a' ) ;
112+ await expect ( await getCellByColumnName ( table , 'Topic' , rows . nth ( 0 ) ) ) . toHaveText ( 'order-topic' ) ;
113+ await expect ( await getCellByColumnName ( table , 'Time' , rows . nth ( 0 ) ) ) . not . toBeEmpty ( ) ;
114+
115+ } )
116+
117+ await test . step ( 'Visit Kafka Topic' , async ( ) => {
118+
119+ await page . getByRole ( 'table' , { name : 'Topics' } ) . getByText ( 'order-topic' ) . click ( ) ;
120+ await expect ( page . getByLabel ( 'Topic' , { exact : true } ) ) . toHaveText ( 'order-topic' ) ;
121+ await expect ( page . getByLabel ( 'Cluster' ) ) . toHaveText ( 'Kafka Order Service API' ) ;
122+ await expect ( page . getByLabel ( 'Cluster' ) ) . toHaveAttribute ( 'href' ) ;
123+ await expect ( page . getByLabel ( 'Description' ) ) . toHaveText ( 'The Kafka topic for order events.' ) ;
124+
125+ await expect ( page . getByLabel ( 'Type of API' ) ) . toHaveText ( 'Kafka' ) ;
126+
127+ await test . step ( 'Verify Message' , async ( ) => {
128+
129+ await page . getByRole ( 'table' , { name : 'Messages' } ) . locator ( 'tbody tr' ) . click ( ) ;
130+ await expect ( page . getByLabel ( 'Kafka Key' ) ) . toHaveText ( 'a914817b-c5f0-433e-8280-1cd2fe44234e' ) ;
131+ await expect ( page . getByLabel ( 'Kafka Topic' ) ) . toHaveText ( 'order-topic' ) ;
132+ await expect ( page . getByLabel ( 'Kafka Topic' ) ) . toHaveAttribute ( 'href' , '/dashboard/kafka/service/Kafka%20Order%20Service%20API/topic/order-topic' ) ;
133+ await expect ( page . getByLabel ( 'Offset' ) ) . toHaveText ( '0' ) ;
134+ await expect ( page . getByRole ( 'region' , { name : 'Meta' } ) . getByLabel ( 'Content Type' ) ) . toHaveText ( 'application/json' ) ;
135+ await expect ( page . getByLabel ( 'Key Type' ) ) . toHaveText ( '-' ) ;
136+ await expect ( page . getByLabel ( 'Key Type' ) ) . not . toBeEmpty ( ) ;
137+
138+ const value = page . getByRole ( 'region' , { name : 'Value' } ) ;
139+ await expect ( value . getByLabel ( 'Content Type' ) ) . toHaveText ( 'application/json' ) ;
140+ await expect ( value . getByLabel ( 'Lines of Code' ) ) . toHaveText ( '7 lines' ) ;
141+ await expect ( value . getByLabel ( 'Size of Code' ) ) . toHaveText ( '196 B' ) ;
142+ await expect ( value . getByLabel ( 'Size of Code' ) ) . toHaveText ( '196 B' ) ;
143+ await expect ( value . getByLabel ( 'Content' , { exact : true } ) ) . toContainText ( '"orderId": "a914817b-c5f0-433e-8280-1cd2fe44234e",' )
144+
145+ await page . goBack ( ) ;
146+
147+ } ) ;
148+
149+ await test . step ( 'Verify Paritions' , async ( ) => {
150+
151+ await page . getByRole ( 'tab' , { name : 'Partitions' } ) . click ( ) ;
152+ const table = page . getByRole ( 'table' , { name : 'Partitions' } ) ;
153+ const rows = table . locator ( 'tbody tr' ) ;
154+ await expect ( rows ) . toHaveCount ( 1 ) ;
155+ await expect ( await getCellByColumnName ( table , 'ID' ) ) . toHaveText ( '0' ) ;
156+ await expect ( await getCellByColumnName ( table , 'Leader' ) ) . toHaveText ( 'development (localhost:9092)' ) ;
157+ await expect ( await getCellByColumnName ( table , 'Start Offset' ) ) . toHaveText ( '0' ) ;
158+ await expect ( await getCellByColumnName ( table , 'Offset' ) ) . toHaveText ( '1' ) ;
159+ await expect ( await getCellByColumnName ( table , 'Segments' ) ) . toHaveText ( '1' ) ;
160+
161+ } ) ;
162+
163+ await test . step ( 'Verify Groups' , async ( ) => {
164+
165+ await page . getByRole ( 'tab' , { name : 'Groups' } ) . click ( ) ;
166+ const table = page . getByRole ( 'table' , { name : 'Groups' } ) ;
167+ const rows = table . locator ( 'tbody tr' ) ;
168+ await expect ( rows ) . toHaveCount ( 1 ) ;
169+ await expect ( await getCellByColumnName ( table , 'Name' ) ) . toHaveText ( 'order-status-group-100' ) ;
170+ await expect ( await getCellByColumnName ( table , 'State' ) ) . toHaveText ( 'Stable' ) ;
171+ await expect ( await getCellByColumnName ( table , 'Protocol' ) ) . toHaveText ( 'RoundRobinAssigner' ) ;
172+ await expect ( await getCellByColumnName ( table , 'Coordinator' ) ) . toHaveText ( 'localhost:9092' ) ;
173+ await expect ( await getCellByColumnName ( table , 'Leader' ) ) . toHaveText ( / ^ p r o d u c e r / ) ;
174+ await expect ( await getCellByColumnName ( table , 'Members' ) ) . toContainText ( / ^ p r o d u c e r / ) ;
175+ await expect ( await getCellByColumnName ( table , 'Lag' ) ) . toHaveText ( '0' ) ;
176+
177+ } ) ;
178+
179+ await test . step ( 'Verify Configs' , async ( ) => {
180+
181+ await page . getByRole ( 'tab' , { name : 'Configs' } ) . click ( ) ;
182+ const configs = page . getByRole ( 'tabpanel' , { name : 'Configs' } ) ;
183+ await expect ( configs . getByLabel ( 'Name' ) ) . toHaveText ( 'OrderCreatedEvent' ) ;
184+ await expect ( configs . getByLabel ( 'Title' ) ) . toHaveText ( 'Order Created Event' ) ;
185+ await expect ( configs . getByLabel ( 'Summary' ) ) . toHaveText ( 'Notification that a new order has been created.' ) ;
186+ await expect ( configs . getByLabel ( 'Message Content Type' , { exact : true } ) ) . toHaveText ( 'application/json' ) ;
187+ const value = configs . getByRole ( 'tabpanel' , { name : 'Value' } )
188+ await expect ( value . getByLabel ( 'Lines of Code' ) . nth ( 0 ) ) . toHaveText ( '41 lines' ) ;
189+ await expect ( value . getByLabel ( 'Size of Code' ) . nth ( 0 ) ) . toHaveText ( '826 B' ) ;
190+ await expect ( value . getByRole ( 'region' , { name : 'Content' } ) . nth ( 0 ) ) . toContainText ( `"type": "object",
191+ "properties": {` ) ;
192+
193+ } ) ;
194+
195+ } ) ;
196+ } ) ;
0 commit comments