run offline test

pull/5370/head
bunsenstraat 8 months ago
parent f8184e57dc
commit 9546be9212
  1. 5
      .circleci/config.yml
  2. 1
      apps/remixdesktop/package.json
  3. 47
      apps/remixdesktop/src/plugins/compilerLoader.ts
  4. 2
      apps/remixdesktop/test/nighwatch.app.ts
  5. 41
      apps/remixdesktop/test/tests/app/offline.test.ts

@ -130,7 +130,7 @@ jobs:
name: "Run tests" name: "Run tests"
command: | command: |
cd apps/remixdesktop/ cd apps/remixdesktop/
yarn run build:e2e && yarn run test && yarn run test:isogit yarn run build:e2e && yarn run test:offline && yarn run test && yarn run test:isogit
build-remixdesktop-linux: build-remixdesktop-linux:
machine: machine:
@ -267,6 +267,7 @@ jobs:
cd "apps/remixdesktop/" cd "apps/remixdesktop/"
yarn -v yarn -v
sleep 15 sleep 15
yarn run test:offline
yarn run test yarn run test
yarn run test:isogit yarn run test:isogit
shell: powershell.exe shell: powershell.exe
@ -508,7 +509,7 @@ jobs:
command: | command: |
nvm use 20 nvm use 20
cd apps/remixdesktop cd apps/remixdesktop
yarn run test && yarn run test:isogit yarn run test:offline && yarn run test && yarn run test:isogit
uploadartifacts: uploadartifacts:
docker: docker:

