pull/2399/head
filip mertens 2 years ago
parent f88691e4ed
commit 36c7e3ef1c
  1. 3
      apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts
  2. 97
      apps/remix-ide-e2e/src/tests/file_decorator.test.ts
  3. 2
      apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts
  4. 6
      libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-tooltip.tsx
  5. 6
      libs/remix-ui/file-decorators/src/lib/helper/index.tsx
  6. 2
      libs/remix-ui/file-decorators/src/lib/types/index.ts

@ -514,5 +514,4 @@ module.exports = {
.sendKeys(this.Keys.ENTER)
})
}
}
}

@ -0,0 +1,97 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'Test decorators with script': function (browser: NightwatchBrowser) {
browser
.openFile('contracts')
.openFile('contracts/2_Owner.sol')
.openFile('contracts/1_Storage.sol')
.openFile('contracts/3_Ballot.sol')
.addFile('scripts/decorators.ts', { content: testScript })
.pause(2000)
.executeScript('remix.exeCurrent()')
.pause(4000)
.useXpath()
.waitForElementContainsText('//*[@id="fileExplorerView"]//*[@data-id="file-decoration-error-contracts/2_Owner.sol"]', '2')
.waitForElementContainsText('//*[@class="mainview"]//*[@data-id="file-decoration-error-contracts/2_Owner.sol"]', '2')
.waitForElementContainsText('//*[@id="fileExplorerView"]//*[@data-id="file-decoration-custom-contracts/2_Owner.sol"]', 'U')
.waitForElementContainsText('//*[@class="mainview"]//*[@data-id="file-decoration-custom-contracts/2_Owner.sol"]', 'U')
.waitForElementContainsText('//*[@id="fileExplorerView"]//*[@data-id="file-decoration-warning-contracts/1_Storage.sol"]', '2')
.waitForElementContainsText('//*[@class="mainview"]//*[@data-id="file-decoration-warning-contracts/1_Storage.sol"]', '2')
.useCss()
.waitForElementNotPresent('[data-id="file-decoration-custom-contracts/3_Ballot.sol"]', 10000)
.useXpath()
.moveToElement('//*[@id="fileExplorerView"]//*[@data-id="file-decoration-error-contracts/2_Owner.sol"]', 0,0)
.waitForElementVisible('//*[@id="error-tooltip-contracts/2_Owner.sol"]')
.waitForElementContainsText('//*[@id="error-tooltip-contracts/2_Owner.sol"]', 'error on owner')
}
}
const testScript = `
(async () => {
remix.call('fileDecorator' as any, 'clearFileDecorators')
let decorator: any = {
path: 'contracts/2_Owner.sol',
isDirectory: false,
fileStateType: 'ERROR',
fileStateLabelClass: 'text-danger',
fileStateIconClass: '',
fileStateIcon: '',
text: '2',
owner: 'code-parser',
bubble: true,
comment: 'error on owner',
}
let decorator2: any = {
path: 'contracts/2_Owner.sol',
isDirectory: false,
fileStateType: 'CUSTOM',
fileStateLabelClass: 'text-success',
fileStateIconClass: 'text-success',
fileStateIcon: 'U',
text: '',
owner: 'code-parser',
bubble: true,
comment: 'modified',
}
remix.call('fileDecorator' as any, 'setFileDecorators', [decorator, decorator2])
decorator = {
path: 'contracts/1_Storage.sol',
isDirectory: false,
fileStateType: 'WARNING',
fileStateLabelClass: 'text-warning',
fileStateIconClass: '',
fileStateIcon: '',
text: '2',
owner: 'code-parser',
bubble: true,
comment: 'warning on storage',
}
remix.call('fileDecorator' as any, 'setFileDecorators', decorator)
decorator = {
path: 'contracts/3_Ballot.sol',
isDirectory: false,
fileStateType: 'CUSTOM',
fileStateLabelClass: '',
fileStateIconClass: '',
fileStateIcon: 'customtext',
text: 'w',
owner: 'dgit',
bubble: true,
comment: '',
}
remix.call('fileDecorator' as any, 'setFileDecorators', decorator)
remix.call('fileDecorator' as any, 'clearFileDecorators', 'dgit')
})()`

@ -156,7 +156,7 @@ export default class CodeParserCompiler {
text: errors.length,
owner: 'code-parser',
bubble: true,
commment: errors.map((error) => error.message),
comment: errors.map((error) => error.message),
}
decorators.push(decorator)
}

@ -9,9 +9,9 @@ const FileDecorationTooltip = (props: {
},
) => {
const getComments = function (fileDecoration: fileDecoration) {
if (fileDecoration.commment) {
const commments = Array.isArray(fileDecoration.commment) ? fileDecoration.commment : [fileDecoration.commment]
return commments.map((comment, index) => {
if (fileDecoration.comment) {
const comments = Array.isArray(fileDecoration.comment) ? fileDecoration.comment : [fileDecoration.comment]
return comments.map((comment, index) => {
return <div key={index}>{comment}<br></br></div>
})
}

@ -2,9 +2,9 @@ import React from "react"
import { fileDecoration } from "../types"
export const getComments = function (fileDecoration: fileDecoration) {
if(fileDecoration.commment){
const commments = Array.isArray(fileDecoration.commment) ? fileDecoration.commment : [fileDecoration.commment]
return commments.map((comment, index) => {
if(fileDecoration.comment){
const comments = Array.isArray(fileDecoration.comment) ? fileDecoration.comment : [fileDecoration.comment]
return comments.map((comment, index) => {
return <div key={index}>{comment}<br></br></div>
})
}

@ -17,7 +17,7 @@ export enum fileDecorationType {
owner: string,
workspace?: any
tooltip?: string
commment?: string[] | string
comment?: string[] | string
}
export interface FileType {

Loading…
Cancel
Save