@@ -55,143 +55,80 @@ test.describe("Produce Message(s) to Topic", { tag: [Tag.ProduceMessageToTopic]
5555 ] ;
5656
5757 for ( const [ connectionType , connectionTag ] of connectionTypes ) {
58- test . describe ( `${ connectionType } connection` , { tag : [ connectionTag ] } , ( ) => {
59- for ( const [ schemaType , fileExtension ] of schemaTypes ) {
60- test . describe ( schemaType ? `${ schemaType } schema` : "(no schema)" , ( ) => {
61- const schemaSuffix = schemaType ? schemaType . toLowerCase ( ) : "no-schema" ;
62-
63- // specify the connection type to use with the `connectionItem` fixture, and the topic to
64- // create with the `topic` fixture
65- test . use ( {
66- connectionType,
67- topicConfig : { name : `e2e-produce-message-${ schemaSuffix } ` } ,
68- } ) ;
69-
70- test . beforeEach ( async ( { page, connectionItem, topic : topicName } ) => {
71- // ensure connection tree item has resources available to work with
72- await expect ( connectionItem . locator ) . toHaveAttribute ( "aria-expanded" , "true" ) ;
73-
74- const topicsView = new TopicsView ( page ) ;
75- // click a Kafka cluster from the Resources view to open and populate the Topics view
76- await topicsView . loadTopics ( connectionType , SelectKafkaCluster . FromResourcesView ) ;
77- let targetTopic = topicsView . topicsWithoutSchemas . filter ( { hasText : topicName } ) ;
78-
79- // if we want to use a schema, create a new subject with an initial schema version to match
80- // the topic we're using
81- if ( schemaType && fileExtension ) {
82- const schemasView = new SchemasView ( page ) ;
83- await schemasView . loadSchemaSubjects (
84- connectionType ,
85- SelectSchemaRegistry . FromResourcesView ,
86- ) ;
87- // create the schema version and keep track of the subject name for cleanup later
88- subjectName = await schemasView . createSchemaVersion (
89- page ,
90- schemaType ,
91- `schemas/customer.${ fileExtension } ` ,
92- `${ topicName } -value` ,
93- ) ;
94-
95- // make sure the Topics view is updated to show the topic with schemas
96- // (which, in the background, will associate the topic with the subject we created,
97- // which then informs the schema key/value/etc quickpick during the produce flow)
98- await topicsView . clickRefresh ( ) ;
99- targetTopic = topicsView . topicsWithSchemas . filter ( {
100- hasText : topicName ,
101- } ) ;
102- }
103-
104- // until we can delete topics, we may have too many to show at once in the view, so
105- // scroll the target topic into view before trying to click it
106- await targetTopic . scrollIntoViewIfNeeded ( ) ;
107- topicItem = new TopicItem ( page , targetTopic . first ( ) ) ;
108- await expect ( topicItem . locator ) . toBeVisible ( ) ;
109- } ) ;
110-
111- test . afterEach ( async ( { page, electronApp } ) => {
112- // delete the subject if it was created during the test
113- if ( subjectName ) {
114- const schemasView = new SchemasView ( page ) ;
115- await schemasView . deleteSchemaSubject (
116- page ,
117- electronApp ,
118- subjectName ,
119- deletionConfirmation ,
120- ) ;
121- }
122- } ) ;
123-
124- test ( "should successfully produce a message" , async ( { page } ) => {
125- // open a new JSON editor and add "good" content
126- const document : TextDocument = await openNewUntitledDocument ( page , "json" ) ;
127- const messageContent : string = loadFixtureFromFile ( "produceMessages/good.json" ) ;
128- await document . insertContent ( messageContent ) ;
129-
130- await topicItem . clickSendMessages ( ) ;
131- // click the currently open document item in the document/URI quickpick
132- const documentQuickpick = new Quickpick ( page ) ;
133- await expect ( documentQuickpick . locator ) . toBeVisible ( ) ;
134- const currentDocumentItem = documentQuickpick . items . filter ( {
135- hasText : "Untitled" ,
136- } ) ;
137- await expect ( currentDocumentItem ) . not . toHaveCount ( 0 ) ;
138- await currentDocumentItem . click ( ) ;
139- // confirm the default selection in the schema multi-select quickpick
140- const schemaQuickpick = new Quickpick ( page ) ;
141- await expect ( schemaQuickpick . locator ) . toBeVisible ( ) ;
142- // we could check the default selection(s) here based on which schemas are used (key,
143- // value, key+value, etc) but that isn't necessary for now
144- await schemaQuickpick . confirm ( ) ;
145-
146- // expect info notification about successfully producing the message
147- const notificationArea = new NotificationArea ( page ) ;
148- const successNotifications = notificationArea . infoNotifications . filter ( {
149- hasText : / S u c c e s s f u l l y p r o d u c e d 1 m e s s a g e t o t o p i c / ,
58+ test . describe (
59+ `${ connectionType } connection` ,
60+ { tag : [ connectionTag , Tag . RequiresTopic ] } ,
61+ ( ) => {
62+ for ( const [ schemaType , fileExtension ] of schemaTypes ) {
63+ test . describe ( schemaType ? `${ schemaType } schema` : "(no schema)" , ( ) => {
64+ const schemaSuffix = schemaType ? schemaType . toLowerCase ( ) : "no-schema" ;
65+
66+ // specify the connection type to use with the `connectionItem` fixture, and the topic to
67+ // create with the `topic` fixture
68+ test . use ( {
69+ connectionType,
70+ topicConfig : { name : `e2e-produce-message-${ schemaSuffix } ` } ,
15071 } ) ;
151- await expect ( successNotifications ) . not . toHaveCount ( 0 ) ;
152- } ) ;
15372
154- test ( "should show a JSON validation error when producing a bad message" , async ( {
155- page,
156- } ) => {
157- // open a new JSON editor and add content that's missing the required 'key' field
158- const document : TextDocument = await openNewUntitledDocument ( page , "json" ) ;
159- const badMessageContent : string = loadFixtureFromFile (
160- "produceMessages/bad_missing-key.json" ,
161- ) ;
162- await document . insertContent ( badMessageContent ) ;
163-
164- await topicItem . clickSendMessages ( ) ;
165- // click the currently open document item in the document/URI quickpick
166- const documentQuickpick = new Quickpick ( page ) ;
167- await expect ( documentQuickpick . locator ) . toBeVisible ( ) ;
168- const currentDocumentItem = documentQuickpick . items . filter ( {
169- hasText : "Untitled" ,
73+ test . beforeEach ( async ( { page, connectionItem, topic : topicName } ) => {
74+ // ensure connection tree item has resources available to work with
75+ await expect ( connectionItem . locator ) . toHaveAttribute ( "aria-expanded" , "true" ) ;
76+
77+ const topicsView = new TopicsView ( page ) ;
78+ // click a Kafka cluster from the Resources view to open and populate the Topics view
79+ await topicsView . loadTopics ( connectionType , SelectKafkaCluster . FromResourcesView ) ;
80+ let targetTopic = topicsView . topicsWithoutSchemas . filter ( { hasText : topicName } ) ;
81+
82+ // if we want to use a schema, create a new subject with an initial schema version to match
83+ // the topic we're using
84+ if ( schemaType && fileExtension ) {
85+ const schemasView = new SchemasView ( page ) ;
86+ await schemasView . loadSchemaSubjects (
87+ connectionType ,
88+ SelectSchemaRegistry . FromResourcesView ,
89+ ) ;
90+ // create the schema version and keep track of the subject name for cleanup later
91+ subjectName = await schemasView . createSchemaVersion (
92+ page ,
93+ schemaType ,
94+ `schemas/customer.${ fileExtension } ` ,
95+ `${ topicName } -value` ,
96+ ) ;
97+
98+ // make sure the Topics view is updated to show the topic with schemas
99+ // (which, in the background, will associate the topic with the subject we created,
100+ // which then informs the schema key/value/etc quickpick during the produce flow)
101+ await topicsView . clickRefresh ( ) ;
102+ targetTopic = topicsView . topicsWithSchemas . filter ( {
103+ hasText : topicName ,
104+ } ) ;
105+ }
106+
107+ // until we can delete topics, we may have too many to show at once in the view, so
108+ // scroll the target topic into view before trying to click it
109+ await targetTopic . scrollIntoViewIfNeeded ( ) ;
110+ topicItem = new TopicItem ( page , targetTopic . first ( ) ) ;
111+ await expect ( topicItem . locator ) . toBeVisible ( ) ;
170112 } ) ;
171- await expect ( currentDocumentItem ) . not . toHaveCount ( 0 ) ;
172- await currentDocumentItem . click ( ) ;
173- // no schema quickpick since we should show an error notification before getting to that point
174113
175- await expect ( document . errorDiagnostics ) . not . toHaveCount ( 0 ) ;
176-
177- // expect error notification about basic JSON validation failure
178- const notificationArea = new NotificationArea ( page ) ;
179- const errorNotifications = notificationArea . errorNotifications . filter ( {
180- hasText : / J S O N s c h e m a v a l i d a t i o n f a i l e d / ,
114+ test . afterEach ( async ( { page, electronApp } ) => {
115+ // delete the subject if it was created during the test
116+ if ( subjectName ) {
117+ const schemasView = new SchemasView ( page ) ;
118+ await schemasView . deleteSchemaSubject (
119+ page ,
120+ electronApp ,
121+ subjectName ,
122+ deletionConfirmation ,
123+ ) ;
124+ }
181125 } ) ;
182- await expect ( errorNotifications ) . toHaveCount ( 1 ) ;
183- } ) ;
184126
185- if ( schemaType ) {
186- test ( "should show a schema validation error when producing a bad message" , async ( {
187- page,
188- } ) => {
189- // open a new JSON editor and add content that doesn't follow the schema
127+ test ( "should successfully produce a message" , async ( { page } ) => {
128+ // open a new JSON editor and add "good" content
190129 const document : TextDocument = await openNewUntitledDocument ( page , "json" ) ;
191- const uglyMessageContent : string = loadFixtureFromFile (
192- "produceMessages/ugly_schema-validation-error.json" ,
193- ) ;
194- await document . insertContent ( uglyMessageContent ) ;
130+ const messageContent : string = loadFixtureFromFile ( "produceMessages/good.json" ) ;
131+ await document . insertContent ( messageContent ) ;
195132
196133 await topicItem . clickSendMessages ( ) ;
197134 // click the currently open document item in the document/URI quickpick
@@ -209,18 +146,85 @@ test.describe("Produce Message(s) to Topic", { tag: [Tag.ProduceMessageToTopic]
209146 // value, key+value, etc) but that isn't necessary for now
210147 await schemaQuickpick . confirm ( ) ;
211148
149+ // expect info notification about successfully producing the message
150+ const notificationArea = new NotificationArea ( page ) ;
151+ const successNotifications = notificationArea . infoNotifications . filter ( {
152+ hasText : / S u c c e s s f u l l y p r o d u c e d 1 m e s s a g e t o t o p i c / ,
153+ } ) ;
154+ await expect ( successNotifications ) . not . toHaveCount ( 0 ) ;
155+ } ) ;
156+
157+ test ( "should show a JSON validation error when producing a bad message" , async ( {
158+ page,
159+ } ) => {
160+ // open a new JSON editor and add content that's missing the required 'key' field
161+ const document : TextDocument = await openNewUntitledDocument ( page , "json" ) ;
162+ const badMessageContent : string = loadFixtureFromFile (
163+ "produceMessages/bad_missing-key.json" ,
164+ ) ;
165+ await document . insertContent ( badMessageContent ) ;
166+
167+ await topicItem . clickSendMessages ( ) ;
168+ // click the currently open document item in the document/URI quickpick
169+ const documentQuickpick = new Quickpick ( page ) ;
170+ await expect ( documentQuickpick . locator ) . toBeVisible ( ) ;
171+ const currentDocumentItem = documentQuickpick . items . filter ( {
172+ hasText : "Untitled" ,
173+ } ) ;
174+ await expect ( currentDocumentItem ) . not . toHaveCount ( 0 ) ;
175+ await currentDocumentItem . click ( ) ;
176+ // no schema quickpick since we should show an error notification before getting to that point
177+
212178 await expect ( document . errorDiagnostics ) . not . toHaveCount ( 0 ) ;
213179
214- // expect error notification about schema validation failure
180+ // expect error notification about basic JSON validation failure
215181 const notificationArea = new NotificationArea ( page ) ;
216182 const errorNotifications = notificationArea . errorNotifications . filter ( {
217- hasText : / F a i l e d t o p r o d u c e 1 m e s s a g e t o t o p i c / ,
183+ hasText : / J S O N s c h e m a v a l i d a t i o n f a i l e d / ,
218184 } ) ;
219185 await expect ( errorNotifications ) . toHaveCount ( 1 ) ;
220186 } ) ;
221- }
222- } ) ;
223- }
224- } ) ;
187+
188+ if ( schemaType ) {
189+ test ( "should show a schema validation error when producing a bad message" , async ( {
190+ page,
191+ } ) => {
192+ // open a new JSON editor and add content that doesn't follow the schema
193+ const document : TextDocument = await openNewUntitledDocument ( page , "json" ) ;
194+ const uglyMessageContent : string = loadFixtureFromFile (
195+ "produceMessages/ugly_schema-validation-error.json" ,
196+ ) ;
197+ await document . insertContent ( uglyMessageContent ) ;
198+
199+ await topicItem . clickSendMessages ( ) ;
200+ // click the currently open document item in the document/URI quickpick
201+ const documentQuickpick = new Quickpick ( page ) ;
202+ await expect ( documentQuickpick . locator ) . toBeVisible ( ) ;
203+ const currentDocumentItem = documentQuickpick . items . filter ( {
204+ hasText : "Untitled" ,
205+ } ) ;
206+ await expect ( currentDocumentItem ) . not . toHaveCount ( 0 ) ;
207+ await currentDocumentItem . click ( ) ;
208+ // confirm the default selection in the schema multi-select quickpick
209+ const schemaQuickpick = new Quickpick ( page ) ;
210+ await expect ( schemaQuickpick . locator ) . toBeVisible ( ) ;
211+ // we could check the default selection(s) here based on which schemas are used (key,
212+ // value, key+value, etc) but that isn't necessary for now
213+ await schemaQuickpick . confirm ( ) ;
214+
215+ await expect ( document . errorDiagnostics ) . not . toHaveCount ( 0 ) ;
216+
217+ // expect error notification about schema validation failure
218+ const notificationArea = new NotificationArea ( page ) ;
219+ const errorNotifications = notificationArea . errorNotifications . filter ( {
220+ hasText : / F a i l e d t o p r o d u c e 1 m e s s a g e t o t o p i c / ,
221+ } ) ;
222+ await expect ( errorNotifications ) . toHaveCount ( 1 ) ;
223+ } ) ;
224+ }
225+ } ) ;
226+ }
227+ } ,
228+ ) ;
225229 }
226230} ) ;
0 commit comments