Skip to content

Commit

Permalink
[DOCS] Automate generative AI connector screenshots (#165420)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored Sep 6, 2023
1 parent 58198a2 commit 633aebe
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/management/connectors/action-types/gen-ai.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ You can create connectors in *{stack-manage-app} > {connectors-ui}*. For exampl

[role="screenshot"]
image::management/connectors/images/gen-ai-connector.png[Generative AI connector]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

[float]
[[gen-ai-connector-configuration]]
Expand Down Expand Up @@ -65,6 +66,7 @@ as you're creating or editing the connector in {kib}. For example:

[role="screenshot"]
image::management/connectors/images/gen-ai-params-test.png[Generative AI params test]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

The Generative AI actions have the following configuration properties.

Expand Down
Binary file modified docs/management/connectors/images/gen-ai-connector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/management/connectors/images/gen-ai-params-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const commonScreenshots = getService('commonScreenshots');
const screenshotDirectories = ['response_ops_docs', 'stack_connectors'];
const pageObjects = getPageObjects(['common', 'header']);
const actions = getService('actions');
const testSubjects = getService('testSubjects');
const actionBody =
`{\n` +
`"model": "gpt-3.5-turbo",\n` +
`"messages": [{\n` +
`"role": "user",\n` +
`"content": "You are a cyber security analyst using Elastic Security. I would like you to evaluate the event below and format your output neatly in markdown syntax. Add your description, an accuracy rating, and a threat rating."\n` +
`}]`;

describe('connector types', function () {
beforeEach(async () => {
await pageObjects.common.navigateToApp('connectors');
await pageObjects.header.waitUntilLoadingHasFinished();
});

it('generative ai connector screenshots', async () => {
await pageObjects.common.navigateToApp('connectors');
await pageObjects.header.waitUntilLoadingHasFinished();
await actions.common.openNewConnectorForm('gen-ai');
await testSubjects.setValue('nameInput', 'OpenAI test connector');
await testSubjects.setValue('secrets.apiKey-input', 'testkey');
await commonScreenshots.takeScreenshot('gen-ai-connector', screenshotDirectories, 1920, 1200);
await testSubjects.click('create-connector-flyout-save-test-btn');
await testSubjects.click('toastCloseButton');
const editor = await testSubjects.find('kibanaCodeEditor');
await editor.clearValue();
await testSubjects.setValue('kibanaCodeEditor', actionBody, {
clearWithKeyboard: true,
});
await commonScreenshots.takeScreenshot('gen-ai-params-test', screenshotDirectories);
await testSubjects.click('euiFlyoutCloseButton');
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) {

loadTestFile(require.resolve('./connectors'));
loadTestFile(require.resolve('./connector_types'));
loadTestFile(require.resolve('./generative_ai_connector'));
});
}

0 comments on commit 633aebe

Please sign in to comment.