diff --git a/apps/remix-ide-e2e/src/tests/file_decorator.test.ts b/apps/remix-ide-e2e/src/tests/file_decorator.test.ts index 3483853cad..e69de29bb2 100644 --- a/apps/remix-ide-e2e/src/tests/file_decorator.test.ts +++ b/apps/remix-ide-e2e/src/tests/file_decorator.test.ts @@ -1,125 +0,0 @@ - -'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: testScriptSet }) - .pause(2000) - .executeScriptInTerminal('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') - .waitForElementContainsText('//*[@id="fileExplorerView"]//*[@data-id="file-decoration-custom-contracts/3_Ballot.sol"]', 'customtext') - .waitForElementContainsText('//*[@class="mainview"]//*[@data-id="file-decoration-custom-contracts/3_Ballot.sol"]', 'customtext') - .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') - }, - - 'clear ballot decorator': function (browser: NightwatchBrowser) { - browser - .useCss() - .addFile('scripts/clearballot.ts', { content: testScriptClearBallot }) - .pause(2000) - .executeScriptInTerminal('remix.exeCurrent()') - .pause(4000) - .waitForElementNotPresent('[data-id="file-decoration-custom-contracts/3_Ballot.sol"]', 10000) - }, - 'clear all decorators': function (browser: NightwatchBrowser) { - browser - .addFile('scripts/clearall.ts', { content: testScriptClear }) - .pause(2000) - .executeScriptInTerminal('remix.exeCurrent()') - .pause(4000) - .waitForElementNotPresent('[data-id="file-decoration-error-contracts/2_Owner.sol"]', 10000) - .waitForElementNotPresent('[data-id="file-decoration-warning-contracts/1_Storage.sol"]', 10000) - } - - -} -const testScriptSet = ` -(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', - 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: '', - bubble: true, - comment: 'modified', - } - await 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', - bubble: true, - comment: 'warning on storage', - } - await remix.call('fileDecorator' as any, 'setFileDecorators', decorator) - - decorator = { - path: 'contracts/3_Ballot.sol', - isDirectory: false, - fileStateType: 'CUSTOM', - fileStateLabelClass: '', - fileStateIconClass: '', - fileStateIcon: 'customtext', - text: 'with text', - bubble: true, - comment: 'custom comment', - } - await remix.call('fileDecorator' as any, 'setFileDecorators', decorator) - - })()` - - -const testScriptClearBallot = ` - (async () => { - - await remix.call('fileDecorator' as any, 'clearFileDecorators', 'contracts/3_Ballot.sol') - - })()` - -const testScriptClear = ` - (async () => { - await remix.call('fileDecorator' as any, 'clearAllFileDecorators') - - - })()` \ No newline at end of file diff --git a/apps/remix-ide/src/app/plugins/file-decorator.ts b/apps/remix-ide/src/app/plugins/file-decorator.ts index 9b6d304b02..85ad3a4f8f 100644 --- a/apps/remix-ide/src/app/plugins/file-decorator.ts +++ b/apps/remix-ide/src/app/plugins/file-decorator.ts @@ -8,11 +8,7 @@ import { fileDecoration } from '@remix-ui/file-decorators' const profile = { name: 'fileDecorator', desciption: 'Keeps decorators of the files', -<<<<<<< HEAD methods: ['setFileDecorators', 'clearFileDecorators', 'clearAllFileDecorators'], -======= - methods: ['setFileDecorators', 'clearFileDecorators'], ->>>>>>> 43bc1038a (add test) events: ['fileDecoratorsChanged'], version: '0.0.1' } @@ -22,25 +18,11 @@ export class FileDecorator extends Plugin { constructor() { super(profile) } -<<<<<<< HEAD - - onActivation(): void { - this.on('filePanel', 'setWorkspace', async () => { - await this.clearAllFileDecorators() - }) - } - -======= ->>>>>>> 43bc1038a (add test) /** * * @param fileStates Array of file states */ async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) { -<<<<<<< HEAD - const { from } = this.currentRequest - const workspace = await this.call('filePanel', 'getCurrentWorkspace') -======= const workspace = await this.call('filePanel', 'getCurrentWorkspace') function sortByPath( a: fileDecoration, b: fileDecoration ) { if ( a.path < b.path ){ @@ -52,49 +34,20 @@ export class FileDecorator extends Plugin { return 0; } ->>>>>>> 43bc1038a (add test) const fileStatesPayload = Array.isArray(fileStates) ? fileStates : [fileStates] // clear all file states in the previous state of this owner on the files called fileStatesPayload.forEach((state) => { state.workspace = workspace -<<<<<<< HEAD state.owner = from }) const filteredState = this._fileStates.filter((state) => { const index = fileStatesPayload.findIndex((payloadFileState: fileDecoration) => { return from == state.owner && payloadFileState.path == state.path -======= - }) - const filteredState = this._fileStates.filter((state) => { - const index = fileStatesPayload.findIndex((payloadFileState: fileDecoration) => { - return payloadFileState.owner == state.owner && payloadFileState.path == state.path ->>>>>>> 43bc1038a (add test) }) return index == -1 }) const newState = [...filteredState, ...fileStatesPayload].sort(sortByPath) -<<<<<<< HEAD - -======= ->>>>>>> 43bc1038a (add test) - if (!deepequal(newState, this._fileStates)) { - this._fileStates = newState - this.emit('fileDecoratorsChanged', this._fileStates) - } - } - -<<<<<<< HEAD - async clearFileDecorators(path?: string) { - const { from } = this.currentRequest - if (!from) return - - const filteredState = this._fileStates.filter((state) => { - if(state.owner != from) return true - if(path && state.path != path) return true - }) - const newState = [...filteredState].sort(sortByPath) - if (!deepequal(newState, this._fileStates)) { this._fileStates = newState this.emit('fileDecoratorsChanged', this._fileStates) @@ -102,24 +55,8 @@ export class FileDecorator extends Plugin { } - async clearAllFileDecorators() { - this._fileStates = [] - this.emit('fileDecoratorsChanged', []) - } -} - -const sortByPath = (a: fileDecoration, b: fileDecoration) => { - if (a.path < b.path) { - return -1; - } - if (a.path > b.path) { - return 1; - } - return 0; -======= async clearFileDecorators() { this._fileStates = [] this.emit('fileDecoratorsChanged', []) } ->>>>>>> 43bc1038a (add test) } \ No newline at end of file diff --git a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx index 807331e0b9..c157bc66c0 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx @@ -5,11 +5,7 @@ import { fileDecoration } from '../../types' const FileDecorationCustomIcon = (props: { fileDecoration: fileDecoration }) => { -<<<<<<< HEAD - return <> -======= return <> ->>>>>>> 43bc1038a (add test) {props.fileDecoration.fileStateIcon} } diff --git a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx index 07b7db6b5f..2bb61fd97f 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx @@ -7,11 +7,7 @@ const FileDecorationErrorIcon = (props: { fileDecoration: fileDecoration }) => { return <> -<<<<<<< HEAD - {props.fileDecoration.text} -======= {props.fileDecoration.text} ->>>>>>> 43bc1038a (add test) } diff --git a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx index d7bddff75e..1c027c9854 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx @@ -5,11 +5,7 @@ import { fileDecoration } from '../../types' const FileDecorationWarningIcon = (props: { fileDecoration: fileDecoration }) => { -<<<<<<< HEAD - return <>{props.fileDecoration.text} -======= return <>{props.fileDecoration.text} ->>>>>>> 43bc1038a (add test) } export default FileDecorationWarningIcon \ No newline at end of file