pull/1879/head
yann300 3 years ago
parent e5d59482f5
commit 5fb724ccef
  1. 15
      apps/remix-ide-e2e/src/commands/modalFooterCancelClick.ts
  2. 11
      apps/remix-ide-e2e/src/commands/modalFooterOKClick.ts
  3. 6
      apps/remix-ide-e2e/src/tests/gist.test.ts
  4. 4
      apps/remix-ide-e2e/src/types/index.d.ts
  5. 2
      libs/remix-core-plugin/src/lib/gist-handler.ts
  6. 10
      libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx

@ -1,14 +1,15 @@
import { NightwatchBrowser } from 'nightwatch' import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events' import EventEmitter from 'events'
class ModalFooterOKClick extends EventEmitter { class ModalFooterCancelClick extends EventEmitter {
command (this: NightwatchBrowser): NightwatchBrowser { command (this: NightwatchBrowser, id?: string): NightwatchBrowser {
this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => { const clientId = id ? `*[data-id="${id}-modal-footer-cancel-react"]` : '#modal-footer-cancel'
this.api.execute(function () { this.api.waitForElementVisible(clientId).perform((client, done) => {
const elem = document.querySelector('#modal-footer-cancel') as HTMLElement this.api.execute(function (clientId) {
const elem = document.querySelector(clientId) as HTMLElement
elem.click() elem.click()
}, [], () => { }, [clientId], () => {
done() done()
this.emit('complete') this.emit('complete')
}) })
@ -17,4 +18,4 @@ class ModalFooterOKClick extends EventEmitter {
} }
} }
module.exports = ModalFooterOKClick module.exports = ModalFooterCancelClick

@ -2,13 +2,14 @@ import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events' import EventEmitter from 'events'
class ModalFooterOKClick extends EventEmitter { class ModalFooterOKClick extends EventEmitter {
command (this: NightwatchBrowser): NightwatchBrowser { command (this: NightwatchBrowser, id?: string): NightwatchBrowser {
this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => { const clientId = id ? `*[data-id="${id}-modal-footer-ok-react"]` : '#modal-footer-ok'
this.api.execute(function () { this.api.waitForElementVisible(clientId).perform((client, done) => {
const elem = document.querySelector('#modal-footer-ok') as HTMLElement this.api.execute(function (clientId) {
const elem = document.querySelector(clientId) as HTMLElement
elem.click() elem.click()
}, [], () => { }, [clientId], () => {
done() done()
this.emit('complete') this.emit('complete')
}) })

@ -81,7 +81,7 @@ module.exports = {
.waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"]') .waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"]')
.assert.containsText('*[data-id="gisthandlerModalDialogModalBody-react"]', 'Enter the ID of the Gist or URL you would like to load.') .assert.containsText('*[data-id="gisthandlerModalDialogModalBody-react"]', 'Enter the ID of the Gist or URL you would like to load.')
.waitForElementVisible('*[data-id="modalDialogCustomPromp"]') .waitForElementVisible('*[data-id="modalDialogCustomPromp"]')
.modalFooterCancelClick() .modalFooterCancelClick('gisthandler')
}, },
'Display Error Message For Invalid Gist ID': function (browser: NightwatchBrowser) { 'Display Error Message For Invalid Gist ID': function (browser: NightwatchBrowser) {
@ -91,10 +91,10 @@ module.exports = {
.scrollAndClick('*[data-id="landingPageImportFromGistButton"]') .scrollAndClick('*[data-id="landingPageImportFromGistButton"]')
.waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"] input[data-id="modalDialogCustomPromp"]') .waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"] input[data-id="modalDialogCustomPromp"]')
.setValue('*[data-id="gisthandlerModalDialogModalBody-react"] input[data-id="modalDialogCustomPromp"]', testData.invalidGistId) .setValue('*[data-id="gisthandlerModalDialogModalBody-react"] input[data-id="modalDialogCustomPromp"]', testData.invalidGistId)
.modalFooterOKClick() .modalFooterOKClick('gisthandler')
.waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"]') .waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"]')
.assert.containsText('*[data-id="gisthandlerModalDialogModalBody-react"]', 'Not Found') .assert.containsText('*[data-id="gisthandlerModalDialogModalBody-react"]', 'Not Found')
.modalFooterOKClick() .modalFooterOKClick('gisthandler')
}, },
'Display Error Message For Missing Gist Token When Publishing': function (browser: NightwatchBrowser) { 'Display Error Message For Missing Gist Token When Publishing': function (browser: NightwatchBrowser) {

@ -18,7 +18,7 @@ declare module 'nightwatch' {
goToVMTraceStep(step: number, incr?: number): NightwatchBrowser, goToVMTraceStep(step: number, incr?: number): NightwatchBrowser,
checkVariableDebug(id: string, debugValue: NightwatchCheckVariableDebugValue): NightwatchBrowser, checkVariableDebug(id: string, debugValue: NightwatchCheckVariableDebugValue): NightwatchBrowser,
addAtAddressInstance(address: string, isValidFormat: boolean, isValidChecksum: boolean): NightwatchBrowser, addAtAddressInstance(address: string, isValidFormat: boolean, isValidChecksum: boolean): NightwatchBrowser,
modalFooterOKClick(): NightwatchBrowser, modalFooterOKClick(id?: string): NightwatchBrowser,
clickInstance(index: number): NightwatchBrowser, clickInstance(index: number): NightwatchBrowser,
journalLastChildIncludes(val: string): NightwatchBrowser, journalLastChildIncludes(val: string): NightwatchBrowser,
executeScript(script: string): NightwatchBrowser, executeScript(script: string): NightwatchBrowser,
@ -32,7 +32,7 @@ declare module 'nightwatch' {
scrollToLine(line: number): NightwatchBrowser, scrollToLine(line: number): NightwatchBrowser,
waitForElementContainsText(id: string, value: string, timeout?: number): NightwatchBrowser, waitForElementContainsText(id: string, value: string, timeout?: number): NightwatchBrowser,
getModalBody(callback: (value: string, cb: VoidFunction) => void): NightwatchBrowser, getModalBody(callback: (value: string, cb: VoidFunction) => void): NightwatchBrowser,
modalFooterCancelClick(): NightwatchBrowser, modalFooterCancelClick(id?: string): NightwatchBrowser,
selectContract(contractName: string): NightwatchBrowser, selectContract(contractName: string): NightwatchBrowser,
createContract(inputParams: string): NightwatchBrowser, createContract(inputParams: string): NightwatchBrowser,
getAddressAtPosition(index: number, cb: (pos: string) => void): NightwatchBrowser, getAddressAtPosition(index: number, cb: (pos: string) => void): NightwatchBrowser,

@ -37,7 +37,7 @@ export class GistHandler extends Plugin {
setTimeout(() => resolve(value), 0) setTimeout(() => resolve(value), 0)
}, },
cancelFn: () => { cancelFn: () => {
setTimeout(() => reject("Canceled"), 0) setTimeout(() => reject(new Error('Canceled')), 0)
} }
} }
this.call('modal', 'modal', modalContent) this.call('modal', 'modal', modalContent)

@ -92,11 +92,11 @@ export const ModalDialog = (props: ModalDialogProps) => {
} }
</div> </div>
<div className="modal-body text-break remixModalBody" data-id={`${props.id}ModalDialogModalBody-react`}> <div className="modal-body text-break remixModalBody" data-id={`${props.id}ModalDialogModalBody-react`}>
{ props.children ? props.children : props.message } {props.children ? props.children : props.message}
</div> </div>
<div className="modal-footer" data-id={`${props.id}ModalDialogModalFooter-react`}> <div className="modal-footer" data-id={`${props.id}ModalDialogModalFooter-react`}>
{/* todo add autofocus ^^ */} {/* todo add autofocus ^^ */}
{ <span {<span
data-id={`${props.id}-modal-footer-ok-react`} data-id={`${props.id}-modal-footer-ok-react`}
className={'modal-ok btn btn-sm ' + (state.toggleBtn ? 'btn-dark' : 'btn-light')} className={'modal-ok btn btn-sm ' + (state.toggleBtn ? 'btn-dark' : 'btn-light')}
onClick={() => { onClick={() => {
@ -104,10 +104,10 @@ export const ModalDialog = (props: ModalDialogProps) => {
handleHide() handleHide()
}} }}
> >
{ props.okLabel ? props.okLabel : 'OK' } {props.okLabel ? props.okLabel : 'OK'}
</span> </span>
} }
{ <span {<span
data-id={`${props.id}-modal-footer-cancel-react`} data-id={`${props.id}-modal-footer-cancel-react`}
className={'modal-cancel btn btn-sm ' + (state.toggleBtn ? 'btn-light' : 'btn-dark')} className={'modal-cancel btn btn-sm ' + (state.toggleBtn ? 'btn-light' : 'btn-dark')}
data-dismiss="modal" data-dismiss="modal"
@ -116,7 +116,7 @@ export const ModalDialog = (props: ModalDialogProps) => {
handleHide() handleHide()
}} }}
> >
{ props.cancelLabel ? props.cancelLabel : 'Cancel' } {props.cancelLabel ? props.cancelLabel : 'Cancel'}
</span> </span>
} }
</div> </div>

Loading…
Cancel
Save