|
| 1 | +/* |
| 2 | + * Copyright OpenSearch Contributors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; |
| 7 | + |
| 8 | +const miscUtils = new MiscUtils(cy); |
| 9 | + |
| 10 | +describe('console app', () => { |
| 11 | + const DEFAULT_REQUEST = `GET _search |
| 12 | +{ |
| 13 | + "query": { |
| 14 | + "match_all": {} |
| 15 | + } |
| 16 | +}`.trim(); |
| 17 | + |
| 18 | + beforeEach(() => { |
| 19 | + // Navigate to the console page before each test |
| 20 | + miscUtils.visitPage('/app/dev_tools#/console'); |
| 21 | + // Assuming there's a method to collapse the help pane in your page objects or you directly use a command here |
| 22 | + cy.getElementByTestId('help-close-button').click({ force: true }); |
| 23 | + cy.wait(1000); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should show the default request', () => { |
| 27 | + // Get the request text and assert it matches the default request |
| 28 | + // Adjust the selector to target the element containing the request |
| 29 | + cy.getVisibleTextFromAceEditor('request-editor').should( |
| 30 | + 'eq', |
| 31 | + DEFAULT_REQUEST |
| 32 | + ); |
| 33 | + }); |
| 34 | + |
| 35 | + it('default request response should include `"timed_out" : false`', () => { |
| 36 | + // Click the "Play" button to submit the request |
| 37 | + // Adjust the selector as needed |
| 38 | + cy.getElementByTestId('sendRequestButton').click(); |
| 39 | + |
| 40 | + // Check the response for the expected text |
| 41 | + // Adjust the selector to target the element containing the response |
| 42 | + cy.getElementByTestId('response-editor').should( |
| 43 | + 'contain', |
| 44 | + '"timed_out": false,' |
| 45 | + ); |
| 46 | + }); |
| 47 | + |
| 48 | + it('settings should allow changing the text size', () => { |
| 49 | + // Navigate to settings and change the font size, then verify the change |
| 50 | + // This assumes you have a way to navigate to settings and change them, possibly abstracted in commands |
| 51 | + cy.changeConsoleFontSize(20); |
| 52 | + cy.getElementByTestId('request-editor').should( |
| 53 | + 'have.css', |
| 54 | + 'font-size', |
| 55 | + '20px' |
| 56 | + ); |
| 57 | + |
| 58 | + cy.changeConsoleFontSize(24); |
| 59 | + cy.getElementByTestId('request-editor').should( |
| 60 | + 'have.css', |
| 61 | + 'font-size', |
| 62 | + '24px' |
| 63 | + ); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should resize the editor', () => { |
| 67 | + // Set initial window size |
| 68 | + cy.viewport(1300, 1100); |
| 69 | + |
| 70 | + // Capture initial size |
| 71 | + let initialWidth; |
| 72 | + cy.get('.conApp').then(($editor) => { |
| 73 | + initialWidth = $editor.width(); |
| 74 | + }); |
| 75 | + |
| 76 | + // Change window size |
| 77 | + cy.viewport(1000, 1100); |
| 78 | + |
| 79 | + // Assert that the editor width has decreased |
| 80 | + cy.get('.conApp').should(($editor) => { |
| 81 | + expect($editor.width()).to.be.lessThan(initialWidth); |
| 82 | + }); |
| 83 | + }); |
| 84 | +}); |
0 commit comments