From cc599b900d5d378769ce964f00e7d4d060f24868 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 6 Nov 2024 14:57:27 +0100 Subject: [PATCH] add simple test --- apps/remix-ide-e2e/src/tests/ai_panel.test.ts | 52 +++++++++++++++++++ libs/remix-ui/renderer/src/lib/renderer.tsx | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 apps/remix-ide-e2e/src/tests/ai_panel.test.ts diff --git a/apps/remix-ide-e2e/src/tests/ai_panel.test.ts b/apps/remix-ide-e2e/src/tests/ai_panel.test.ts new file mode 100644 index 0000000000..4b4cf4a81a --- /dev/null +++ b/apps/remix-ide-e2e/src/tests/ai_panel.test.ts @@ -0,0 +1,52 @@ +'use strict' + +import { NightwatchBrowser } from 'nightwatch' +import init from '../helpers/init' +import examples from '../examples/example-contracts' + +const sources = [ + { 'Untitled.sol': { content: examples.ballot.content } } +] + +module.exports = { + before: function (browser: NightwatchBrowser, done: VoidFunction) { + init(browser, done) + }, + '@sources': function () { + return sources + }, + 'Add Ballot': function (browser: NightwatchBrowser) { + browser + .addFile('Untitled.sol', sources[0]['Untitled.sol']) + }, + 'Explain the contract': function (browser: NightwatchBrowser) { + browser + .waitForElementVisible('*[data-id="explain-editor"]') + .click('*[data-id="explain-editor"]') + .waitForElementVisible('*[data-id="popupPanelPluginsContainer"]') + .waitForElementVisible('*[data-id="aichat-view"]') + .waitForElementVisible({ + locateStrategy: 'xpath', + selector: '//*[@data-id="aichat-view" and contains(.,"Explain the current code")]' + }) + }, + 'close the popup': function (browser: NightwatchBrowser) { + browser + .waitForElementVisible('*[data-id="popupPanelToggle"]') + .click('*[data-id="popupPanelToggle"]') + .waitForElementNotVisible('*[data-id="popupPanelPluginsContainer"]') + }, + 'Add a bad contract': function (browser: NightwatchBrowser) { + browser + .addFile('Bad.sol', { content: 'errors' }) + .clickLaunchIcon('solidity') + .waitForElementVisible('.ask-remix-ai-button') + .click('.ask-remix-ai-button') + .waitForElementVisible('*[data-id="popupPanelPluginsContainer"]') + .waitForElementVisible('*[data-id="aichat-view"]') + .waitForElementVisible({ + locateStrategy: 'xpath', + selector: '//*[@data-id="aichat-view" and contains(.,"Explain the error")]' + }) + } +} \ No newline at end of file diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 966cb23f07..75ba8b7e60 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -126,7 +126,7 @@ export const Renderer = ({ message, opt, plugin, context }: RendererProps) => { > { event.preventDefault(); askGtp() }} style={{ borderColor: "var(--ai)" }} >