fix e2e and modal behavior

pull/1879/head
yann300 3 years ago
parent e95397cf2c
commit 2b94f3a2f7
  1. 18
      apps/remix-ide-e2e/src/tests/gist.test.ts
  2. 41
      libs/remix-core-plugin/src/lib/gist-handler.ts

@ -76,11 +76,11 @@ module.exports = {
.waitForElementVisible('button[data-id="landingPageImportFromGistButton"]') .waitForElementVisible('button[data-id="landingPageImportFromGistButton"]')
.pause(1000) .pause(1000)
.scrollAndClick('button[data-id="landingPageImportFromGistButton"]') .scrollAndClick('button[data-id="landingPageImportFromGistButton"]')
.waitForElementVisible('*[data-id="modalDialogModalTitle"]') .waitForElementVisible('*[data-id="gisthandlerModalDialogModalTitle-react"]')
.assert.containsText('*[data-id="modalDialogModalTitle"]', 'Load a Gist') .assert.containsText('*[data-id="gisthandlerModalDialogModalTitle-react"]', 'Load a Gist')
.waitForElementVisible('*[data-id="modalDialogModalBody"]') .waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"]')
.assert.containsText('*[data-id="modalDialogModalBody"]', '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="modalDialogCustomPromptText"]') .waitForElementVisible('*[data-id="modalDialogCustomPromp"]')
.modalFooterCancelClick() .modalFooterCancelClick()
}, },
@ -89,11 +89,11 @@ module.exports = {
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('filePanel') .clickLaunchIcon('filePanel')
.scrollAndClick('*[data-id="landingPageImportFromGistButton"]') .scrollAndClick('*[data-id="landingPageImportFromGistButton"]')
.waitForElementVisible('*[data-id="modalDialogCustomPromptText"]') .waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"] input[data-id="modalDialogCustomPromp"]')
.setValue('*[data-id="modalDialogCustomPromptText"]', testData.invalidGistId) .setValue('*[data-id="gisthandlerModalDialogModalBody-react"] input[data-id="modalDialogCustomPromp"]', testData.invalidGistId)
.modalFooterOKClick() .modalFooterOKClick()
.waitForElementVisible('*[data-id="modalDialogModalBody"]') .waitForElementVisible('*[data-id="gisthandlerModalDialogModalBody-react"]')
.assert.containsText('*[data-id="modalDialogModalBody"]', 'Not Found') .assert.containsText('*[data-id="gisthandlerModalDialogModalBody-react"]', 'Not Found')
.modalFooterOKClick() .modalFooterOKClick()
}, },

@ -24,20 +24,29 @@ export class GistHandler extends Plugin {
var loadingFromGist = false var loadingFromGist = false
if (!gistId) { if (!gistId) {
loadingFromGist = true loadingFromGist = true
const value = await (() => { let value
return new Promise((resolve, reject) => { try {
const modalContent = { value = await (() => {
id: 'gisthandler', return new Promise((resolve, reject) => {
title: 'Load a Gist', const modalContent = {
message: 'Enter the ID of the Gist or URL you would like to load.', id: 'gisthandler',
modalType: 'prompt', title: 'Load a Gist',
okFn: (value) => { message: 'Enter the ID of the Gist or URL you would like to load.',
resolve(value) modalType: 'prompt',
okFn: (value) => {
setTimeout(() => resolve(value), 0)
},
cancelFn: () => {
setTimeout(() => reject(), 0)
}
} }
} this.call('modal', 'modal', modalContent)
this.call('modal', 'modal', modalContent) })
}) })()
})() } catch (e) {
// the modal has been canceled
return
}
if (value !== '') { if (value !== '') {
gistId = getGistId(value) gistId = getGistId(value)
@ -50,16 +59,16 @@ export class GistHandler extends Plugin {
message: 'Error while loading gist. Please provide a valid Gist ID or URL.', message: 'Error while loading gist. Please provide a valid Gist ID or URL.',
modalType: 'alert' modalType: 'alert'
} }
await this.call('modal', 'modal', modalContent) this.call('modal', 'modal', modalContent)
} }
} else { } else {
const modalContent = { const modalContent = {
id: 'gisthandler', id: 'gisthandlerEmpty',
title: 'Gist load error', title: 'Gist load error',
message: 'Error while loading gist. Id cannot be empty.', message: 'Error while loading gist. Id cannot be empty.',
modalType: 'alert' modalType: 'alert'
} }
await this.call('modal', 'modal', modalContent) this.call('modal', 'modal', modalContent)
} }
return loadingFromGist return loadingFromGist
} else { } else {

Loading…
Cancel
Save