@ -30,6 +30,7 @@
"postinstall": "electron-builder install-app-deps", "postinstall": "electron-builder install-app-deps",
"test": "yarn run build:e2e && nightwatch --config build-e2e/remixdesktop/test/nighwatch.app.js", "test": "yarn run build:e2e && nightwatch --config build-e2e/remixdesktop/test/nighwatch.app.js",
"test:isogit": "yarn run test --useIsoGit --test build-e2e/remixdesktop/test/tests/app/git.test.js", "test:isogit": "yarn run test --useIsoGit --test build-e2e/remixdesktop/test/tests/app/git.test.js",
"test:offline": "yarn run test --useOffline --test build-e2e/remixdesktop/test/tests/app/offline.test.js",
"build:e2e": "tsc -p tsconfig.e2e.json" "build:e2e": "tsc -p tsconfig.e2e.json"
}, },
"devDependencies": { "devDependencies": {

@ -1,16 +1,19 @@
import {Profile} from '@remixproject/plugin-utils' import { Profile } from '@remixproject/plugin-utils'
import {ElectronBasePlugin, ElectronBasePluginClient} from '@remixproject/plugin-electron' import { ElectronBasePlugin, ElectronBasePluginClient } from '@remixproject/plugin-electron'
import fs from 'fs/promises' import fs from 'fs/promises'
import axios from 'axios' import axios from 'axios'
import express from 'express' import express from 'express'
import {cacheDir} from '../utils/config' import { cacheDir } from '../utils/config'
export const baseURLBin = 'https://binaries.soliditylang.org/bin' export const baseURLBin = 'https://binaries.soliditylang.org/bin'
export const baseURLWasm = 'https://binaries.soliditylang.org/wasm' export const baseURLWasm = 'https://binaries.soliditylang.org/wasm'
const appExpress = express() const appExpress = express()
// used in e2e tests
const useOffline = process.argv.includes('--useOffline');
console.log('cacheDir', cacheDir) console.log('cacheDir', cacheDir)
appExpress.use(express.static(cacheDir)) appExpress.use(express.static(cacheDir))
const server = appExpress.listen(0, () => { const server = appExpress.listen(0, () => {
@ -28,9 +31,9 @@ export class CompilerLoaderPlugin extends ElectronBasePlugin {
constructor() { constructor() {
super(profile, clientProfile, CompilerLoaderPluginClient) super(profile, clientProfile, CompilerLoaderPluginClient)
this.methods = [...super.methods] this.methods = [...super.methods]
;(async () => { ; (async () => {
await getLists() await getLists()
})() })()
} }
@ -73,7 +76,7 @@ class CompilerLoaderPluginClient extends ElectronBasePluginClient {
async downloadCompiler(url: string): Promise<void> { async downloadCompiler(url: string): Promise<void> {
console.log('downloadCompiler', url) console.log('downloadCompiler', url)
if(url.includes('localhost')) return if (url.includes('localhost')) return
const plugin = this const plugin = this
try { try {
const fileName = url.split('/').pop() const fileName = url.split('/').pop()
@ -127,7 +130,7 @@ class CompilerLoaderPluginClient extends ElectronBasePluginClient {
async getJsonBinData() { async getJsonBinData() {
const lists = await this.getLists() const lists = await this.getLists()
this.solJsonBinData = { this.solJsonBinData = {
baseURLWasm: 'http://localhost:' + (server.address() as any).port + '/compilers', baseURLWasm: 'http://localhost:' + (server.address() as any).port + '/compilers',
baseURLBin: 'http://localhost:' + (server.address() as any).port + '/compilers', baseURLBin: 'http://localhost:' + (server.address() as any).port + '/compilers',
@ -137,11 +140,11 @@ class CompilerLoaderPluginClient extends ElectronBasePluginClient {
const localCompilers = await this.listCompilers() const localCompilers = await this.listCompilers()
this.solJsonBinData.wasmList && (this.solJsonBinData.wasmList = this.solJsonBinData.wasmList.map((item) => { this.solJsonBinData.wasmList && (this.solJsonBinData.wasmList = this.solJsonBinData.wasmList.map((item) => {
localCompilers.includes(item.path) ? (item.wasmURL = 'http://localhost:' + (server.address() as any).port + '/compilers/') && (item.isDownloaded=true) : (item.wasmURL = baseURLWasm) && (item.isDownloaded = false) localCompilers.includes(item.path) ? (item.wasmURL = 'http://localhost:' + (server.address() as any).port + '/compilers/') && (item.isDownloaded = true) : (item.wasmURL = baseURLWasm) && (item.isDownloaded = false)
return item return item
})) }))
this.solJsonBinData.binList && (this.solJsonBinData.binList = this.solJsonBinData.binList.map((item) => { this.solJsonBinData.binList && (this.solJsonBinData.binList = this.solJsonBinData.binList.map((item) => {
localCompilers.includes(item.path) ? (item.binURL = 'http://localhost:' + (server.address() as any).port + '/compilers/') && (item.isDownloaded=true) : (item.binURL = baseURLBin) && (item.isDownloaded = false) localCompilers.includes(item.path) ? (item.binURL = 'http://localhost:' + (server.address() as any).port + '/compilers/') && (item.isDownloaded = true) : (item.binURL = baseURLBin) && (item.isDownloaded = false)
return item return item
})) }))
this.emit('jsonBinDataLoaded', this.solJsonBinData) this.emit('jsonBinDataLoaded', this.solJsonBinData)
@ -156,17 +159,19 @@ const getLists = async () => {
let binData let binData
let wasmData let wasmData
try { if (!useOffline) {
const binRes = await axios.get(baseURLBin + '/list.json') try {
await fs.writeFile(cacheDir + '/binlist.json', JSON.stringify(binRes.data, null, 2)) const binRes = await axios.get(baseURLBin + '/list.json')
binData = binRes.data await fs.writeFile(cacheDir + '/binlist.json', JSON.stringify(binRes.data, null, 2))
} catch (e) {} binData = binRes.data
} catch (e) { }
try {
const wasmRes = await axios.get(baseURLWasm + '/list.json') try {
await fs.writeFile(cacheDir + '/wasmlist.json', JSON.stringify(wasmRes.data, null, 2)) const wasmRes = await axios.get(baseURLWasm + '/list.json')
wasmData = wasmRes.data await fs.writeFile(cacheDir + '/wasmlist.json', JSON.stringify(wasmRes.data, null, 2))
} catch (e) {} wasmData = wasmRes.data
} catch (e) { }
}
if (!wasmData) { if (!wasmData) {
try { try {

@ -3,6 +3,7 @@ const os = require('os');
const http = require('http'); const http = require('http');
const useIsoGit = process.argv.includes('--useIsoGit'); const useIsoGit = process.argv.includes('--useIsoGit');
const useOffline = process.argv.includes('--useOffline');
// Function to check if localhost:8080 is active // Function to check if localhost:8080 is active
function checkLocalhost8080Active(callback) { function checkLocalhost8080Active(callback) {
@ -84,6 +85,7 @@ module.exports = {
let args = process.env.CIRCLECI ? ["--e2e"] : ["--e2e-local"]; let args = process.env.CIRCLECI ? ["--e2e"] : ["--e2e-local"];
if(useIsoGit) args = [...args, '--useIsoGit']; if(useIsoGit) args = [...args, '--useIsoGit'];
if(useOffline) args = [...args, '--useOffline'];
if(!process.env.CIRCLECI){ if(!process.env.CIRCLECI){
checkLocalhost8080Active((isActive)=>{ checkLocalhost8080Active((isActive)=>{

@ -0,0 +1,41 @@
import { NightwatchBrowser } from 'nightwatch'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
done()
},
'open default template': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.waitForElementVisible('button[data-id="landingPageImportFromTemplate"]')
.click('button[data-id="landingPageImportFromTemplate"]')
.waitForElementVisible('*[data-id="modalDialogCustomPromptTextCreate"]')
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok')
.click('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok')
.pause(3000)
.windowHandles(function (result) {
console.log(result.value)
browser.switchWindow(result.value[1])
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]')
.click('*[data-id="treeViewLitreeViewItemtests"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]')
.click('*[data-id="treeViewLitreeViewItemcontracts"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]')
.openFile('contracts/1_Storage.sol')
.waitForElementVisible('*[id="editorView"]', 10000)
.getEditorValue((content) => {
browser.assert.ok(content.includes('function retrieve() public view returns (uint256){'))
})
})
},
'compile storage': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('solidity')
.pause(1000)
.waitForElementVisible('*[data-id="compilerContainerCompileBtn"]')
.click('[data-id="compilerContainerCompileBtn"]')
.clickLaunchIcon('filePanel')
.verifyContracts(['Storage'])
}
}
Loading…
Cancel
Save