Skip to content

Commit ef88b04

Browse files
committed
run tests
1 parent 0932e7a commit ef88b04

File tree

5 files changed

+290
-47
lines changed

5 files changed

+290
-47
lines changed
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
'use strict'
2+
3+
import { NightwatchBrowser } from 'nightwatch'
4+
import init from '../helpers/init'
5+
6+
const templatesToCheck = [
7+
{
8+
value: "remixDefault",
9+
displayName: "Basic",
10+
checkSelectors: [
11+
'*[data-id="treeViewLitreeViewItemcontracts/3_Ballot.sol"]',
12+
'*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]'
13+
]
14+
},
15+
{
16+
value: "blank",
17+
displayName: "Blank",
18+
checkSelectors: ['*[data-id="treeViewLitreeViewItem.prettierrc.json"]']
19+
},
20+
{
21+
value: "simpleEip7702",
22+
displayName: "Simple EIP-7702",
23+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcontracts/Example7702.sol"]']
24+
},
25+
{
26+
value: "introToEIP7702",
27+
displayName: "Intro to EIP-7702",
28+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcontracts/Spender.sol"]']
29+
},
30+
{
31+
value: "accountAbstraction",
32+
displayName: "Account Abstraction",
33+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemfunding.json"]']
34+
},
35+
{
36+
value: "ozerc20",
37+
displayName: "ERC20",
38+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcontracts/MyToken.sol"]']
39+
},
40+
{
41+
value: "ozerc721",
42+
displayName: "ERC721",
43+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcontracts/MyToken.sol"]']
44+
},
45+
{
46+
value: "ozerc1155",
47+
displayName: "ERC1155",
48+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcontracts/MyToken.sol"]']
49+
},
50+
{
51+
value: "zeroxErc20",
52+
displayName: "ERC20",
53+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcontracts/SampleERC20.sol"]']
54+
},
55+
{
56+
value: "gnosisSafeMultisig",
57+
displayName: "MultiSig",
58+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcontracts/MultisigWallet.sol"]']
59+
},
60+
{
61+
value: "semaphore",
62+
displayName: "Semaphore",
63+
checkSelectors: ['*[data-id="treeViewLitreeViewItemcircuits/semaphore.circom"]']
64+
},
65+
{
66+
value: "hashchecker",
67+
displayName: "Hash",
68+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemcircuits/calculate_hash.circom"]']
69+
},
70+
{
71+
value: "rln",
72+
displayName: "Rate",
73+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemcircuits/rln.circom"]']
74+
},
75+
{
76+
value: "multNr",
77+
displayName: "Multiplier",
78+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemsrc/main.nr"]']
79+
},
80+
{
81+
value: "sindriScripts",
82+
displayName: "Add Sindri ZK scripts",
83+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemscripts/sindri/run_compile.ts"]']
84+
},
85+
{
86+
value: "uniswapV4Template",
87+
displayName: "v4 Template",
88+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemfoundry.toml"]']
89+
},
90+
{
91+
value: "contractCreate2Factory",
92+
displayName: "Add Create2 Solidity factory",
93+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemcontracts/libs/create2-factory.sol"]']
94+
},
95+
{
96+
value: "contractDeployerScripts",
97+
displayName: "Add contract deployer scripts",
98+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemscripts/contract-deployer/basic-contract-deploy.ts"]']
99+
},
100+
{
101+
value: "etherscanScripts",
102+
displayName: "Add Etherscan scripts",
103+
checkSelectors: ['*[data-id="treeViewDivtreeViewItemscripts/etherscan/receiptGuidScript.ts"]']
104+
},
105+
{
106+
value: "runJsTestAction",
107+
displayName: "Mocha Chai Test Workflow",
108+
checkSelectors: ['*[data-id="treeViewDivtreeViewItem.github/workflows/run-js-test.yml"]']
109+
},
110+
{
111+
value: "runSolidityUnittestingAction",
112+
displayName: "Solidity Test Workflow",
113+
checkSelectors: ['*[data-id="treeViewDivtreeViewItem.github/workflows/run-solidity-unittesting.yml"]']
114+
},
115+
{
116+
value: "runSlitherAction",
117+
displayName: "Slither Workflo",
118+
checkSelectors: ['*[data-id="treeViewDivtreeViewItem.github/workflows/run-slither-action.yml"]']
119+
}
120+
]
121+
122+
function openTemplatesExplorer(browser: NightwatchBrowser) {
123+
browser
124+
.click('*[data-id="workspacesMenuDropdown"]')
125+
.click('*[data-id="workspacecreate"]')
126+
.waitForElementPresent('*[data-id="create-remixDefault"]')
127+
}
128+
129+
function runTemplateChecks(
130+
browser: NightwatchBrowser,
131+
start: number,
132+
end: number,
133+
mode: 'create' | 'add' = 'create'
134+
) {
135+
templatesToCheck.slice(start, end).forEach(({ value, displayName, checkSelectors }) => {
136+
console.log(`Checking template: ${value} in ${mode} mode`)
137+
openTemplatesExplorer(browser)
138+
139+
if (mode === 'create') {
140+
browser
141+
.waitForElementVisible(`[data-id="create-${value}"]`, 5000)
142+
.click(`[data-id="create-${value}"]`)
143+
} else {
144+
browser
145+
.waitForElementVisible(`[data-id="create-blank"]`, 5000)
146+
.click(`[data-id="create-blank"]`)
147+
}
148+
149+
browser
150+
.waitForElementVisible('*[data-id="TemplatesSelection-modal-footer-ok-react"]', 2000)
151+
.click('*[data-id="TemplatesSelection-modal-footer-ok-react"]')
152+
.pause(1000)
153+
154+
if (mode === 'add') {
155+
browser.element('css selector', `[data-id="add-${value}"]`, result => {
156+
console.log(`Element add-${value} status: ${result.status}`)
157+
if (result.status == 0) {
158+
openTemplatesExplorer(browser)
159+
browser
160+
.waitForElementVisible(`[data-id="add-${value}"]`, 5000)
161+
.click(`[data-id="add-${value}"]`)
162+
163+
checkSelectors.forEach(selector => {
164+
console.log(`Checking selector: ${selector}`)
165+
browser.waitForElementVisible(selector, 30000)
166+
})
167+
}
168+
})
169+
} else {
170+
browser
171+
.useXpath()
172+
.waitForElementVisible(`//div[contains(@data-id, "dropdown-content") and contains(., "${displayName}")]`, 5000)
173+
.useCss()
174+
175+
checkSelectors.forEach(selector => {
176+
console.log(`Checking selector: ${selector}`)
177+
browser.waitForElementVisible(selector, 30000)
178+
})
179+
}
180+
})
181+
}
182+
183+
module.exports = {
184+
'@disabled': true,
185+
before: function (browser: NightwatchBrowser, done: VoidFunction) {
186+
init(browser, done)
187+
},
188+
openFilePanel: function (browser: NightwatchBrowser) {
189+
browser.clickLaunchIcon('filePanel')
190+
},
191+
'Loop through templates and click create #group1': function (browser) {
192+
runTemplateChecks(browser, 0, templatesToCheck.length, 'create')
193+
},
194+
'Loop through templates and click add buttons #group2': function (browser) {
195+
runTemplateChecks(browser, 0, templatesToCheck.length, 'add')
196+
}
197+
}

