Skip to content

Commit 8cdb823

Browse files
Refactored single test into multiple for schedule form
1 parent 0f7454e commit 8cdb823

File tree

2 files changed

+311
-298
lines changed

2 files changed

+311
-298
lines changed
Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
/* eslint-disable no-undef */
2+
3+
function addSchedule() {
4+
cy.get('#miq_schedule_vmdb_choice').click();
5+
cy.get('ul[aria-label="Configuration"] [title="Add a new Schedule"]').click();
6+
// Checks if Save button is disabled initially
7+
cy.contains(
8+
'#main-content .bx--btn-set button[type="submit"]',
9+
'Save'
10+
).should('be.disabled');
11+
// Adding data
12+
cy.get('input#name').type('Test name');
13+
cy.get('input#description').type('Test description');
14+
cy.get('input[type="checkbox"]#enabled').check({ force: true });
15+
cy.get('select#action_typ').select('VM Analysis');
16+
cy.get('select#filter_typ').select('A single VM');
17+
cy.get('select#timer_typ').select('Hourly');
18+
cy.get('select#timer_value').select('1 Hour');
19+
cy.get('input[role="combobox"]#time_zone').click();
20+
cy.contains('[role="option"]', '(GMT-10:00) Hawaii')
21+
.should('be.visible')
22+
.click();
23+
cy.get('input#start_date').type('06/30/2025', { force: true });
24+
cy.get('input#start_time').type('11:23');
25+
// Checks if Save button is enabled once all required fields are filled
26+
cy.contains('#main-content .bx--btn-set button[type="submit"]', 'Save')
27+
.should('be.enabled')
28+
.click();
29+
}
30+
31+
describe('Automate Schedule form operations: Settings > Application Settings > Settings > Schedules > Configuration > Add a new schedule', () => {
32+
beforeEach(() => {
33+
cy.login();
34+
cy.menu('Settings', 'Application Settings');
35+
cy.get('[title="Schedules"]')
36+
.click();
37+
});
38+
39+
it('Validate visibility of elements based on dropdown selections', () => {
40+
cy.get('#miq_schedule_vmdb_choice').click();
41+
cy.get(
42+
'ul[aria-label="Configuration"] [title="Add a new Schedule"]'
43+
).click();
44+
45+
/* ===== Selecting any option other than "Automation Tasks" from "Action" dropdown does not hide the Filter dropdown ===== */
46+
47+
cy.get('select#action_typ').select('VM Analysis');
48+
cy.get('select#action_typ').should('have.value', 'vm');
49+
// Checking for Filter type dropdown
50+
cy.get('label[for="filter_typ"]').should('exist');
51+
cy.get('select#filter_typ').should('exist');
52+
53+
cy.get('select#action_typ').select('Template Analysis');
54+
cy.get('select#action_typ').should('have.value', 'miq_template');
55+
// Checking for Filter type dropdown
56+
cy.get('label[for="filter_typ"]').should('exist');
57+
cy.get('select#filter_typ').should('exist');
58+
59+
cy.get('select#action_typ').select('Host Analysis');
60+
cy.get('select#action_typ').should('have.value', 'host');
61+
// Checking for Filter type dropdown
62+
cy.get('label[for="filter_typ"]').should('exist');
63+
cy.get('select#filter_typ').should('exist');
64+
65+
cy.get('select#action_typ').select('Container Image Analysis');
66+
cy.get('select#action_typ').should('have.value', 'container_image');
67+
// Checking for Filter type dropdown
68+
cy.get('label[for="filter_typ"]').should('exist');
69+
cy.get('select#filter_typ').should('exist');
70+
71+
cy.get('select#action_typ').select('Cluster Analysis');
72+
cy.get('select#action_typ').should('have.value', 'emscluster');
73+
// Checking for Filter type dropdown
74+
cy.get('label[for="filter_typ"]').should('exist');
75+
cy.get('select#filter_typ').should('exist');
76+
77+
cy.get('select#action_typ').select('Datastore Analysis');
78+
cy.get('select#action_typ').should('have.value', 'storage');
79+
// Checking for Filter type dropdown
80+
cy.get('label[for="filter_typ"]').should('exist');
81+
cy.get('select#filter_typ').should('exist');
82+
83+
cy.get('select#action_typ').select('VM Compliance Check');
84+
cy.get('select#action_typ').should('have.value', 'vm_check_compliance');
85+
// Checking for Filter type dropdown
86+
cy.get('label[for="filter_typ"]').should('exist');
87+
cy.get('select#filter_typ').should('exist');
88+
89+
cy.get('select#action_typ').select('Host Compliance Check');
90+
cy.get('select#action_typ').should('have.value', 'host_check_compliance');
91+
// Checking for Filter type dropdown
92+
cy.get('label[for="filter_typ"]').should('exist');
93+
cy.get('select#filter_typ').should('exist');
94+
95+
cy.get('select#action_typ').select('Container Image Compliance Check');
96+
cy.get('select#action_typ').should(
97+
'have.value',
98+
'container_image_check_compliance'
99+
);
100+
// Checking for Filter type dropdown
101+
cy.get('label[for="filter_typ"]').should('exist');
102+
cy.get('select#filter_typ').should('exist');
103+
104+
/* ===== Selecting "Automation Tasks" option from "Action" dropdown shows Zone, Object details & Object fields ===== */
105+
106+
cy.get('select#action_typ').select('Automation Tasks');
107+
cy.get('select#action_typ').should('have.value', 'automation_request');
108+
109+
// Checking for Zone dropdown
110+
cy.get('label[for="zone_id"]').should('exist');
111+
cy.get('select#zone_id').should('exist');
112+
113+
// Checking for Object Details
114+
cy.get('h3[name="object_details"]').should('exist');
115+
// Checking for System/Process dropdown
116+
cy.get('label[for="instance_name"]').should('exist');
117+
cy.get('select#instance_name').should('exist');
118+
// Checking for Messsage textfield
119+
cy.get('label[for="message"]').should('exist');
120+
cy.get('input#message').should('exist');
121+
// Checking for Request textfield
122+
cy.get('label[for="request"]').should('exist');
123+
cy.get('input#request').should('exist');
124+
125+
// Checking for Object
126+
cy.get('h3[name="object_attributes"]').should('exist');
127+
// Checking for Type Combobox
128+
cy.get('label[for="target_class"]').should('exist');
129+
cy.get('input[role="combobox"]#target_class').should('exist');
130+
// Checking for Object Combobox
131+
cy.get('label[for="target_id"]').should('exist');
132+
cy.get('input[role="combobox"]#target_id').should('exist');
133+
134+
// Checking for Attribute/Value pairs
135+
cy.contains('h3', 'Attribute/Value Pairs').should('exist');
136+
// Checking for 5 attribute-value pairs text fields
137+
cy.get('input#attribute_1').should('exist');
138+
cy.get('input#value_1').should('exist');
139+
cy.get('input#attribute_2').should('exist');
140+
cy.get('input#value_2').should('exist');
141+
cy.get('input#attribute_3').should('exist');
142+
cy.get('input#value_3').should('exist');
143+
cy.get('input#attribute_4').should('exist');
144+
cy.get('input#value_4').should('exist');
145+
cy.get('input#attribute_5').should('exist');
146+
cy.get('input#value_5').should('exist');
147+
148+
/* ===== Selecting "Once" option from "Run" dropdown does not show the "Every" dropdown ===== */
149+
150+
cy.get('select#timer_typ').select('Once');
151+
// Checking whether the Every dropdown is hidden
152+
cy.get('input#timer_value').should('not.exist');
153+
154+
/* ===== Selecting any other option other than "Once" from "Run" dropdown shows the "Every" dropdown ===== */
155+
156+
cy.get('select#timer_typ').select('Hours', { force: true });
157+
// Checking whether the "Every" dropdown exist
158+
cy.get('label[for="timer_value"]').should('exist');
159+
cy.get('select#timer_value').should('exist');
160+
161+
cy.get('select#timer_typ').select('Days', { force: true });
162+
// Checking whether the "Every" dropdown exist
163+
cy.get('label[for="timer_value"]').should('exist');
164+
cy.get('select#timer_value').should('exist');
165+
166+
cy.get('select#timer_typ').select('Weeks', { force: true });
167+
// Checking whether the "Every" dropdown exist
168+
cy.get('label[for="timer_value"]').should('exist');
169+
cy.get('select#timer_value').should('exist');
170+
171+
cy.get('select#timer_typ').select('Months', { force: true });
172+
// Checking whether the "Every" dropdown exist
173+
cy.get('label[for="timer_value"]').should('exist');
174+
cy.get('select#timer_value').should('exist');
175+
});
176+
177+
it('Checking whether Cancel button works on the Add form', () => {
178+
cy.get('#miq_schedule_vmdb_choice').click();
179+
cy.get(
180+
'ul[aria-label="Configuration"] [title="Add a new Schedule"]'
181+
).click();
182+
cy.contains('#main-content .bx--btn-set button[type="button"]', 'Cancel')
183+
.should('be.enabled')
184+
.click();
185+
cy.get('#main_div #flash_msg_div .alert-success').contains(
186+
'Add was cancelled by the user'
187+
);
188+
});
189+
190+
it('Checking whether adding a schedule works', () => {
191+
addSchedule();
192+
cy.get('#main_div #flash_msg_div .alert-success').contains(
193+
'Schedule "Test name" was saved'
194+
);
195+
});
196+
197+
it('Checking whether creating a duplicate record is restricted', () => {
198+
addSchedule();
199+
cy.get('#main_div #flash_msg_div .alert-danger').contains(
200+
'Error when adding a new schedule: Validation failed: MiqSchedule: Name has already been taken'
201+
);
202+
});
203+
204+
it('Checking whether Cancel button works on the Edit form', () => {
205+
// Selecting the created schedule
206+
cy.contains('li.list-group-item', 'Test name').click();
207+
cy.get('#miq_schedule_vmdb_choice').click();
208+
cy.get(
209+
'ul[aria-label="Configuration"] [title="Edit this Schedule"]'
210+
).click();
211+
cy.contains('#main-content .bx--btn-set button[type="button"]', 'Cancel')
212+
.should('be.enabled')
213+
.click();
214+
cy.get('#main_div #flash_msg_div .alert-success').contains(
215+
'Edit of "Test name" was cancelled by the user'
216+
);
217+
});
218+
219+
it('Checking whether Reset button works on the Edit form', () => {
220+
// Selecting the created schedule
221+
cy.contains('li.list-group-item', 'Test name').click();
222+
cy.get('#miq_schedule_vmdb_choice').click();
223+
cy.get(
224+
'ul[aria-label="Configuration"] [title="Edit this Schedule"]'
225+
).click();
226+
// Editing description and start date
227+
cy.get('input#description').clear().type('Dummy description');
228+
cy.get('input#start_date').clear().type('07/21/2025', { force: true });
229+
cy.contains('#main-content .bx--btn-set button[type="button"]', 'Reset')
230+
.should('be.enabled')
231+
.click();
232+
cy.get('#main_div #flash_msg_div .alert-warning').contains(
233+
'All changes have been reset'
234+
);
235+
// Confirming the edited fields contain the old values after resetting
236+
cy.get('input#description').should('have.value', 'Test description');
237+
cy.get('input#start_date').should('have.value', '06/30/2025');
238+
});
239+
240+
it('Checking whether Edit functionality works', () => {
241+
// Selecting the created schedule
242+
cy.contains('li.list-group-item', 'Test name').click();
243+
cy.get('#miq_schedule_vmdb_choice').click();
244+
cy.get(
245+
'ul[aria-label="Configuration"] [title="Edit this Schedule"]'
246+
).click();
247+
// Editing name and description
248+
cy.get('input#name').clear().type('Dummy name');
249+
cy.get('input#description').clear().type('Dummy description');
250+
// Confirms Save button is enabled after making edits
251+
cy.contains('#main-content .bx--btn-set button[type="submit"]', 'Save')
252+
.should('be.enabled')
253+
.click();
254+
cy.get('#main_div #flash_msg_div .alert-success').contains(
255+
'Schedule "Dummy name" was saved'
256+
);
257+
});
258+
259+
it('Checking whether Disabling, Enabling & Queueing up the schedule works', () => {
260+
// Selecting the schedule
261+
cy.contains('li.list-group-item', 'Dummy name').click();
262+
263+
/* ===== Disabling the Schedule ===== */
264+
265+
cy.get('#miq_schedule_vmdb_choice').click();
266+
cy.get(
267+
'ul[aria-label="Configuration"] [title="Disable this Schedule"]'
268+
).click();
269+
cy.get('#main_div #flash_msg_div .alert-info').contains(
270+
'The selected Schedules were disabled'
271+
);
272+
273+
/* ===== Enabling the Schedule ===== */
274+
275+
cy.get('#miq_schedule_vmdb_choice').click();
276+
cy.get(
277+
'ul[aria-label="Configuration"] [title="Enable this Schedule"]'
278+
).click();
279+
cy.get('#main_div #flash_msg_div .alert-info').contains(
280+
'The selected Schedules were enabled'
281+
);
282+
283+
/* ===== Queueing-up the Schedule ===== */
284+
285+
cy.get('#miq_schedule_vmdb_choice').click();
286+
cy.get(
287+
'ul[aria-label="Configuration"] [title="Queue up this Schedule to run now"]'
288+
).click();
289+
cy.get('#main_div #flash_msg_div .alert-success').contains(
290+
'The selected Schedule has been queued to run'
291+
);
292+
});
293+
294+
it('Checking whether Deleting the schedule works', () => {
295+
// Selecting the schedule
296+
cy.contains('li.list-group-item', 'Dummy name').click();
297+
cy.get('#miq_schedule_vmdb_choice').click();
298+
cy.on('window:confirm', (text) => {
299+
expect(text).to.eq(
300+
'Warning: This Schedule and ALL of its components will be permanently removed!'
301+
);
302+
return true;
303+
});
304+
cy.get(
305+
'ul[aria-label="Configuration"] [title="Delete this Schedule from the Database"]'
306+
).click();
307+
cy.get('#main_div #flash_msg_div .alert-success').contains(
308+
'Schedule "Dummy name": Delete successful'
309+
);
310+
});
311+
});

0 commit comments

Comments
 (0)