-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy path8_WLM_create.cy.js
More file actions
75 lines (60 loc) · 2.59 KB
/
Copy path8_WLM_create.cy.js
File metadata and controls
75 lines (60 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
describe('WLM Create Page', () => {
beforeEach(() => {
cy.visit('/app/workload-management#/wlm-create');
});
it('renders the full create form with required fields', () => {
cy.contains('h1', 'Create workload group').should('exist');
cy.contains('h2', 'Overview').should('exist');
// Form labels and fields
[
'Name',
'Description – Optional',
'Resiliency mode',
'Index wildcard',
'Reject queries when CPU usage exceeds',
'Reject queries when memory usage exceeds',
].forEach((label) => {
cy.contains(label).should('exist');
});
cy.contains('Soft').should('exist');
cy.contains('Enforced').should('exist');
cy.contains('+ Add another rule').should('exist');
cy.get('button').contains('Create workload group').should('exist');
});
it('shows validation errors for CPU and memory thresholds', () => {
cy.get('[data-testid="cpu-threshold-input"]').clear().type('150');
cy.contains('Value must be between 0 and 100').should('exist');
cy.get('[data-testid="cpu-threshold-input"]').clear().type('0');
cy.contains('Value must be between 0 and 100').should('exist');
cy.get('[data-testid="memory-threshold-input"]').clear().type('101');
cy.contains('Value must be between 0 and 100').should('exist');
cy.get('[data-testid="memory-threshold-input"]').clear().type('0');
cy.contains('Value must be between 0 and 100').should('exist');
});
it('creates a workload group successfully with valid inputs', () => {
const groupName = `wlm_test_${Date.now()}`;
cy.get('[data-testid="name-input"]').type(groupName);
cy.contains('Soft').click();
cy.get('[data-testid="indexInput"]').type('test-index');
cy.get('[data-testid="cpu-threshold-input"]').type('10');
cy.get('[data-testid="memory-threshold-input"]').type('20');
cy.intercept('PUT', '/api/_wlm/workload_group').as('createRequest');
cy.get('button').contains('Create workload group').click();
cy.url().should('include', '/workloadManagement');
cy.contains(groupName).should('exist');
});
it('adds and deletes a rule block', () => {
cy.contains('+ Add another rule').click();
cy.get('[data-testid="indexInput"]').should('have.length', 2);
cy.get('[aria-label="Delete rule"]').first().click();
cy.get('[data-testid="indexInput"]').should('have.length', 1);
});
it('navigates back to main page on Cancel', () => {
cy.get('button').contains('Cancel').click();
cy.url().should('include', '/workloadManagement');
});
});