-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Console] Add tests for Console's text input
Co-authored-by: Muhammad Ibragimov <[email protected]>
- Loading branch information
1 parent
860ca8c
commit 4e68ec9
Showing
5 changed files
with
154 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const retry = getService('retry'); | ||
const toasts = getService('toasts'); | ||
const PageObjects = getPageObjects(['common', 'console', 'header']); | ||
|
||
describe('text input', function testTextInput() { | ||
before(async () => { | ||
await PageObjects.common.navigateToApp('console'); | ||
await PageObjects.console.collapseHelp(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await PageObjects.console.clearTextArea(); | ||
}); | ||
|
||
describe('with a data URI in the load_from query', () => { | ||
it('loads the data from the URI', async () => { | ||
await PageObjects.common.navigateToApp('console', { | ||
hash: '#/console?load_from=data:text/plain,BYUwNmD2Q', | ||
}); | ||
|
||
await retry.try(async () => { | ||
const actualRequest = await PageObjects.console.getRequest(); | ||
expect(actualRequest.trim()).to.eql('hello'); | ||
}); | ||
}); | ||
|
||
describe('with invalid data', () => { | ||
it('shows a toast error', async () => { | ||
await PageObjects.common.navigateToApp('console', { | ||
hash: '#/console?load_from=data:text/plain,BYUwNmD2', | ||
}); | ||
|
||
await retry.try(async () => { | ||
expect(await toasts.getToastCount()).to.equal(1); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('copy/pasting cURL commands into the console', () => { | ||
it('should convert cURL commands into the console request format', async () => { | ||
await PageObjects.console.enterRequest( | ||
`\n curl -XGET "http://localhost:9200/_search?pretty" -d'\n{"query": {"match_all": {}}}'` | ||
); | ||
await PageObjects.console.copyRequestsToClipboard(); | ||
await PageObjects.console.clearTextArea(); | ||
await PageObjects.console.pasteClipboardValue(); | ||
await retry.try(async () => { | ||
const actualRequest = await PageObjects.console.getRequest(); | ||
expect(actualRequest.trim()).to.eql('GET /_search?pretty\n {"query": {"match_all": {}}}'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('console history', () => { | ||
const sendRequest = async (request: string) => { | ||
await PageObjects.console.enterRequest(request); | ||
await PageObjects.console.clickPlay(); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
}; | ||
|
||
it('should show the history', async () => { | ||
await sendRequest('GET /_search?pretty'); | ||
await PageObjects.console.clickHistory(); | ||
await retry.try(async () => { | ||
const history = await PageObjects.console.getHistoryEntries(); | ||
expect(history).to.eql(['/_search?pretty (a few seconds ago)']); | ||
}); | ||
|
||
// Clear the history | ||
await PageObjects.console.clickClearHistory(); | ||
await PageObjects.console.closeHistory(); | ||
}); | ||
|
||
it('should load a request from history', async () => { | ||
await sendRequest('GET _search\n{"query": {"match_all": {}}}'); | ||
await PageObjects.console.clearTextArea(); | ||
await PageObjects.console.clickHistory(); | ||
await PageObjects.console.loadRequestFromHistory(0); | ||
await retry.try(async () => { | ||
const actualRequest = await PageObjects.console.getRequest(); | ||
expect(actualRequest.trim()).to.eql( | ||
'GET _search\n{\n "query": {\n "match_all": {}\n }\n}' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters