-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy path6_notebooks.spec.js
177 lines (157 loc) · 5.39 KB
/
6_notebooks.spec.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="cypress" />
import {
TEST_NOTEBOOK,
SAMPLE_URL,
BASE_PATH,
delayTime,
MARKDOWN_TEXT,
OBSERVABILITY_INDEX_NAME,
} from '../../../utils/constants';
import { skipOn } from '@cypress/skip-test';
let loadedOnce = 0;
const moveToNotebookHome = () => {
cy.visit(`${BASE_PATH}/app/observability-notebooks#/`);
};
const moveToTestNotebook = () => {
cy.visit(`${BASE_PATH}/app/observability-notebooks#/`, {
timeout: delayTime * 3,
});
// Force refresh the observablity index and reload page to load notebooks.
if (loadedOnce === 0) {
cy.request({
method: 'POST',
failOnStatusCode: false,
form: false,
url: 'api/console/proxy',
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
qs: {
path: `${OBSERVABILITY_INDEX_NAME}/_refresh`,
method: 'POST',
},
});
cy.reload();
loadedOnce = 1;
}
cy.get('.euiTableCellContent')
.contains(TEST_NOTEBOOK, {
timeout: delayTime * 3,
})
.click();
};
describe('Testing notebook actions', () => {
before(() => {
moveToNotebookHome();
cy.get('a[data-test-subj="createNotebookPrimaryBtn"]').click();
cy.get('input[data-test-subj="custom-input-modal-input"]').focus();
cy.get('input[data-test-subj="custom-input-modal-input"]').type(
TEST_NOTEBOOK
);
cy.get(
'button[data-test-subj="custom-input-modal-confirm-button"]'
).click();
cy.get('h1[data-test-subj="notebookTitle"]')
.contains(TEST_NOTEBOOK)
.should('exist');
});
beforeEach(() => {
moveToTestNotebook();
});
it('Creates a code paragraph', () => {
cy.get('button[data-test-subj="emptyNotebookAddCodeBlockBtn"]').click();
cy.get('textarea[data-test-subj="editorArea-0"]').should('exist');
cy.get('button[data-test-subj="runRefreshBtn-0"]').contains('Run').click();
cy.get('div[data-test-subj="paragraphInputErrorText"]')
.contains('Input is required.')
.should('exist');
});
it('Renders markdown', () => {
cy.get('button[data-test-subj="paragraphToggleInputBtn"]').click();
cy.get('.euiCodeBlock').click();
cy.get('textarea[data-test-subj="editorArea-0"]').clear();
cy.get('textarea[data-test-subj="editorArea-0"]').focus();
cy.get('textarea[data-test-subj="editorArea-0"]').type(MARKDOWN_TEXT);
cy.get('button[data-test-subj="runRefreshBtn-0"]').click();
cy.get('textarea[data-test-subj="editorArea-0"]').should('not.exist');
cy.get(`a[href="${SAMPLE_URL}"]`).should('exist');
cy.get('code').contains('POST').should('exist');
cy.get('td').contains('b2').should('exist');
});
});
describe('Test reporting integration if plugin installed', () => {
beforeEach(() => {
moveToNotebookHome();
cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click();
cy.get('h1[data-test-subj="notebookTitle"]')
.contains(TEST_NOTEBOOK)
.should('exist');
cy.get('body').then(($body) => {
skipOn($body.find('#reportingActionsButton').length <= 0);
});
});
it('Create in-context PDF report from notebook', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(1)')
.contains('Download PDF')
.click();
cy.get('body').contains('Please continue report generation in the new tab');
});
it('Create in-context PNG report from notebook', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(2)')
.contains('Download PNG')
.click();
cy.get('body').contains('Please continue report generation in the new tab');
});
it('Create on-demand report definition from context menu', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(3)')
.contains('Create report definition')
.click();
cy.location('pathname', { timeout: delayTime * 3 }).should(
'include',
'/reports-dashboards'
);
cy.get('#reportSettingsName').type('Create notebook on-demand report');
cy.get('#createNewReportDefinition').click({ force: true });
});
it('View reports homepage from context menu', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(4)')
.contains('View reports')
.click();
cy.location('pathname', { timeout: delayTime * 3 }).should(
'include',
'/reports-dashboards'
);
});
});
describe('clean up all test data', () => {
it('Cleans up test notebooks', () => {
moveToNotebookHome();
cy.get('input[data-test-subj="checkboxSelectAll"]').click();
cy.get('button[data-test-subj="notebookTableActionBtn"]').click();
cy.get('button[data-test-subj="deleteNotebookBtn"]').click();
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).should('be.disabled');
cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus();
cy.get('input[data-test-subj="delete-notebook-modal-input"]').type(
'delete'
);
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).should('not.be.disabled');
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).click();
moveToNotebookHome();
cy.get('div[data-test-subj="notebookEmptyTableText"]').should('exist');
});
});