Skip to content

Commit 4539444

Browse files
authored
feat: create/delete/list subscriptions e2e tests (#4180)
1 parent df0d624 commit 4539444

File tree

1 file changed

+291
-0
lines changed

1 file changed

+291
-0
lines changed
Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
import {Organization} from '../../../src/types'
2+
3+
describe('Subscriptions', () => {
4+
beforeEach(() =>
5+
cy.flush().then(() =>
6+
cy.signin().then(() => {
7+
cy.get('@org').then(({id}: Organization) => {
8+
cy.fixture('routes').then(({orgs}) => {
9+
cy.quartzProvision({
10+
accountType: 'pay_as_you_go',
11+
}).then(() => {
12+
cy.visit(`${orgs}/${id}/load-data/sources`)
13+
cy.setFeatureFlags({
14+
subscriptionsUI: true,
15+
})
16+
cy.getByTestID('subscriptions--tab').should('be.visible')
17+
cy.intercept('POST', `/api/v2private/broker/subs*`).as(
18+
'CreateSubscription'
19+
)
20+
cy.intercept('DELETE', `/api/v2private/broker/subs/*`).as(
21+
'DeleteSubscription'
22+
)
23+
cy.intercept('GET', `/api/v2private/broker/subs*`).as(
24+
'GetSubscriptions'
25+
)
26+
})
27+
})
28+
})
29+
})
30+
)
31+
)
32+
33+
it('should navigate to empty subscriptions page via sources tab', () => {
34+
cy.getByTestID('tree-nav-toggle').should('be.visible')
35+
cy.getByTestID('tree-nav-toggle').click()
36+
cy.getByTestID('nav-item-load-data').should('be.visible')
37+
cy.getByTestID('nav-item-load-data').click()
38+
cy.getByTestID('subscriptions--tab').should('be.visible')
39+
cy.getByTestID('load-data-item mqtt')
40+
.scrollIntoView()
41+
.should('be.visible')
42+
cy.getByTestID('load-data-item mqtt').click()
43+
cy.getByTestID('subscriptions-empty-state').should('exist')
44+
})
45+
46+
it('should navigate to empty subscriptions page via load data dropdown', () => {
47+
cy.getByTestID('tree-nav-toggle').should('be.visible')
48+
cy.getByTestID('tree-nav-toggle').click()
49+
cy.getByTestID('nav-item-load-data').should('be.visible')
50+
cy.getByTestID('nav-item-load-data').click()
51+
cy.getByTestID('nav-subitem-subscriptions').should('be.visible')
52+
cy.getByTestID('nav-subitem-subscriptions').click()
53+
cy.getByTestID('subscriptions-empty-state').should('exist')
54+
})
55+
56+
it('should create and delete LP subscription', () => {
57+
cy.getByTestID('subscriptions--tab').click()
58+
cy.getByTestID('create-subscription-button--empty').should('be.visible')
59+
cy.getByTestID('create-subscription-button--empty')
60+
.first()
61+
.click()
62+
// broker form
63+
cy.getByTestID('create-broker-form-overlay').should('be.visible')
64+
// back to create landing
65+
cy.getByTestID('create-broker-form--cancel').should('be.visible')
66+
cy.getByTestID('create-broker-form--cancel').click()
67+
// return to broker form
68+
cy.getByTestID('create-subscription-button--control-bar').should(
69+
'be.visible'
70+
)
71+
cy.getByTestID('create-subscription-button--control-bar')
72+
.first()
73+
.click()
74+
cy.getByTestID('create-broker-form-overlay').should('be.visible')
75+
// fill in broker form
76+
cy.getByTestID('create-broker-form--name').type('My Subscription')
77+
cy.getByTestID('create-broker-form--description').type('My Description')
78+
cy.getByTestID('dropdown')
79+
.contains('MQTT')
80+
.click()
81+
cy.getByTestID('create-broker-form--host').type('localhost')
82+
cy.getByTestID('create-broker-form--port').type('1883')
83+
cy.getByTestID('create-broker-form--submit').click()
84+
// subscription form
85+
cy.getByTestID('create-subscription-form--overlay-form').should(
86+
'be.visible'
87+
)
88+
// back to broker form
89+
cy.getByTestID('create-subscription-form--back').should('be.visible')
90+
cy.getByTestID('create-subscription-form--back').click()
91+
cy.getByTestID('create-broker-form-overlay').should('be.visible')
92+
// return to subscription
93+
cy.getByTestID('create-broker-form--submit').should('be.visible')
94+
cy.getByTestID('create-broker-form--submit').click()
95+
cy.getByTestID('create-subscription-form--overlay-form').should(
96+
'be.visible'
97+
)
98+
// fill in subscription form
99+
cy.getByTestID('create-subscription-form--topic').type('topic')
100+
cy.getByTestID('list-item')
101+
.contains('defbuck')
102+
.click()
103+
cy.getByTestID('create-subscription-form--submit').click()
104+
// parsing form
105+
cy.getByTestID('create-parsing-form-overlay').should('be.visible')
106+
// back to subscription
107+
cy.getByTestID('create-parsing-form--back').should('be.visible')
108+
cy.getByTestID('create-parsing-form--back').click()
109+
cy.getByTestID('create-subscription-form--overlay-form').should(
110+
'be.visible'
111+
)
112+
// return to parsing
113+
cy.getByTestID('create-subscription-form--submit').click()
114+
// line protocol
115+
cy.getByTestID('create-parsing-form-line-protocol--button').click()
116+
cy.getByTestID('create-parsing-form--submit').click()
117+
// wait for intercepts
118+
cy.wait('@CreateSubscription')
119+
cy.wait('@GetSubscriptions')
120+
// subscriptions list view
121+
cy.get('.subscriptions-list').should('be.visible')
122+
cy.get('.cf-resource-card').should('be.visible')
123+
cy.get('.cf-resource-card').should('have.length', 1)
124+
cy.get('.cf-resource-card').contains('My Subscription')
125+
// delete
126+
cy.getByTestID('context-delete-menu--button').should('be.visible')
127+
cy.getByTestID('context-delete-menu--button').click()
128+
cy.getByTestID('context-delete-menu--confirm-button').should('be.visible')
129+
cy.getByTestID('context-delete-menu--confirm-button').click()
130+
// empty list
131+
cy.wait('@DeleteSubscription')
132+
cy.wait('@GetSubscriptions')
133+
cy.getByTestID('subscriptions-empty-state').should('be.visible')
134+
})
135+
it('should create and delete a JSON subscription', () => {
136+
cy.getByTestID('subscriptions--tab').click()
137+
cy.getByTestID('create-subscription-button--control-bar').should(
138+
'be.visible'
139+
)
140+
cy.getByTestID('create-subscription-button--control-bar')
141+
.first()
142+
.click()
143+
// broker form
144+
cy.getByTestID('create-broker-form-overlay').should('be.visible')
145+
cy.getByTestID('create-broker-form--name').type('My Subscription 2')
146+
cy.getByTestID('create-broker-form--description').type('My Description')
147+
cy.getByTestID('dropdown')
148+
.contains('MQTT')
149+
.click()
150+
cy.getByTestID('create-broker-form--host').type('localhost')
151+
cy.getByTestID('create-broker-form--port').type('1883')
152+
cy.getByTestID('create-broker-form--submit').click()
153+
// subscription form
154+
cy.getByTestID('create-subscription-form--overlay-form').should(
155+
'be.visible'
156+
)
157+
cy.getByTestID('create-subscription-form--topic').type('topic')
158+
cy.getByTestID('list-item')
159+
.contains('defbuck')
160+
.click()
161+
cy.getByTestID('create-subscription-form--submit').click()
162+
// parsing form
163+
cy.getByTestID('create-parsing-form-overlay').should('be.visible')
164+
// json
165+
cy.getByTestID('create-parsing-form-json--button').click()
166+
cy.getByTestID('timestamp-json-parsing').type('$.t')
167+
cy.getByTestID('measurement-json-parsing-name').type('m')
168+
cy.getByTestID('measurement-json-parsing-type')
169+
.contains('String')
170+
.click()
171+
cy.getByTestID('measurement-json-parsing-path').type('$.m')
172+
cy.getByTestID('true-json-parsing-name').type('t')
173+
cy.getByTestID('true-json-parsing-type')
174+
.contains('String')
175+
.click()
176+
cy.getByTestID('true-json-parsing-path').type('$.t')
177+
// add field
178+
cy.getByTestID('json-parsing-add-rule').click()
179+
cy.getByTestID('json-parsing-add-rule-1')
180+
.first()
181+
.click()
182+
// delete field
183+
cy.getByTestID('false-json-delete-label--button').should('be.visible')
184+
cy.getByTestID('false-json-delete-label--button')
185+
.first()
186+
.click()
187+
cy.getByTestID('false-json-delete-label--confirm-button').should(
188+
'be.visible'
189+
)
190+
cy.getByTestID('false-json-delete-label--confirm-button').click()
191+
// add field
192+
cy.getByTestID('false-json-parsing-name').type('f')
193+
cy.getByTestID('false-json-parsing-type')
194+
.first()
195+
.contains('String')
196+
.click()
197+
cy.getByTestID('false-json-parsing-path').type('$.f')
198+
// submit
199+
cy.getByTestID('create-parsing-form--submit').click()
200+
// wait for intercepts
201+
cy.wait('@CreateSubscription')
202+
cy.wait('@GetSubscriptions')
203+
// subscriptions list
204+
cy.get('.subscriptions-list').should('be.visible')
205+
cy.get('.cf-resource-card').should('be.visible')
206+
cy.get('.cf-resource-card').should('have.length', 1)
207+
cy.get('.cf-resource-card').contains('My Subscription 2')
208+
// delete
209+
cy.getByTestID('context-delete-menu--button').should('be.visible')
210+
cy.getByTestID('context-delete-menu--button').click()
211+
cy.getByTestID('context-delete-menu--confirm-button').should('be.visible')
212+
cy.getByTestID('context-delete-menu--confirm-button').click()
213+
// empty list
214+
cy.wait('@DeleteSubscription')
215+
cy.wait('@GetSubscriptions')
216+
cy.getByTestID('subscriptions-empty-state').should('be.visible')
217+
})
218+
219+
it('should create and delete a String subscription', () => {
220+
cy.getByTestID('subscriptions--tab').click()
221+
cy.getByTestID('create-subscription-button--control-bar').should(
222+
'be.visible'
223+
)
224+
cy.getByTestID('create-subscription-button--control-bar')
225+
.first()
226+
.click()
227+
// broker form
228+
cy.getByTestID('create-broker-form-overlay').should('be.visible')
229+
cy.getByTestID('create-broker-form--name').type('My Subscription 3')
230+
cy.getByTestID('create-broker-form--description').type('My Description')
231+
cy.getByTestID('dropdown')
232+
.contains('MQTT')
233+
.click()
234+
cy.getByTestID('create-broker-form--host').type('localhost')
235+
cy.getByTestID('create-broker-form--port').type('1883')
236+
cy.getByTestID('create-broker-form--submit').click()
237+
// subscription form
238+
cy.getByTestID('create-subscription-form--overlay-form').should(
239+
'be.visible'
240+
)
241+
cy.getByTestID('create-subscription-form--topic').type('topic')
242+
cy.getByTestID('list-item')
243+
.contains('defbuck')
244+
.click()
245+
cy.getByTestID('create-subscription-form--submit').click()
246+
// parsing form
247+
cy.getByTestID('create-parsing-form-overlay').should('be.visible')
248+
// string
249+
cy.getByTestID('create-parsing-form-string--button').click()
250+
cy.getByTestID('timestamp-string-parsing').type('0123456789')
251+
cy.getByTestID('measurment-string-parsing-pattern').type('m=//m')
252+
cy.getByTestID('Tag-string-parsing-name').type('tag')
253+
cy.getByTestID('Tag-string-parsing-pattern').type('t=//t')
254+
// add field
255+
cy.getByTestID('string-parsing-add-rule').click()
256+
cy.getByTestID('string-parsing-add-rule-1')
257+
.first()
258+
.click()
259+
// delete field
260+
cy.getByTestID('Field-string-delete-label--button').should('be.visible')
261+
cy.getByTestID('Field-string-delete-label--button')
262+
.first()
263+
.click()
264+
cy.getByTestID('Field-string-delete-label--confirm-button').should(
265+
'be.visible'
266+
)
267+
cy.getByTestID('Field-string-delete-label--confirm-button').click()
268+
// add field
269+
cy.getByTestID('Field-string-parsing-name').type('field')
270+
cy.getByTestID('Field-string-parsing-pattern').type('f=//f')
271+
// submit
272+
cy.getByTestID('create-parsing-form--submit').click()
273+
// wait for intercepts
274+
cy.wait('@CreateSubscription')
275+
cy.wait('@GetSubscriptions')
276+
// list page
277+
cy.get('.subscriptions-list').should('be.visible')
278+
cy.get('.cf-resource-card').should('be.visible')
279+
cy.get('.cf-resource-card').should('have.length', 1)
280+
cy.get('.cf-resource-card').contains('My Subscription 3')
281+
// delete
282+
cy.getByTestID('context-delete-menu--button').should('be.visible')
283+
cy.getByTestID('context-delete-menu--button').click()
284+
cy.getByTestID('context-delete-menu--confirm-button').should('be.visible')
285+
cy.getByTestID('context-delete-menu--confirm-button').click()
286+
// empty list
287+
cy.wait('@DeleteSubscription')
288+
cy.wait('@GetSubscriptions')
289+
cy.getByTestID('subscriptions-empty-state').should('be.visible')
290+
})
291+
})

0 commit comments

Comments
 (0)