apps/remix-ide/src/app/plugins/templates-selection/templates-selection-plugin.tsx

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import isElectron from 'is-electron'
1212
import type { TemplateGroup } from '@remix-ui/workspace'
1313
import './templates-selection-plugin.css'
1414
import { templates } from './templates'
15+
import { TEMPLATE_METADATA } from '@remix-ui/workspace'
1516

1617
//@ts-ignore
1718
const _paq = (window._paq = window._paq || [])
@@ -76,7 +77,7 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
7677
if (error) {
7778
const modal: AppModal = {
7879
id: 'TemplatesSelection',
79-
title: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.workspace.create': 'filePanel.workspace.create.desktop' }),
80+
title: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.workspace.create' : 'filePanel.workspace.create.desktop' }),
8081
message: error.message,
8182
okLabel: window._intl.formatMessage({ id: 'filePanel.ok' }),
8283
cancelLabel: window._intl.formatMessage({ id: 'filePanel.cancel' })
@@ -96,9 +97,9 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
9697
let initGit = false
9798
const modal: AppModal = {
9899
id: 'TemplatesSelection',
99-
title: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.workspace.create': 'filePanel.workspace.create.desktop' }),
100+
title: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.workspace.create' : 'filePanel.workspace.create.desktop' }),
100101
message: await createModalMessage(defaultName, gitNotSet, (value) => workspaceName = value, (value) => initGit = !!value, (event) => setCheckBoxRefs(event), (event) => setRadioRefs(event), templateName),
101-
okLabel: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.ok':'filePanel.selectFolder' }),
102+
okLabel: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.ok' : 'filePanel.selectFolder' }),
102103
}
103104
const modalResult = await this.call('notification', 'modal', modal)
104105
if (!modalResult) return
@@ -112,7 +113,7 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
112113
if (e) {
113114
const modal: AppModal = {
114115
id: 'TemplatesSelection',
115-
title: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.workspace.create': 'filePanel.workspace.create.desktop' }),
116+
title: window._intl.formatMessage({ id: !isElectron() ? 'filePanel.workspace.create' : 'filePanel.workspace.create.desktop' }),
116117
message: e.message,
117118
okLabel: window._intl.formatMessage({ id: 'filePanel.ok' }),
118119
cancelLabel: window._intl.formatMessage({ id: 'filePanel.cancel' })
@@ -173,6 +174,8 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
173174
hScrollable={false}
174175
>
175176
{template.items.map((item, index) => {
177+
item.templateType = TEMPLATE_METADATA[item.value]
178+
if(item.templateType && item.templateType.disabled === true) return
176179
if (!item.opts) {
177180
return (
178181
<RemixUIGridCell
@@ -197,7 +200,7 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
197200
</div>
198201
</div>
199202
<div className='align-items-center justify-content-between w-100 d-flex pt- flex-row'>
200-
{(!template.IsArtefact || !item.isArtefact) && <CustomTooltip
203+
{(!template.IsArtefact || !item.IsArtefact) && <CustomTooltip
201204
placement="auto"
202205
tooltipId={`overlay-tooltip-new${item.name}`}
203206
tooltipText="Create a new workspace"
@@ -209,29 +212,30 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
209212
}}
210213
className="btn btn-sm mr-2 border border-primary"
211214
>
212-
Create
215+
Create
213216
</span>
214217
</CustomTooltip>}
215-
<CustomTooltip
216-
placement="auto"
217-
tooltipId={`overlay-tooltip-add${item.name}`}
218-
tooltipText="Add template files to current workspace"
219-
>
220-
<span
221-
data-id={`add-${item.value}`}
222-
onClick={async () => addToCurrentWorkspace(item)}
223-
className="btn btn-sm border"
218+
{item.templateType && item.templateType.forceCreateNewWorkspace ? <></> :
219+
<CustomTooltip
220+
placement="auto"
221+
tooltipId={`overlay-tooltip-add${item.name}`}
222+
tooltipText="Add template files to current workspace"
224223
>
225-
Add to current
226-
</span>
227-
</CustomTooltip>
224+
<span
225+
data-id={`add-${item.value}`}
226+
onClick={async () => addToCurrentWorkspace(item)}
227+
className="btn btn-sm border"
228+
>
229+
Add to current
230+
</span>
231+
</CustomTooltip>}
228232
</div>
229233
</div>
230234
</RemixUIGridCell>
231235
)
232236
}
233237
})}
234-
{ template.name === 'Cookbook' && <RemixUIGridCell
238+
{template.name === 'Cookbook' && <RemixUIGridCell
235239
plugin={this}
236240
title={"More from Cookbook"}
237241
key={"cookbookMore"}
@@ -241,10 +245,10 @@ export class TemplatesSelectionPlugin extends ViewPlugin {
241245
classList='TSCellStyle'
242246
>
243247
<div className='d-flex justify-content-between h-100 flex-column'>
244-
<span className='pt-4 px-1 h6 text-dark'>{ template.description }</span>
245-
<span style={{ cursor: 'pointer' }} className='mt-2 btn btn-sm border align-items-left' onClick={() => template.onClick() }>{ template.onClickLabel }</span>
248+
<span className='pt-4 px-1 h6 text-dark'>{template.description}</span>
249+
<span style={{ cursor: 'pointer' }} className='mt-2 btn btn-sm border align-items-left' onClick={() => template.onClick()}>{template.onClickLabel}</span>
246250
</div>
247-
</RemixUIGridCell> }
251+
</RemixUIGridCell>}
248252
</RemixUIGridSection>
249253
})}
250254
</RemixUIGridView>
@@ -317,7 +321,7 @@ const createModalMessage = async (
317321
<div className="d-flex ml-2 custom-control custom-radio">
318322
<input className="custom-control-input" type="radio" name="upgradeability" value="uups" id="uups" onChange={onChangeRadioRefs} />
319323
<label className="form-check-label custom-control-label" htmlFor="uups" data-id="upgradeTypeUups">
320-
UUPS
324+
UUPS
321325
</label>
322326
</div>
323327
</div>

apps/remix-ide/src/app/plugins/templates-selection/templates.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const templates = (intl, plugin) => {
1+
import { Template, TemplateGroup } from "@remix-ui/workspace"
2+
export const templates = (intl: any, plugin: any): TemplateGroup[] => {
3+
24
return [
35
{
46
name: "Generic",
@@ -269,8 +271,8 @@ export const templates = (intl, plugin) => {
269271
},
270272
onClickLabel: 'Open Cookbook Plugin',
271273
description: 'Discover more templates!',
272-
items: [
273-
{
274+
items: [],
275+
/* {
274276
value: "token-sale",
275277
displayName: 'Token Sale',
276278
description: "ERC20 token sale contact. Sell tokens for ETH"
@@ -316,8 +318,8 @@ export const templates = (intl, plugin) => {
316318
opts: {
317319
burnable: true,
318320
pausable: true
319-
}, },
320-
]
321+
}, },
322+
]*/
321323
},
322324
{
323325
name: "0xProject",

libs/remix-ui/workspace/src/lib/types/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ export type TemplateType = {
6464
name?: string
6565
endpoint?: string
6666
params?: any[]
67+
desktopCompatible?: boolean
68+
forceCreateNewWorkspace?: boolean
69+
disabled?: boolean
6770
}
6871

6972
export interface FilePanelType extends ViewPlugin {

0 commit comments

Comments
 (0)