diff --git a/.gitignore b/.gitignore index 6acb0b3156..ec20f02b2e 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ testem.log # System Files .DS_Store .vscode/settings.json +.vscode/launch.json diff --git a/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts b/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts index 4a38d8e49f..25fefb8eb8 100644 --- a/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts +++ b/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts @@ -35,10 +35,9 @@ export class WorkSpacePlugin extends PluginClient { constructor () { super() - console.log('CONSTRUCTOR') createClient(this) - this.methods = ['qr', 'dismiss', 'customAction'] + this.methods = ['customAction'] this.onload() .then(async (x) => { @@ -482,7 +481,7 @@ export class WorkSpacePlugin extends PluginClient { } async soltest () { - const f = `pragma solidity >=0.4.0 <0.7.0; + const f = `pragma solidity >=0.4.0; contract SimpleStorage { uint storedData; @@ -498,7 +497,7 @@ export class WorkSpacePlugin extends PluginClient { } ` - const t = `pragma solidity >=0.4.0 <0.7.0; + const t = `pragma solidity >=0.4.0; import "remix_tests.sol"; // this import is automatically injected by Remix. import "./modifyVariable.sol"; @@ -515,10 +514,6 @@ export class WorkSpacePlugin extends PluginClient { } } ` - - console.log(f) - console.log(t) - await this.call('fileManager', 'setFile', '/modifyVariable.sol', f) await this.call('fileManager', 'switchFile', '/modifyVariable.sol') await this.call('fileManager', 'setFile', '/modifyVariable_test.sol', t) @@ -527,7 +522,7 @@ export class WorkSpacePlugin extends PluginClient { 'testFromPath', 'modifyVariable_test.sol' ) - return result.errors + this.setFeedback(result) } async disableCallBacks () { diff --git a/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx b/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx index 958e76756e..0353f36d47 100644 --- a/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx +++ b/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx @@ -8,21 +8,22 @@ export const client = new WorkSpacePlugin() function App () { const [payload, setPayload] = useState('') const [result, setResult] = useState() + const [append, setAppend] = useState(false) const handleChange = ({ target }: any) => { setPayload(target.value) } - const test = async () => { - setResult('') - const r = await client.soltest() - setResult('test done') + const setAppendChange = ({ target }: any) => { + console.log('append', target.checked) + setAppend(target.checked) } return (
v5
- + + @@ -30,7 +31,7 @@ function App () { - + diff --git a/apps/remix-ide-e2e/src/local-plugin/src/app/logger.tsx b/apps/remix-ide-e2e/src/local-plugin/src/app/logger.tsx index 949f2baae8..91712ecf82 100644 --- a/apps/remix-ide-e2e/src/local-plugin/src/app/logger.tsx +++ b/apps/remix-ide-e2e/src/local-plugin/src/app/logger.tsx @@ -1,12 +1,21 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import { useBehaviorSubject } from './usesubscribe/index' import { client } from './app' interface loggerProps { - + append: boolean } -export const Logger: React.FC = ({}) => { +export const Logger: React.FC = (props) => { const log = useBehaviorSubject(client.feedback) - return (
{typeof log === 'string' ? log : JSON.stringify(log)}
) + const [value, setValue] = useState('') + + useEffect(() => { + setValue(value => { + const addValue = typeof log === 'string' ? log : JSON.stringify(log) + return props.append ? `${value} ${addValue}` : addValue + }) + }, [log]) + + return (
{value}
) } diff --git a/apps/remix-ide-e2e/src/local-plugin/tests/plugin-api.test.ts b/apps/remix-ide-e2e/src/local-plugin/tests/plugin-api.test.ts index 8369b5aa1c..c2197099e6 100644 --- a/apps/remix-ide-e2e/src/local-plugin/tests/plugin-api.test.ts +++ b/apps/remix-ide-e2e/src/local-plugin/tests/plugin-api.test.ts @@ -1,16 +1,12 @@ import { Selector, RequestLogger, Role } from 'testcafe' import { Profile, LocationProfile, ExternalProfile } from '@remixproject/plugin-utils' -const logger = RequestLogger() - -const role = Role(process.env.TEST_URL || 'http://localhost:8080', async t => { - -}) - -fixture`DGIT production tests` - .page(process.env.TEST_URL || 'http://localhost:8080') +fixture`Plugin API tests` + .page(process.env.TEST_URL || 'http://127.0.0.1:8080') .beforeEach(async t => { + }).afterEach(async t => { + console.log(await t.getBrowserConsoleMessages()) }) const openPlugin = async (t: TestController, plugin: string) => { await t.click(`#icon-panel div[plugin="${plugin}"]`) @@ -20,7 +16,7 @@ interface dataIdSelectorInterface extends Selector { select(id: string): Promise } -const dataIdSelector = async (id:string) => { return Selector(`[data-id="${id}"]`) } +const dataIdSelector = async (id: string) => { return Selector(`[data-id="${id}"]`) } const installPlugin = async (t: TestController, profile: Profile & LocationProfile & ExternalProfile) => { await t.click('*[plugin="pluginManager"]') @@ -46,7 +42,7 @@ const localPluginData = { location: 'sidePanel', url: 'http://localhost:2020', canActivate: [ - 'dGitProvider,flattener' + 'dGitProvider,flattener,solidityUnitTesting' ] } @@ -64,7 +60,7 @@ test('install plugin', async t => { test.disablePageReloads('switch to plugin', async t => { await t .click('#verticalIconsKindpluginManager') - // .click('[data-id="pluginManagerComponentActivateButtondgittest"]') + // .click('[data-id="pluginManagerComponentActivateButtondgittest"]') .click('[data-id="verticalIconsKindlocalplugin"]') .switchToIframe('#plugin-localplugin') }) @@ -123,3 +119,18 @@ test.disablePageReloads('open a file', async t => { await expectLogMessage(t, file) }) + +test.disablePageReloads('run a test file', async t => { + await t + .click('#appendToLog') + .click(Selector('Button') + .withText('run sol test')) + .switchToMainWindow() + .click('#remember') + .click(Selector('span').withText('Accept')) + .switchToIframe('#plugin-localplugin') + .click(Selector('Button') + .withText('run sol test')).wait(5000) + + await expectLogMessage(t, '"totalPassing":1,"totalFailing":0') +}) diff --git a/apps/remix-ide/ci/browser_tests_plugin_api.sh b/apps/remix-ide/ci/browser_tests_plugin_api.sh index 3bc2d479a9..a5142b716b 100755 --- a/apps/remix-ide/ci/browser_tests_plugin_api.sh +++ b/apps/remix-ide/ci/browser_tests_plugin_api.sh @@ -8,9 +8,7 @@ TEST_EXITCODE=0 npm run serve & npx nx serve remix-ide-e2e-src-local-plugin & - -sleep 5 - +sleep 5 & npm run testcafe_local_pluginApi || TEST_EXITCODE=1 echo "$TEST_EXITCODE"