|
6 | 6 | /// <reference types="cypress" /> |
7 | 7 |
|
8 | 8 | import { |
9 | | - delayTime, |
| 9 | + SAMPLE_SQL_QUERY, |
10 | 10 | TEST_NOTEBOOK, |
11 | 11 | SAMPLE_URL, |
12 | | - SQL_QUERY_TEXT, |
13 | | - PPL_QUERY_TEXT, |
14 | 12 | BASE_PATH, |
| 13 | + delayTime, |
| 14 | + MARKDOWN_TEXT, |
15 | 15 | } from '../../../utils/constants'; |
16 | 16 |
|
| 17 | +import { skipOn } from '@cypress/skip-test'; |
| 18 | + |
| 19 | +const moveToNotebookHome = () => { |
| 20 | + cy.visit(`${BASE_PATH}/app/observability-notebooks#/`); |
| 21 | +}; |
| 22 | + |
17 | 23 | const moveToTestNotebook = () => { |
18 | 24 | cy.visit(`${BASE_PATH}/app/observability-notebooks#/`, { |
19 | 25 | timeout: delayTime * 3, |
20 | 26 | }); |
| 27 | + |
| 28 | + // Reload page to load notebooks if they are not flushed in OpenSearch index yet. |
| 29 | + cy.reload(); |
| 30 | + |
21 | 31 | cy.get('.euiTableCellContent') |
22 | 32 | .contains(TEST_NOTEBOOK, { |
23 | 33 | timeout: delayTime * 3, |
24 | 34 | }) |
25 | 35 | .click(); |
26 | 36 | }; |
27 | 37 |
|
28 | | -describe('Testing paragraphs', () => { |
| 38 | +describe('Testing notebook actions', () => { |
| 39 | + before(() => { |
| 40 | + moveToNotebookHome(); |
| 41 | + cy.get('a[data-test-subj="createNotebookPrimaryBtn"]').click(); |
| 42 | + cy.get('input[data-test-subj="custom-input-modal-input"]').focus(); |
| 43 | + cy.get('input[data-test-subj="custom-input-modal-input"]').type( |
| 44 | + TEST_NOTEBOOK |
| 45 | + ); |
| 46 | + cy.get( |
| 47 | + 'button[data-test-subj="custom-input-modal-confirm-button"]' |
| 48 | + ).click(); |
| 49 | + cy.get('h1[data-test-subj="notebookTitle"]') |
| 50 | + .contains(TEST_NOTEBOOK) |
| 51 | + .should('exist'); |
| 52 | + }); |
| 53 | + |
29 | 54 | beforeEach(() => { |
30 | 55 | moveToTestNotebook(); |
31 | 56 | }); |
32 | 57 |
|
| 58 | + it('Creates a code paragraph', () => { |
| 59 | + cy.get('button[data-test-subj="emptyNotebookAddCodeBlockBtn"]').click(); |
| 60 | + cy.get('textarea[data-test-subj="editorArea-0"]').should('exist'); |
| 61 | + cy.get('button[data-test-subj="runRefreshBtn-0"]').contains('Run').click(); |
| 62 | + cy.get('div[data-test-subj="paragraphInputErrorText"]') |
| 63 | + .contains('Input is required.') |
| 64 | + .should('exist'); |
| 65 | + }); |
| 66 | + |
33 | 67 | it('Renders markdown', () => { |
34 | | - cy.get('.euiTextArea').should('not.exist'); |
| 68 | + cy.get('button[data-test-subj="paragraphToggleInputBtn"]').click(); |
| 69 | + cy.get('.euiCodeBlock').click(); |
| 70 | + cy.get('textarea[data-test-subj="editorArea-0"]').clear(); |
| 71 | + cy.get('textarea[data-test-subj="editorArea-0"]').focus(); |
| 72 | + cy.get('textarea[data-test-subj="editorArea-0"]').type(MARKDOWN_TEXT); |
| 73 | + |
| 74 | + cy.get('button[data-test-subj="runRefreshBtn-0"]').click(); |
| 75 | + cy.get('textarea[data-test-subj="editorArea-0"]').should('not.exist'); |
35 | 76 | cy.get(`a[href="${SAMPLE_URL}"]`).should('exist'); |
36 | 77 | cy.get('code').contains('POST').should('exist'); |
37 | 78 | cy.get('td').contains('b2').should('exist'); |
38 | 79 | }); |
39 | 80 |
|
40 | | - it('Shows output message', () => { |
41 | | - cy.get('button[aria-label="Toggle show input"]').click(); |
42 | | - cy.wait(delayTime); |
43 | | - cy.get('.euiTextColor').contains('Last successful run').should('exist'); |
44 | | - |
45 | | - cy.get('pre.input').eq(0).click(); |
46 | | - cy.wait(delayTime); |
47 | | - cy.get('.euiTextArea').type('Another text'); |
48 | | - cy.wait(delayTime); |
| 81 | + it('Adds a SQL query paragraph', () => { |
| 82 | + cy.get('button[data-test-subj="AddParagraphButton"]').click(); |
| 83 | + cy.get('button[data-test-subj="AddCodeBlockBtn"]').click(); |
49 | 84 |
|
50 | | - cy.get('.euiTextColor').contains('Last successful run').should('exist'); |
51 | | - }); |
| 85 | + cy.get('textarea[data-test-subj="editorArea-1"]').clear(); |
| 86 | + cy.get('textarea[data-test-subj="editorArea-1"]').focus(); |
| 87 | + cy.get('textarea[data-test-subj="editorArea-1"]').type(SAMPLE_SQL_QUERY); |
| 88 | + cy.get('button[data-test-subj="runRefreshBtn-1"]').click(); |
52 | 89 |
|
53 | | - it.skip('Duplicates paragraphs', () => { |
54 | | - cy.get('.euiButtonIcon[aria-label="Open paragraph menu"]').eq(0).click(); |
55 | | - cy.wait(delayTime); |
56 | | - cy.get('.euiContextMenuItem__text').contains('Duplicate').eq(0).click(); |
57 | | - cy.wait(delayTime); |
58 | | - cy.get('.euiButton__text').contains('Run').click(); |
59 | | - cy.wait(delayTime); |
| 90 | + cy.get('textarea[data-test-subj="editorArea-1"]').should('not.exist'); |
| 91 | + cy.get('div[data-test-subj="queryOutputText"]') |
| 92 | + .contains('select 1') |
| 93 | + .should('exist'); |
60 | 94 |
|
61 | | - cy.get(`a[href="${SAMPLE_URL}"]`).should('have.length.gte', 2); |
| 95 | + cy.get('.euiDataGrid__overflow').should('exist'); |
62 | 96 | }); |
| 97 | +}); |
63 | 98 |
|
64 | | - it('Adds a dashboards visualization paragraph', () => { |
65 | | - cy.contains('Add paragraph').click(); |
66 | | - cy.wait(delayTime); |
67 | | - cy.get('.euiContextMenuItem__text').contains('Visualization').click(); |
68 | | - cy.wait(delayTime); |
69 | | - |
70 | | - cy.get('.euiButton__text').contains('Run').click(); |
71 | | - cy.wait(delayTime); |
72 | | - cy.get('.euiTextColor') |
73 | | - .contains('Visualization is required.') |
| 99 | +describe('Test reporting integration if plugin installed', () => { |
| 100 | + beforeEach(() => { |
| 101 | + moveToNotebookHome(); |
| 102 | + cy.get('.euiTableCellContent').contains(TEST_NOTEBOOK).click(); |
| 103 | + cy.get('h1[data-test-subj="notebookTitle"]') |
| 104 | + .contains(TEST_NOTEBOOK) |
74 | 105 | .should('exist'); |
75 | | - |
76 | | - cy.get('.euiButton__text').contains('Browse').click(); |
77 | | - cy.wait(delayTime); |
78 | | - cy.get('.euiFieldSearch') |
79 | | - .focus() |
80 | | - .type('[Flights] Flight Count and Average Ticket Price{enter}'); |
81 | | - cy.wait(delayTime); |
82 | | - cy.get('.euiButton__text').contains('Select').click(); |
83 | | - cy.wait(delayTime); |
84 | | - cy.get('.euiButton__text').contains('Run').click(); |
85 | | - cy.wait(delayTime); |
86 | | - cy.get('div.visualization').should('exist'); |
| 106 | + cy.get('body').then(($body) => { |
| 107 | + skipOn($body.find('#reportingActionsButton').length <= 0); |
| 108 | + }); |
87 | 109 | }); |
88 | 110 |
|
89 | | - it('Adds a SQL query paragraph', () => { |
90 | | - cy.contains('Add paragraph').click(); |
91 | | - cy.wait(delayTime); |
92 | | - cy.get('.euiContextMenuItem__text').contains('Code block').click(); |
93 | | - cy.wait(delayTime); |
94 | | - |
95 | | - cy.get('.euiTextArea').type(SQL_QUERY_TEXT); |
96 | | - cy.wait(delayTime); |
97 | | - cy.get('.euiButton__text').contains('Run').click(); |
98 | | - cy.wait(delayTime * 5); |
99 | | - |
100 | | - cy.get('b').contains( |
101 | | - 'select * from opensearch_dashboards_sample_data_flights limit 20' |
102 | | - ); |
103 | | - |
104 | | - cy.get('.euiDataGrid__overflow').should('exist'); |
| 111 | + it('Create in-context PDF report from notebook', () => { |
| 112 | + cy.get('#reportingActionsButton').click(); |
| 113 | + cy.get('button.euiContextMenuItem:nth-child(1)') |
| 114 | + .contains('Download PDF') |
| 115 | + .click(); |
| 116 | + cy.get('#downloadInProgressLoadingModal').should('exist'); |
105 | 117 | }); |
106 | 118 |
|
107 | | - it('Adds a PPL query paragraph', () => { |
108 | | - cy.contains('Add paragraph').click(); |
109 | | - cy.wait(delayTime); |
110 | | - cy.get('.euiContextMenuItem__text').contains('Code block').click(); |
111 | | - cy.wait(delayTime); |
112 | | - |
113 | | - cy.get('.euiTextArea').type(PPL_QUERY_TEXT); |
114 | | - cy.wait(delayTime); |
115 | | - cy.get('.euiButton__text').contains('Run').click(); |
116 | | - cy.wait(delayTime * 5); |
117 | | - |
118 | | - cy.get('b').contains('source=opensearch_dashboards_sample_data_flights'); |
119 | | - |
120 | | - cy.get('.euiDataGrid__overflow').should('exist'); |
| 119 | + it('Create in-context PNG report from notebook', () => { |
| 120 | + cy.get('#reportingActionsButton').click(); |
| 121 | + cy.get('button.euiContextMenuItem:nth-child(2)') |
| 122 | + .contains('Download PNG') |
| 123 | + .click(); |
| 124 | + cy.get('#downloadInProgressLoadingModal').should('exist'); |
121 | 125 | }); |
122 | 126 |
|
123 | | - it('Runs all paragraphs', () => { |
124 | | - cy.wait(delayTime * 3); // need to wait for paragraphs to load first |
125 | | - cy.get('[data-test-subj="notebook-paragraph-actions-button"]').click(); |
126 | | - cy.wait(delayTime); |
127 | | - cy.get('.euiContextMenuItem__text').contains('Run all paragraphs').click(); |
128 | | - cy.wait(delayTime); |
129 | | - |
130 | | - cy.get(`a[href="${SAMPLE_URL}"]`).should('exist'); |
| 127 | + it('Create on-demand report definition from context menu', () => { |
| 128 | + cy.get('#reportingActionsButton').click(); |
| 129 | + cy.get('button.euiContextMenuItem:nth-child(3)') |
| 130 | + .contains('Create report definition') |
| 131 | + .click(); |
| 132 | + cy.location('pathname', { timeout: delayTime * 3 }).should( |
| 133 | + 'include', |
| 134 | + '/reports-dashboards' |
| 135 | + ); |
| 136 | + cy.get('#reportSettingsName').type('Create notebook on-demand report'); |
| 137 | + cy.get('#createNewReportDefinition').click({ force: true }); |
131 | 138 | }); |
132 | 139 |
|
133 | | - it('Deletes paragraphs', () => { |
134 | | - cy.wait(delayTime * 3); |
135 | | - cy.get('[data-test-subj="notebook-paragraph-actions-button"]').click(); |
136 | | - cy.wait(delayTime); |
137 | | - cy.get('.euiContextMenuItem__text') |
138 | | - .contains('Delete all paragraphs') |
| 140 | + it('View reports homepage from context menu', () => { |
| 141 | + cy.get('#reportingActionsButton').click(); |
| 142 | + cy.get('button.euiContextMenuItem:nth-child(4)') |
| 143 | + .contains('View reports') |
139 | 144 | .click(); |
140 | | - cy.wait(delayTime); |
141 | | - cy.get('.euiButton__text').contains('Delete').click(); |
142 | | - cy.wait(delayTime); |
143 | | - |
144 | | - cy.get('.euiTextAlign').contains('No paragraphs').should('exist'); |
| 145 | + cy.location('pathname', { timeout: delayTime * 3 }).should( |
| 146 | + 'include', |
| 147 | + '/reports-dashboards' |
| 148 | + ); |
145 | 149 | }); |
| 150 | +}); |
146 | 151 |
|
| 152 | +describe('clean up all test data', () => { |
147 | 153 | it('Cleans up test notebooks', () => { |
148 | | - cy.get('[data-test-subj="notebook-notebook-actions-button"]').click(); |
149 | | - cy.wait(delayTime); |
150 | | - cy.get('.euiContextMenuItem__text').contains('Delete notebook').click(); |
151 | | - cy.wait(delayTime); |
152 | | - |
153 | | - cy.get('button.euiButton--danger').should('be.disabled'); |
154 | | - |
155 | | - cy.get('input.euiFieldText[placeholder="delete"]').type('delete'); |
156 | | - cy.get('button.euiButton--danger').should('not.be.disabled'); |
157 | | - cy.get('.euiButton__text').contains('Delete').click(); |
158 | | - cy.wait(delayTime * 3); |
159 | | - |
160 | | - cy.get('.euiText').contains('No notebooks').should('exist'); |
| 154 | + moveToNotebookHome(); |
| 155 | + cy.get('input[data-test-subj="checkboxSelectAll"]').click(); |
| 156 | + cy.get('button[data-test-subj="notebookTableActionBtn"]').click(); |
| 157 | + cy.get('button[data-test-subj="deleteNotebookBtn"]').click(); |
| 158 | + cy.get( |
| 159 | + 'button[data-test-subj="delete-notebook-modal-delete-button"]' |
| 160 | + ).should('be.disabled'); |
| 161 | + |
| 162 | + cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus(); |
| 163 | + cy.get('input[data-test-subj="delete-notebook-modal-input"]').type( |
| 164 | + 'delete' |
| 165 | + ); |
| 166 | + cy.get( |
| 167 | + 'button[data-test-subj="delete-notebook-modal-delete-button"]' |
| 168 | + ).should('not.be.disabled'); |
| 169 | + cy.get( |
| 170 | + 'button[data-test-subj="delete-notebook-modal-delete-button"]' |
| 171 | + ).click(); |
| 172 | + moveToNotebookHome(); |
| 173 | + cy.get('div[data-test-subj="notebookEmptyTableText"]').should('exist'); |
161 | 174 | }); |
162 | 175 | }); |
0 commit comments