@centreon/ui 26.12.0 → 26.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -3
- package/public/mockServiceWorker.js +31 -8
- package/src/Dashboard/Dashboard.browser.test.tsx +107 -0
- package/src/Form/Form.browser.test.tsx +445 -0
- package/src/Form/Inputs/ExclusiveCheckboxGroup.browser.test.tsx +304 -0
- package/src/Form/Inputs/SegmentedButtons.browser.test.tsx +113 -0
- package/src/InputField/Number/Number.browser.test.tsx +109 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.browser.test.tsx +250 -0
- package/src/Listing/Listing.browser.test.tsx +476 -0
- package/src/Module/Module.browser.test.tsx +145 -0
- package/src/Pagination/Pagination.browser.test.tsx +184 -0
- package/src/Panel/Section/index.test.tsx +1 -1
- package/src/RichTextEditor/RichTextEditor.browser.test.tsx +567 -0
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +3 -1
- package/src/TimePeriods/ResolutionTimePeriod.browser.test.tsx +143 -0
- package/src/TimePeriods/TimePeriods.browser.test.tsx +468 -0
- package/src/Typography/FluidTypography/FluidTypography.browser.test.tsx +54 -0
- package/src/api/useMutationQuery/useMutationQuery.browser.test.tsx +154 -0
- package/src/components/CollapsibleItem/CollapsibleItem.browser.test.tsx +120 -0
- package/src/components/CopyCommand/CopyCommand.browser.test.tsx +287 -0
- package/src/components/CrudPage/CrudPage.browser.test.tsx +659 -0
- package/src/components/DataTable/DataTable.browser.test.tsx +257 -0
- package/src/components/Form/AccessRights/AccessRights.browser.test.tsx +527 -0
- package/src/components/ItemComposition/ItemComposition.browser.test.tsx +172 -0
- package/src/components/Layout/PageLayout.browser.test.tsx +114 -0
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.browser.test.tsx +237 -0
- package/src/components/SortableEntriesList/SortableEntriesList.browser.test.tsx +981 -0
- package/src/components/Tabs/Tabs.browser.test.tsx +115 -0
- package/src/utils/useFullscreen/Fullscreen.browser.test.tsx +176 -0
- package/src/utils/useLocale/useLocale.browser.test.tsx +49 -0
- package/src/utils/useLocaleTimezoneDate/{LocaleTimezoneDate.cypress.spec.tsx → LocaleTimezoneDate.browser.test.tsx} +24 -11
- package/src/Dashboard/Dashboard.cypress.spec.tsx +0 -71
- package/src/Form/Form.cypress.spec.tsx +0 -306
- package/src/Form/Inputs/ExclusiveCheckboxGroup.cypress.spec.tsx +0 -236
- package/src/Form/Inputs/SegmentedButtons.cypress.spec.tsx +0 -101
- package/src/InputField/Number/Number.cypress.spec.tsx +0 -89
- package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.cypress.spec.tsx +0 -182
- package/src/Listing/Listing.cypress.spec.tsx +0 -349
- package/src/Module/Module.cypress.spec.tsx +0 -127
- package/src/Pagination/Pagination.cypress.spec.tsx +0 -140
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +0 -408
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +0 -74
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +0 -488
- package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +0 -27
- package/src/api/useMutationQuery/useMutationQuery.cypress.spec.tsx +0 -93
- package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +0 -76
- package/src/components/CopyCommand/CopyCommand.cypress.spec.tsx +0 -167
- package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -561
- package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -174
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +0 -376
- package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +0 -112
- package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -64
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.cypress.spec.tsx +0 -171
- package/src/components/SortableEntriesList/SortableEntriesList.cypress.spec.tsx +0 -792
- package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -69
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +0 -130
- package/src/utils/useLocale/useLocale.cypress.spec.tsx +0 -40
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { createStore } from 'jotai';
|
|
2
|
-
|
|
3
|
-
import { Method } from '..';
|
|
4
|
-
import Module from '.';
|
|
5
|
-
import LicensedModule from './LicensedModule';
|
|
6
|
-
|
|
7
|
-
const initializeModule = (): void => {
|
|
8
|
-
cy.mount({
|
|
9
|
-
Component: (
|
|
10
|
-
<Module seedName="seed" store={createStore()}>
|
|
11
|
-
<p>Module</p>
|
|
12
|
-
</Module>
|
|
13
|
-
)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const initializeModuleWithValidLicense = (
|
|
18
|
-
isFederatedComponent = false
|
|
19
|
-
): void => {
|
|
20
|
-
cy.interceptAPIRequest({
|
|
21
|
-
alias: 'getValidLicense',
|
|
22
|
-
method: Method.GET,
|
|
23
|
-
path: './api/internal.php?object=centreon_license_manager&action=licenseValid&productName=valid',
|
|
24
|
-
response: {
|
|
25
|
-
success: true
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
cy.mount({
|
|
30
|
-
Component: (
|
|
31
|
-
<div style={{ height: '100vh' }}>
|
|
32
|
-
<LicensedModule
|
|
33
|
-
isFederatedComponent={isFederatedComponent}
|
|
34
|
-
moduleName="valid"
|
|
35
|
-
seedName="seed"
|
|
36
|
-
store={createStore()}
|
|
37
|
-
>
|
|
38
|
-
<p>Module</p>
|
|
39
|
-
</LicensedModule>
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const initializeModuleWithInvalidLicense = (
|
|
46
|
-
isFederatedComponent = false
|
|
47
|
-
): void => {
|
|
48
|
-
cy.interceptAPIRequest({
|
|
49
|
-
alias: 'getInvalidLicense',
|
|
50
|
-
method: Method.GET,
|
|
51
|
-
path: './api/internal.php?object=centreon_license_manager&action=licenseValid&productName=invalid',
|
|
52
|
-
response: {
|
|
53
|
-
success: false
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
cy.mount({
|
|
58
|
-
Component: (
|
|
59
|
-
<div style={{ height: '100vh' }}>
|
|
60
|
-
<LicensedModule
|
|
61
|
-
isFederatedComponent={isFederatedComponent}
|
|
62
|
-
moduleName="invalid"
|
|
63
|
-
seedName="seed"
|
|
64
|
-
store={createStore()}
|
|
65
|
-
>
|
|
66
|
-
<p>Module</p>
|
|
67
|
-
</LicensedModule>
|
|
68
|
-
</div>
|
|
69
|
-
)
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
describe('Module', () => {
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
initializeModule();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('displays the content of the module', () => {
|
|
79
|
-
cy.contains('Module').should('be.visible');
|
|
80
|
-
|
|
81
|
-
cy.makeSnapshot();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe('Valid license module', () => {
|
|
86
|
-
it('displays the content of the page when the license is valid license', () => {
|
|
87
|
-
initializeModuleWithValidLicense();
|
|
88
|
-
cy.waitForRequest('@getValidLicense');
|
|
89
|
-
|
|
90
|
-
cy.contains('Module').should('be.visible');
|
|
91
|
-
|
|
92
|
-
cy.makeSnapshot();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('displays the content of the component when the license is valid license', () => {
|
|
96
|
-
initializeModuleWithValidLicense(true);
|
|
97
|
-
|
|
98
|
-
cy.contains('Module').should('be.visible');
|
|
99
|
-
|
|
100
|
-
cy.makeSnapshot();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe('Invalid license module', () => {
|
|
105
|
-
it('displays the content of the page when the license is invalid license', () => {
|
|
106
|
-
initializeModuleWithInvalidLicense();
|
|
107
|
-
cy.waitForRequest('@getInvalidLicense');
|
|
108
|
-
|
|
109
|
-
cy.contains('Module').should('not.exist');
|
|
110
|
-
|
|
111
|
-
cy.contains('Oops').should('be.visible');
|
|
112
|
-
cy.contains('License invalid or expired').should('be.visible');
|
|
113
|
-
cy.contains('Please contact your administrator.').should('be.visible');
|
|
114
|
-
cy.get('img[alt="License invalid or expired !"]').should('be.visible');
|
|
115
|
-
cy.get('img[alt="Centreon Logo"]').should('be.visible');
|
|
116
|
-
|
|
117
|
-
cy.makeSnapshot();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('displays the content of the module when the license is invalid license', () => {
|
|
121
|
-
initializeModuleWithInvalidLicense(true);
|
|
122
|
-
|
|
123
|
-
cy.contains('Module').should('not.exist');
|
|
124
|
-
|
|
125
|
-
cy.makeSnapshot();
|
|
126
|
-
});
|
|
127
|
-
});
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import TestQueryProvider from '../api/TestQueryProvider';
|
|
2
|
-
import { Method } from '../api/useMutationQuery';
|
|
3
|
-
import { labelNextPage, labelPreviousPage } from '../Listing/translatedLabels';
|
|
4
|
-
import Pagination from './Pagination';
|
|
5
|
-
import { generateItems } from './utils';
|
|
6
|
-
|
|
7
|
-
const defaultTotalItems = 25;
|
|
8
|
-
const itemsPerPage = 6;
|
|
9
|
-
const totalPages = Math.ceil(defaultTotalItems / itemsPerPage);
|
|
10
|
-
|
|
11
|
-
const initialize = ({
|
|
12
|
-
total = defaultTotalItems,
|
|
13
|
-
currentPage = 1
|
|
14
|
-
}: {
|
|
15
|
-
total?: number;
|
|
16
|
-
currentPage?: number;
|
|
17
|
-
}) => {
|
|
18
|
-
cy.interceptAPIRequest({
|
|
19
|
-
alias: 'list',
|
|
20
|
-
method: Method.GET,
|
|
21
|
-
path: '**/listing**',
|
|
22
|
-
response: {
|
|
23
|
-
meta: {
|
|
24
|
-
limit: itemsPerPage,
|
|
25
|
-
page: currentPage,
|
|
26
|
-
total
|
|
27
|
-
},
|
|
28
|
-
result: generateItems(itemsPerPage)
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
cy.mount({
|
|
33
|
-
Component: (
|
|
34
|
-
<div
|
|
35
|
-
style={{
|
|
36
|
-
alignItems: 'center',
|
|
37
|
-
display: 'flex',
|
|
38
|
-
height: '100vh',
|
|
39
|
-
justifyContent: 'center',
|
|
40
|
-
width: '100%'
|
|
41
|
-
}}
|
|
42
|
-
>
|
|
43
|
-
<div
|
|
44
|
-
style={{
|
|
45
|
-
boxShadow: '2px 2px 4px rgba(0, 0, 0, 0.2)',
|
|
46
|
-
height: '176px'
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
<TestQueryProvider>
|
|
50
|
-
<Pagination
|
|
51
|
-
api={{ baseEndpoint: '/test/listing', queryKey: ['test'] }}
|
|
52
|
-
/>
|
|
53
|
-
</TestQueryProvider>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
)
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
describe('Pagination Component', () => {
|
|
61
|
-
it('render with correct initial state', () => {
|
|
62
|
-
initialize({});
|
|
63
|
-
cy.waitForRequest('@list');
|
|
64
|
-
|
|
65
|
-
cy.findByTestId(labelPreviousPage).should('be.disabled');
|
|
66
|
-
|
|
67
|
-
cy.findByTestId(labelNextPage).should('not.be.disabled');
|
|
68
|
-
|
|
69
|
-
cy.contains(`Page 1/${totalPages}`);
|
|
70
|
-
|
|
71
|
-
cy.makeSnapshot();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('hides pagination controls when only one page exists', () => {
|
|
75
|
-
initialize({ total: itemsPerPage });
|
|
76
|
-
cy.waitForRequest('@list');
|
|
77
|
-
|
|
78
|
-
cy.findByTestId(labelPreviousPage).should('not.exist');
|
|
79
|
-
cy.findByTestId(labelNextPage).should('not.exist');
|
|
80
|
-
cy.contains(/Page \d+\/\d+/).should('not.exist');
|
|
81
|
-
|
|
82
|
-
cy.makeSnapshot();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('navigates forward through pages correctly', () => {
|
|
86
|
-
initialize({});
|
|
87
|
-
cy.waitForRequest('@list');
|
|
88
|
-
|
|
89
|
-
cy.contains(`Page 1/${totalPages}`);
|
|
90
|
-
|
|
91
|
-
Array.from({ length: totalPages - 1 }).forEach((_, index) => {
|
|
92
|
-
cy.findByTestId(labelNextPage).click();
|
|
93
|
-
cy.waitForRequest('@list');
|
|
94
|
-
|
|
95
|
-
cy.contains(`Page ${index + 2}/${totalPages}`);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
cy.findByTestId(labelNextPage).should('be.disabled');
|
|
99
|
-
|
|
100
|
-
cy.makeSnapshot();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('navigates backward through pages correctly', () => {
|
|
104
|
-
initialize({});
|
|
105
|
-
|
|
106
|
-
cy.waitForRequest('@list');
|
|
107
|
-
|
|
108
|
-
Array.from({ length: totalPages - 1 }).forEach(() => {
|
|
109
|
-
cy.findByTestId(labelNextPage).click();
|
|
110
|
-
|
|
111
|
-
cy.waitForRequest('@list');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
Array.from({ length: totalPages - 1 }).forEach((_, index) => {
|
|
115
|
-
cy.findByTestId(labelPreviousPage).click();
|
|
116
|
-
cy.waitForRequest('@list');
|
|
117
|
-
|
|
118
|
-
cy.contains(`Page ${totalPages - index - 1}/${totalPages}`);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
cy.findByTestId(labelPreviousPage).should('be.disabled');
|
|
122
|
-
|
|
123
|
-
cy.makeSnapshot();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('enables both buttons when on middle page', () => {
|
|
127
|
-
initialize({});
|
|
128
|
-
|
|
129
|
-
cy.waitForRequest('@list');
|
|
130
|
-
|
|
131
|
-
cy.findByTestId(labelNextPage).click();
|
|
132
|
-
|
|
133
|
-
cy.waitForRequest('@list');
|
|
134
|
-
|
|
135
|
-
cy.findByTestId(labelPreviousPage).should('not.be.disabled');
|
|
136
|
-
cy.findByTestId(labelNextPage).should('not.be.disabled');
|
|
137
|
-
|
|
138
|
-
cy.makeSnapshot();
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
import { standardMacros } from './plugins/ToolbarPlugin/MacrosButton';
|
|
2
|
-
import RichTextEditor from './RichTextEditor';
|
|
3
|
-
import { labelAlignPicker } from './translatedLabels';
|
|
4
|
-
|
|
5
|
-
interface CheckElementStyleOnRichTextEditorProps {
|
|
6
|
-
check: boolean;
|
|
7
|
-
element: HTMLElement;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const mockInititalStateToEditor =
|
|
11
|
-
'{"root": {"children": [{"children": [{"detail": 0,"format": 0,"mode": "normal","style": "","text": "test Cypress","type": "text","version": 1}],"direction": "ltr","format": "","indent": 0,"type": "paragraph","version": 1}],"direction": "ltr","format": "","indent": 0,"type": "root","version": 1}}';
|
|
12
|
-
|
|
13
|
-
const checkElementStyleOnRichTextEditor = ({
|
|
14
|
-
element,
|
|
15
|
-
check
|
|
16
|
-
}: CheckElementStyleOnRichTextEditorProps): void => {
|
|
17
|
-
cy.wrap(element).should('be.visible');
|
|
18
|
-
|
|
19
|
-
if (check) {
|
|
20
|
-
cy.wrap(element)
|
|
21
|
-
.contains('strong', 'cypress test')
|
|
22
|
-
.should('have.css', 'font-style')
|
|
23
|
-
.and('match', /italic/);
|
|
24
|
-
|
|
25
|
-
cy.wrap(element)
|
|
26
|
-
.contains('strong', 'cypress test')
|
|
27
|
-
.should('have.css', 'text-decoration')
|
|
28
|
-
.and('match', /underline line-through/);
|
|
29
|
-
} else {
|
|
30
|
-
cy.wrap(element)
|
|
31
|
-
.contains('p', 'cypress test')
|
|
32
|
-
.invoke('css', 'font-style')
|
|
33
|
-
.and('not.match', /italic/);
|
|
34
|
-
|
|
35
|
-
cy.wrap(element)
|
|
36
|
-
.contains('p', 'cypress test')
|
|
37
|
-
.invoke('css', 'text-decoration')
|
|
38
|
-
.and('not.match', /underline line-through/);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
describe('Rich Text Editor', () => {
|
|
43
|
-
describe('Editable Rich Text Editor', () => {
|
|
44
|
-
beforeEach(() => {
|
|
45
|
-
cy.mount({ Component: <RichTextEditor editable /> });
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('displays all elements when RichTextEditor is called with required props', () => {
|
|
49
|
-
cy.findByLabelText('Undo').should('be.visible');
|
|
50
|
-
cy.findByLabelText('Redo').should('be.visible');
|
|
51
|
-
cy.findByLabelText('align picker').should('be.visible');
|
|
52
|
-
cy.findByLabelText('block').should('be.visible');
|
|
53
|
-
cy.findByLabelText('format').should('be.visible');
|
|
54
|
-
cy.findByLabelText('link').should('be.visible');
|
|
55
|
-
cy.findByLabelText('list').should('be.visible');
|
|
56
|
-
|
|
57
|
-
cy.findByLabelText('RichTextEditor')
|
|
58
|
-
.should('be.visible')
|
|
59
|
-
.and('have.value', '');
|
|
60
|
-
|
|
61
|
-
cy.findByLabelText('RichTextEditor').parent().contains('Type here...');
|
|
62
|
-
|
|
63
|
-
cy.makeSnapshot();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('displays all format actions when the format button is clicked', () => {
|
|
67
|
-
cy.findByLabelText('format').click();
|
|
68
|
-
|
|
69
|
-
cy.findByLabelText('bold').should('be.visible');
|
|
70
|
-
cy.findByLabelText('italic').should('be.visible');
|
|
71
|
-
cy.findByLabelText('underline').should('be.visible');
|
|
72
|
-
cy.findByLabelText('strikethrough').should('be.visible');
|
|
73
|
-
|
|
74
|
-
cy.makeSnapshot();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('displays changes with undo redo buttons', () => {
|
|
78
|
-
cy.get('[data-testid="RichTextEditor"]').type('cypress test');
|
|
79
|
-
cy.get('[data-testid="RichTextEditor"]').should(
|
|
80
|
-
'have.text',
|
|
81
|
-
'cypress test'
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
cy.findByLabelText('Undo').click();
|
|
85
|
-
|
|
86
|
-
cy.get('[data-testid="RichTextEditor"]').should('have.text', '');
|
|
87
|
-
|
|
88
|
-
cy.findByLabelText('Redo').click();
|
|
89
|
-
|
|
90
|
-
cy.get('[data-testid="RichTextEditor"]').should(
|
|
91
|
-
'have.text',
|
|
92
|
-
'cypress test'
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('displays changes with bold, italic, underline and strikethrough buttons', () => {
|
|
97
|
-
cy.get('[data-testid="RichTextEditor"]').type('cypress test');
|
|
98
|
-
|
|
99
|
-
cy.get('[data-testid="RichTextEditor"]').focus().type('{selectAll}');
|
|
100
|
-
|
|
101
|
-
cy.findByLabelText('format').click();
|
|
102
|
-
cy.findByLabelText('bold').click();
|
|
103
|
-
|
|
104
|
-
cy.findByLabelText('format').click();
|
|
105
|
-
cy.findByLabelText('italic').click();
|
|
106
|
-
|
|
107
|
-
cy.findByLabelText('format').click();
|
|
108
|
-
cy.findByLabelText('underline').click();
|
|
109
|
-
|
|
110
|
-
cy.findByLabelText('format').click();
|
|
111
|
-
cy.findByLabelText('strikethrough').click();
|
|
112
|
-
|
|
113
|
-
cy.findByTestId('RichTextEditor').then((element: HTMLElement) => {
|
|
114
|
-
checkElementStyleOnRichTextEditor({ check: true, element });
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
cy.findByLabelText('format').click();
|
|
118
|
-
cy.findByLabelText('bold').click();
|
|
119
|
-
|
|
120
|
-
cy.findByLabelText('format').click();
|
|
121
|
-
cy.findByLabelText('italic').click();
|
|
122
|
-
|
|
123
|
-
cy.findByLabelText('format').click();
|
|
124
|
-
cy.findByLabelText('underline').click();
|
|
125
|
-
|
|
126
|
-
cy.findByLabelText('format').click();
|
|
127
|
-
cy.findByLabelText('strikethrough').click();
|
|
128
|
-
|
|
129
|
-
cy.findByTestId('RichTextEditor').then((element: HTMLElement) => {
|
|
130
|
-
checkElementStyleOnRichTextEditor({ check: false, element });
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('adds link with an url when link button is clicked', () => {
|
|
135
|
-
cy.get('[data-testid="RichTextEditor"]').type('cypress');
|
|
136
|
-
cy.get('[data-testid="RichTextEditor"]').focus().type('{selectAll}');
|
|
137
|
-
|
|
138
|
-
cy.findByLabelText('link').click();
|
|
139
|
-
|
|
140
|
-
cy.findByLabelText('Saved link').should('have.text', 'https://');
|
|
141
|
-
|
|
142
|
-
cy.findByLabelText('Edit link').click();
|
|
143
|
-
cy.get('#InputLinkField').type('www.centreon.com').type('{enter}');
|
|
144
|
-
|
|
145
|
-
cy.findByText('cypress')
|
|
146
|
-
.parent()
|
|
147
|
-
.then((element: HTMLElement) => {
|
|
148
|
-
cy.wrap(element)
|
|
149
|
-
.should('have.attr', 'href')
|
|
150
|
-
.and('match', /^https:\/\/www.centreon.com/);
|
|
151
|
-
|
|
152
|
-
cy.wrap(element)
|
|
153
|
-
.should('have.attr', 'rel')
|
|
154
|
-
.and('match', /^noreferrer/);
|
|
155
|
-
|
|
156
|
-
cy.wrap(element)
|
|
157
|
-
.should('have.attr', 'target')
|
|
158
|
-
.and('match', /_blank/);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
cy.get('[data-testid="RichTextEditor"]').focus().type('{selectAll}');
|
|
162
|
-
|
|
163
|
-
cy.findByLabelText('link').click();
|
|
164
|
-
|
|
165
|
-
cy.findByText('cypress')
|
|
166
|
-
.parent()
|
|
167
|
-
.then((element: HTMLElement) => {
|
|
168
|
-
cy.wrap(element)
|
|
169
|
-
.contains('p', 'cypress')
|
|
170
|
-
.should('not.have.attr', 'href');
|
|
171
|
-
|
|
172
|
-
cy.wrap(element).should('not.have.attr', 'rel');
|
|
173
|
-
|
|
174
|
-
cy.wrap(element).should('not.have.attr', 'target');
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('does not allow to open links in a new tab', () => {
|
|
179
|
-
cy.mount({
|
|
180
|
-
Component: <RichTextEditor editable openLinkInNewTab={false} />
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
cy.get('[data-testid="RichTextEditor"]').type('cypress');
|
|
184
|
-
cy.get('[data-testid="RichTextEditor"]').focus().type('{selectAll}');
|
|
185
|
-
|
|
186
|
-
cy.findByLabelText('link').click();
|
|
187
|
-
|
|
188
|
-
cy.findByLabelText('Saved link').should('have.text', 'https://');
|
|
189
|
-
|
|
190
|
-
cy.findByLabelText('Edit link').click();
|
|
191
|
-
cy.get('#InputLinkField').type('www.centreon.com').type('{enter}');
|
|
192
|
-
|
|
193
|
-
cy.findByText('cypress').parent().should('not.have.attr', 'target');
|
|
194
|
-
|
|
195
|
-
cy.get('[data-testid="RichTextEditor"]').focus().clear();
|
|
196
|
-
|
|
197
|
-
cy.get('[data-testid="RichTextEditor"]')
|
|
198
|
-
.focus()
|
|
199
|
-
.type('https://centreon.com');
|
|
200
|
-
|
|
201
|
-
cy.findByText('https://centreon.com')
|
|
202
|
-
.parent()
|
|
203
|
-
.should('not.have.attr', 'target');
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('Rich Text Editor not editable', () => {
|
|
208
|
-
beforeEach(() => {
|
|
209
|
-
cy.mount({
|
|
210
|
-
Component: (
|
|
211
|
-
<RichTextEditor
|
|
212
|
-
editable={false}
|
|
213
|
-
initialEditorState={mockInititalStateToEditor}
|
|
214
|
-
/>
|
|
215
|
-
)
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('displays editor when editable props is false and an initialState exist', () => {
|
|
220
|
-
cy.findByLabelText('Undo').should('not.exist');
|
|
221
|
-
cy.findByLabelText('Redo').should('not.exist');
|
|
222
|
-
cy.findByLabelText(labelAlignPicker).should('not.exist');
|
|
223
|
-
cy.findByLabelText('block').should('not.exist');
|
|
224
|
-
cy.findByLabelText('format').should('not.exist');
|
|
225
|
-
cy.findByLabelText('link').should('not.exist');
|
|
226
|
-
cy.findByLabelText('list').should('not.exist');
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
describe('Rich Text Editor is disabled', () => {
|
|
231
|
-
beforeEach(() => {
|
|
232
|
-
cy.mount({
|
|
233
|
-
Component: (
|
|
234
|
-
<RichTextEditor
|
|
235
|
-
disabled
|
|
236
|
-
editable
|
|
237
|
-
initialEditorState={mockInititalStateToEditor}
|
|
238
|
-
/>
|
|
239
|
-
)
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('displays editor when editable props is false and an initialState exist', () => {
|
|
244
|
-
cy.findByLabelText('Undo').should('be.disabled');
|
|
245
|
-
cy.findByLabelText('Redo').should('be.disabled');
|
|
246
|
-
cy.findByLabelText(labelAlignPicker).should('be.disabled');
|
|
247
|
-
cy.findByLabelText('block').should('be.disabled');
|
|
248
|
-
cy.findByLabelText('format').should('be.disabled');
|
|
249
|
-
cy.findByLabelText('link').should('be.disabled');
|
|
250
|
-
cy.findByLabelText('list').should('be.disabled');
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
describe('Custom style editable rich text editor ', () => {
|
|
255
|
-
beforeEach(() => {
|
|
256
|
-
cy.mount({
|
|
257
|
-
Component: (
|
|
258
|
-
<RichTextEditor
|
|
259
|
-
editable
|
|
260
|
-
minInputHeight={200}
|
|
261
|
-
namespace="CypressComponentTest"
|
|
262
|
-
placeholder="Type Cypress test..."
|
|
263
|
-
/>
|
|
264
|
-
)
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
it('displays editor with custom namespace', () => {
|
|
268
|
-
cy.get('[data-testid="CypressComponentTest"] > p').should('be.exist');
|
|
269
|
-
cy.get('[data-testid="CypressComponentTest"]').should('be.exist');
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('displays editor with custom placeholder', () => {
|
|
273
|
-
cy.get('[data-testid="CypressComponentTest"]')
|
|
274
|
-
.parent()
|
|
275
|
-
.contains('Type Cypress test...');
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('displays editor with custom minimum input height', () => {
|
|
279
|
-
cy.get('[data-testid="CypressComponentTest"]').should(
|
|
280
|
-
'have.css',
|
|
281
|
-
'min-height',
|
|
282
|
-
'200px'
|
|
283
|
-
);
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
describe('Rich Text Editor with Macros Plugin', () => {
|
|
288
|
-
beforeEach(() => {
|
|
289
|
-
cy.mount({
|
|
290
|
-
Component: <RichTextEditor displayMacrosButton editable />
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('displays the Macros button when the "displayMacrosButton" prop is set to true', () => {
|
|
295
|
-
cy.findByLabelText('Macros').click();
|
|
296
|
-
|
|
297
|
-
standardMacros.forEach((macro) => {
|
|
298
|
-
cy.findByText(macro).should('be.visible');
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('ensures that the selected macro is inserted into the RichTextEditor', () => {
|
|
303
|
-
cy.get('[data-testid="RichTextEditor"]').type('macro : ');
|
|
304
|
-
|
|
305
|
-
standardMacros.forEach((macro) => {
|
|
306
|
-
cy.findByLabelText('Macros').click();
|
|
307
|
-
cy.findByText(macro).click();
|
|
308
|
-
|
|
309
|
-
cy.get('[data-testid="RichTextEditor"]').should('contain', macro);
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
describe('Block type', () => {
|
|
315
|
-
beforeEach(() => {
|
|
316
|
-
cy.mount({
|
|
317
|
-
Component: <RichTextEditor editable />
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
const testCases = [
|
|
322
|
-
{
|
|
323
|
-
blockType: 'Huge',
|
|
324
|
-
tag: 'h3'
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
blockType: 'Large',
|
|
328
|
-
tag: 'h5'
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
blockType: 'Normal',
|
|
332
|
-
tag: 'p'
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
blockType: 'Small',
|
|
336
|
-
tag: 'h6'
|
|
337
|
-
}
|
|
338
|
-
];
|
|
339
|
-
|
|
340
|
-
testCases.forEach(({ blockType, tag }) => {
|
|
341
|
-
it(`displays ${blockType} when the corresponding block type button is selected`, () => {
|
|
342
|
-
cy.get('[data-testid="RichTextEditor"]').type('Example');
|
|
343
|
-
cy.findByLabelText('block').click();
|
|
344
|
-
cy.findByText(blockType).click();
|
|
345
|
-
|
|
346
|
-
cy.get('[data-testid="RichTextEditor"]').find(tag).should('be.visible');
|
|
347
|
-
|
|
348
|
-
cy.makeSnapshot();
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
describe('List type', () => {
|
|
354
|
-
beforeEach(() => {
|
|
355
|
-
cy.mount({
|
|
356
|
-
Component: <RichTextEditor editable />
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
const testCases = [
|
|
361
|
-
{
|
|
362
|
-
listType: 'Unordered List',
|
|
363
|
-
tag: 'ul'
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
listType: 'Ordered List',
|
|
367
|
-
tag: 'ol'
|
|
368
|
-
}
|
|
369
|
-
];
|
|
370
|
-
|
|
371
|
-
testCases.forEach(({ listType, tag }) => {
|
|
372
|
-
it(`displays ${listType} when the corresponding list type button is selected`, () => {
|
|
373
|
-
cy.get('[data-testid="RichTextEditor"]').type('Example');
|
|
374
|
-
cy.findByLabelText('list').click();
|
|
375
|
-
cy.findByLabelText(listType).click();
|
|
376
|
-
|
|
377
|
-
cy.get('[data-testid="RichTextEditor"]').find(tag).should('be.visible');
|
|
378
|
-
|
|
379
|
-
cy.makeSnapshot();
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
describe('Aligns', () => {
|
|
385
|
-
beforeEach(() => {
|
|
386
|
-
cy.mount({
|
|
387
|
-
Component: <RichTextEditor editable />
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
const testCases = ['Center', 'Right', 'Left'];
|
|
392
|
-
|
|
393
|
-
testCases.forEach((label) => {
|
|
394
|
-
it(`aligns the text to the ${label} when the corresponding button was clicked`, () => {
|
|
395
|
-
cy.get('[data-testid="RichTextEditor"]').type('Example');
|
|
396
|
-
|
|
397
|
-
cy.findByLabelText(labelAlignPicker).click();
|
|
398
|
-
cy.findByLabelText(label).click();
|
|
399
|
-
|
|
400
|
-
cy.findByText('Example')
|
|
401
|
-
.parent()
|
|
402
|
-
.should('have.css', 'text-align', label.toLowerCase());
|
|
403
|
-
|
|
404
|
-
cy.makeSnapshot();
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
});
|