indexworkspace2
filip mertens 3 years ago
parent 0e50448477
commit 0201621d66
  1. 1
      .gitignore
  2. 13
      apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts
  3. 13
      apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
  4. 17
      apps/remix-ide-e2e/src/local-plugin/src/app/logger.tsx
  5. 29
      apps/remix-ide-e2e/src/local-plugin/tests/plugin-api.test.ts
  6. 4
      apps/remix-ide/ci/browser_tests_plugin_api.sh

1
.gitignore vendored

@ -52,3 +52,4 @@ testem.log
# System Files
.DS_Store
.vscode/settings.json
.vscode/launch.json

@ -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 () {

@ -8,21 +8,22 @@ export const client = new WorkSpacePlugin()
function App () {
const [payload, setPayload] = useState<string>('')
const [result, setResult] = useState<string>()
const [append, setAppend] = useState<boolean>(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 (
<div className="App">
<div>v5</div>
<Logger></Logger>
<Logger append={append}></Logger>
<input id='appendToLog' type='checkbox' onChange={setAppendChange}/><label>append logs</label>
<button className='btn btn-primary btn-sm' onClick={async () => await client.zip()}>zip</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.ipfspush()}>ipfs push</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.ipfspull(payload)}>ipfs pull</button>
@ -30,7 +31,7 @@ function App () {
<button className='btn btn-primary btn-sm' onClick={async () => await client.getAccounts()}>get accounts</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.setSettings()}>set settings to injected</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.getSettings()}>get settings</button>
<button className='btn btn-primary btn-sm' onClick={async () => await test()}>run sol test</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.soltest()}>run sol test</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.highlight(payload)}>highlight</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.addAnnotation(payload)}>annotation</button>
<button className='btn btn-primary btn-sm' onClick={async () => await client.clearAnnotations(payload)}>clear annotation</button>

@ -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<loggerProps> = ({}) => {
export const Logger: React.FC<loggerProps> = (props) => {
const log = useBehaviorSubject(client.feedback)
return (<div id='log'>{typeof log === 'string' ? log : JSON.stringify(log)}</div>)
const [value, setValue] = useState<string>('')
useEffect(() => {
setValue(value => {
const addValue = typeof log === 'string' ? log : JSON.stringify(log)
return props.append ? `${value} ${addValue}` : addValue
})
}, [log])
return (<div id='log'>{value}</div>)
}

@ -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}"]`)
@ -46,7 +42,7 @@ const localPluginData = {
location: 'sidePanel',
url: 'http://localhost:2020',
canActivate: [
'dGitProvider,flattener'
'dGitProvider,flattener,solidityUnitTesting'
]
}
@ -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')
})

@ -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"

Loading…
Cancel
Save