-
Notifications
You must be signed in to change notification settings - Fork 55
/
DetailsRules.cy.js
91 lines (86 loc) · 2.72 KB
/
DetailsRules.cy.js
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { IntlProvider } from '@redhat-cloud-services/frontend-components-translations/';
import { getStore } from '../../Store';
import rulesfixtures from '../../../cypress/fixtures/detailsrules.json';
import topicsfixtures from '../../../cypress/fixtures/detailsrulestopic.json';
const disableRec = true;
const dropdownOpen = false;
import { DetailsRules } from './DetailsRules';
const ruleDescription = rulesfixtures.description;
const ROOT =
'div[class="pf-l-flex pf-m-column pf-m-row-on-lg pf-m-nowrap ins-c-rule-details"]';
const mountComponent = () => {
const store = getStore();
cy.mount(
<MemoryRouter>
<IntlProvider locale={navigator.language.slice(0, 2)}>
<Provider store={store}>
<DetailsRules
rule={rulesfixtures}
topics={topicsfixtures}
permsDisableRec={disableRec}
setActionsDropdownOpen={null}
actionsDropdownOpen={dropdownOpen}
addNotification={null}
handleModalToggle={null}
refetch={null}
/>
</Provider>
</IntlProvider>
</MemoryRouter>
);
};
describe('test mock data', () => {
it('has total risk set to 4 (critical)', () => {
expect(rulesfixtures.total_risk).to.eq(4);
});
it('reboot is required', () => {
expect(rulesfixtures.reboot_required).to.eq(true);
});
});
describe('defaults', () => {
beforeEach(() => {
mountComponent();
});
it('The Rules description component renders', () => {
cy.get(ROOT).should('have.length', 1);
});
it('title and description are correct', () => {
cy.ouiaType('PF4/Title', 'h1')
.should(($el) => expect($el.text().trim()).to.equal(ruleDescription))
.and('have.length', 1);
cy.get('.ins-c-rule-details__description').should(
'have.text',
rulesfixtures.generic.trim()
);
});
it('rule voting is rendered', () => {
cy.get('.ins-c-rule-details__vote').should(
'contain',
'Is this recommendation helpful?'
);
});
it('shows correct total risk and risk of change labels', () => {
cy.get('.ins-c-rule-details__total-risk').should('contain', 'Critical');
cy.get('.ins-c-rule-details__risk-of-ch-label').should(
'have.text',
'Moderate'
);
});
it('tells that reboot is required', () => {
cy.get('.ins-c-rule-details__reboot').should(
'have.text',
'System reboot is required.'
);
});
it('the request is sent when voted', () => {
cy.intercept('/api/insights/v1/rating', { statusCode: 200 }).as('rating');
cy.ouiaId('thumbsUp')
.click()
.then(() => {
cy.wait('@rating');
});
});
});