Skip to content

Commit 43c3791

Browse files
authored
Merge pull request #6096 from ethereum/scriptrunfix
fix script runner tests and config loader
2 parents fe958dd + 7aeefe9 commit 43c3791

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

apps/remix-ide-e2e/src/tests/script-runner.test.ts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const tests = {
2828
.click('button[data-id="script-config"]')
2929
.waitForElementVisible('[data-id="sr-loaded-default"]')
3030
.waitForElementVisible('[data-id="dependency-ethers-^5"]')
31-
.waitForElementVisible('[data-id="sr-load-ethers6"]')
31+
.waitForElementVisible('[data-id="sr-notloaded-ethers6"]')
3232
},
3333
'Should load script runner ethers6': function (browser: NightwatchBrowser) {
3434
browser
35-
.click('[data-id="sr-load-ethers6"]')
35+
.click('[data-id="sr-notloaded-ethers6"]')
3636
.waitForElementVisible('[data-id="sr-loaded-ethers6"]')
3737
.waitForElementPresent('[data-id="dependency-ethers-^6"]')
3838
},
@@ -74,6 +74,7 @@ const tests = {
7474
.waitForElementPresent('*[data-id="create-semaphore"]')
7575
.scrollAndClick('*[data-id="create-semaphore"]')
7676
.modalFooterOKClick('TemplatesSelection')
77+
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/semaphore.circom"]')
7778
.waitForElementVisible({
7879
locateStrategy: 'xpath',
7980
selector: "//li[@data-id='UIScriptRunner' and @role='tab']"
@@ -82,9 +83,37 @@ const tests = {
8283
locateStrategy: 'xpath',
8384
selector: "//li[@data-id='UIScriptRunner' and @role='tab']"
8485
})
85-
.waitForElementVisible('[data-id="sr-load-default"]')
86+
.waitForElementVisible('[data-id="sr-loaded-default"]')
8687
.waitForElementVisible('[data-id="dependency-ethers-^5"]')
87-
.waitForElementVisible('[data-id="sr-load-zksyncv6"]')
88+
.waitForElementVisible('[data-id="sr-notloaded-zksyncv6"]')
89+
},
90+
'open template that sets a config': function (browser: NightwatchBrowser) {
91+
browser
92+
.waitForElementVisible('*[data-id="workspacesMenuDropdown"]')
93+
.click('*[data-id="workspacesMenuDropdown"]')
94+
.click('*[data-id="workspacecreate"]')
95+
.waitForElementPresent('*[data-id="create-introToEIP7702"]')
96+
.scrollAndClick('*[data-id="create-introToEIP7702"]')
97+
.modalFooterOKClick('TemplatesSelection')
98+
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/Example7702.sol"]')
99+
.waitForElementVisible({
100+
locateStrategy: 'xpath',
101+
selector: "//li[@data-id='UIScriptRunner' and @role='tab']"
102+
})
103+
.click({
104+
locateStrategy: 'xpath',
105+
selector: "//li[@data-id='UIScriptRunner' and @role='tab']"
106+
})
107+
.waitForElementVisible('[data-id="sr-notloaded-default"]')
108+
.waitForElementVisible('[data-id="sr-loaded-ethers6"]')
109+
},
110+
'reset to default after template': function (browser: NightwatchBrowser) {
111+
browser
112+
.refreshPage()
113+
.waitForElementVisible('button[data-id="script-config"]')
114+
.click('button[data-id="script-config"]')
115+
.waitForElementVisible('[data-id="sr-notloaded-default"]')
116+
.waitForElementVisible('[data-id="sr-loaded-ethers6"]')
88117
},
89118
'switch to default workspace that should be on ethers6': function (browser: NightwatchBrowser) {
90119
browser
@@ -99,7 +128,9 @@ const tests = {
99128
})
100129
.waitForElementVisible('[data-id="sr-loaded-ethers6"]')
101130
.waitForElementPresent('[data-id="dependency-ethers-^6"]')
102-
}
131+
},
132+
133+
103134
}
104135

105136
module.exports = tests

apps/remix-ide/src/app/plugins/script-runner-bridge.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,18 @@ export class ScriptRunnerBridgePlugin extends Plugin {
7878
this.renderComponent()
7979
})
8080

81+
this.plugin.on('fileManager', 'fileAdded', async (file: string) => {
82+
if (file && file === configFileName) {
83+
await this.loadCustomConfig()
84+
await this.loadConfigurations()
85+
this.renderComponent()
86+
}
87+
})
88+
8189
this.plugin.on('fileManager', 'fileSaved', async (file: string) => {
82-
if (file === configFileName && this.enableCustomScriptRunner) {
90+
if (file && file === configFileName) {
8391
await this.loadCustomConfig()
92+
await this.loadConfigurations()
8493
this.renderComponent()
8594
}
8695
})

libs/remix-ui/scriptrunner/src/lib/components/config-section.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export default function ConfigSection(props: ConfigSectionProps) {
4242
checked={(props.activeConfig && props.activeConfig.name === props.config.name)}
4343
/>
4444
<label className="pointer form-check-label custom-control-label" htmlFor={`${props.config.title || props.config.name}`}
45-
data-id={`sr-load-${props.config.name}`}>
46-
<div data-id={`sr-loaded-${props.config.name}`} className="pl-2">{props.config.title || props.config.name}</div>
45+
data-id={`sr-${(props.activeConfig && props.activeConfig.name === props.config.name)?'loaded':'notloaded'}-${props.config.name}`}>
46+
<div className="pl-2">{props.config.title || props.config.name}</div>
4747
</label>
4848
</div>
4949
</section>

0 commit comments

Comments
 (0)