@eclipse-che/che-e2e
Advanced tools
Comparing version 7.41.0-dev-0a9cb74 to 7.41.0-dev-6e259a3
@@ -23,3 +23,2 @@ "use strict"; | ||
}; | ||
var Terminal_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -34,3 +33,3 @@ exports.Terminal = void 0; | ||
const TestConstants_1 = require("../../TestConstants"); | ||
let Terminal = Terminal_1 = class Terminal { | ||
let Terminal = class Terminal { | ||
constructor(driverHelper) { | ||
@@ -76,4 +75,4 @@ this.driverHelper = driverHelper; | ||
Logger_1.Logger.debug(`Terminal.type "${terminalTabTitle}"`); | ||
const terminalIndex = await this.getTerminalIndex(terminalTabTitle); | ||
const terminalInteractionContainer = this.getTerminalEditorInteractionEditorLocator(terminalIndex); | ||
const terminalID = await this.getTerminalID(terminalTabTitle); | ||
const terminalInteractionContainer = this.getTerminalEditorInteractionEditorLocator(terminalID); | ||
await this.driverHelper.typeToInvisible(terminalInteractionContainer, text); | ||
@@ -88,5 +87,6 @@ } | ||
Logger_1.Logger.debug(`Terminal.getText tab: ${terminalTab}`); | ||
const terminalIndex = await this.getTerminalIndex(terminalTab); | ||
const terminalID = await this.getTerminalID(terminalTab); | ||
const terminalRowsLocator = this.getTerminalEditorTerminalRowsLocator(terminalID); | ||
await this.selectTerminalTab(terminalTab, timeout); | ||
return await this.driverHelper.waitAndGetText(selenium_webdriver_1.By.xpath(Terminal_1.TERMINAL_ROWS_XPATH_LOCATOR_PREFFIX + `[${terminalIndex}]`), timeout); | ||
return await this.driverHelper.waitAndGetText(terminalRowsLocator, timeout); | ||
} | ||
@@ -101,6 +101,7 @@ async getTextFromProblemsTab(timeout = TimeoutConstants_1.TimeoutConstants.TS_SELENIUM_TERMINAL_DEFAULT_TIMEOUT) { | ||
const terminalTabLocatorWithPreffix = `//li[contains(@title, '${terminalTab}')]`; | ||
const terminalIndex = await this.getTerminalIndex(terminalTab); | ||
const terminalID = await this.getTerminalID(terminalTab); | ||
const terminalRowsLocator = this.getTerminalEditorTerminalRowsLocator(terminalID); | ||
await this.driverHelper.waitAndClick(selenium_webdriver_1.By.xpath(terminalTabLocatorWithPreffix), timeout); | ||
await this.driverHelper.waitUntilTrue(async () => { | ||
const terminalText = await this.driverHelper.waitAndGetText(selenium_webdriver_1.By.xpath(Terminal_1.TERMINAL_ROWS_XPATH_LOCATOR_PREFFIX + `[${terminalIndex}]`), timeout); | ||
const terminalText = await this.driverHelper.waitAndGetText(terminalRowsLocator, timeout); | ||
return terminalText.includes(expectedText); | ||
@@ -164,42 +165,21 @@ }, timeout); | ||
} | ||
async getTerminalIndex(terminalTitle) { | ||
for (let i = 0; i < 10; i++) { | ||
try { | ||
return await this.searchTerminalIndex(terminalTitle); | ||
} | ||
catch (err) { | ||
if (!(err instanceof selenium_webdriver_1.error.NoSuchElementError)) { | ||
throw err; | ||
} | ||
if ((err instanceof selenium_webdriver_1.error.NoSuchElementError) && (i === 9)) { | ||
throw err; | ||
} | ||
await this.driverHelper.wait(2000); | ||
} | ||
async getTerminalID(terminalTitle) { | ||
const terminalTabXpathLocator = `//div[@id='theia-bottom-content-panel']//li[contains(@title, '${terminalTitle}')]`; | ||
const terminalTabs = await this.driverHelper.waitAllPresence(selenium_webdriver_1.By.xpath(terminalTabXpathLocator)); | ||
if (terminalTabs.length > 1) { | ||
throw new selenium_webdriver_1.error.InvalidSelectorError(`Terminal.getTerminalID Selector is too generic, found more than one terminal with title:${terminalTitle}`); | ||
} | ||
if (terminalTabs.length === 1) { | ||
return await (await terminalTabs[0].getAttribute('id')).replace('shell-tab-', ''); | ||
} | ||
throw new selenium_webdriver_1.error.NoSuchElementError(`The terminal with title '${terminalTitle}' has not been found.`); | ||
} | ||
async searchTerminalIndex(terminalTitle) { | ||
const terminalTabTitleXpathLocator = `//div[@id='theia-bottom-content-panel']` + | ||
`//li[contains(@id, 'shell-tab-terminal') or contains(@id, 'shell-tab-plugin')]` + | ||
`//div[@class='p-TabBar-tabLabel']`; | ||
const terminalTabs = await this.driverHelper.waitAllPresence(selenium_webdriver_1.By.xpath(terminalTabTitleXpathLocator)); | ||
let terminalTitles = []; | ||
for (let i = 1; i <= terminalTabs.length; i++) { | ||
const terminalTabLocator = selenium_webdriver_1.By.xpath(`(${terminalTabTitleXpathLocator})[${i}]`); | ||
const currentTerminalTitle = await this.driverHelper.waitAndGetText(terminalTabLocator); | ||
if (currentTerminalTitle.search(terminalTitle) > -1) { | ||
return i; | ||
} | ||
terminalTitles.push(currentTerminalTitle); | ||
} | ||
throw new selenium_webdriver_1.error.NoSuchElementError(`The terminal with title '${terminalTitle}' has not been found.\n` + | ||
` > List of the tabs:\n > ${terminalTitles}`); | ||
getTerminalEditorInteractionEditorLocator(terminalID) { | ||
return selenium_webdriver_1.By.xpath(`//div[@id='${terminalID}']//textarea[@aria-label='Terminal input']`); | ||
} | ||
getTerminalEditorInteractionEditorLocator(terminalIndex) { | ||
return selenium_webdriver_1.By.xpath(`(//textarea[@aria-label='Terminal input'])[${terminalIndex}]`); | ||
getTerminalEditorTerminalRowsLocator(terminalID) { | ||
return selenium_webdriver_1.By.xpath(`//div[@id='${terminalID}']//div[@class='xterm-rows xterm-focus']`); | ||
} | ||
}; | ||
Terminal.TERMINAL_ROWS_XPATH_LOCATOR_PREFFIX = '(//div[contains(@class, \'terminal-container\')]//div[contains(@class, \'terminal\')]//div[contains(@class, \'xterm-rows\')])'; | ||
Terminal = Terminal_1 = __decorate([ | ||
Terminal = __decorate([ | ||
inversify_1.injectable(), | ||
@@ -206,0 +186,0 @@ __param(0, inversify_1.inject(inversify_types_1.CLASSES.DriverHelper)), |
@@ -144,3 +144,3 @@ "use strict"; | ||
test('Run application', async () => { | ||
const taskName = 'run'; | ||
const taskName = 'run-with-hsqldb'; | ||
await topMenu.runTask(`${taskName}, ${globalTaskScope}`); | ||
@@ -157,4 +157,4 @@ await ide.waitNotification('Process 8080-tcp is now listening on port 8080. Open it ?', 120000); | ||
test('Close the terminal running tasks', async () => { | ||
await terminal.rejectTerminalProcess('run'); | ||
await terminal.closeTerminalTab('run'); | ||
await terminal.rejectTerminalProcess('run-with-hsqldb'); | ||
await terminal.closeTerminalTab('run-with-hsqldb'); | ||
await warningDialog.waitAndCloseIfAppear(); | ||
@@ -161,0 +161,0 @@ await terminal.closeTerminalTab('build'); |
@@ -87,2 +87,22 @@ "use strict"; | ||
} | ||
async deletePublicSshKeyByName(authToken, keyName) { | ||
const gitHubApiSshURL = GitHubUtil_1.GITHUB_API_ENTRIPOINT_URL + 'user/keys'; | ||
const authHeader = { headers: { 'Authorization': 'token ' + authToken, 'Content-Type': 'application/json' } }; | ||
try { | ||
const response = await axios_1.default.get(gitHubApiSshURL, authHeader); | ||
const stringified = JSON.stringify(response.data); | ||
const arrayOfPublicKeys = JSON.parse(stringified); | ||
for (let entry of arrayOfPublicKeys) { | ||
if (entry.title === keyName) { | ||
this.removePublicSshKey(authToken, entry.id); | ||
break; | ||
} | ||
} | ||
} | ||
catch (error) { | ||
console.error('Cannot delete the ' + keyName + ' public key from the GitHub account'); | ||
console.error(error); | ||
throw error; | ||
} | ||
} | ||
async removeAllPublicSshKeys(authToken) { | ||
@@ -89,0 +109,0 @@ try { |
{ | ||
"name": "@eclipse-che/che-e2e", | ||
"version": "7.41.0-dev-0a9cb74", | ||
"version": "7.41.0-dev-6e259a3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -21,3 +21,2 @@ /********************************************************************* | ||
export class Terminal { | ||
private static readonly TERMINAL_ROWS_XPATH_LOCATOR_PREFFIX = '(//div[contains(@class, \'terminal-container\')]//div[contains(@class, \'terminal\')]//div[contains(@class, \'xterm-rows\')])'; | ||
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } | ||
@@ -83,4 +82,4 @@ | ||
const terminalIndex: number = await this.getTerminalIndex(terminalTabTitle); | ||
const terminalInteractionContainer: By = this.getTerminalEditorInteractionEditorLocator(terminalIndex); | ||
const terminalID: string = await this.getTerminalID(terminalTabTitle); | ||
const terminalInteractionContainer: By = this.getTerminalEditorInteractionEditorLocator(terminalID); | ||
@@ -100,5 +99,6 @@ await this.driverHelper.typeToInvisible(terminalInteractionContainer, text); | ||
const terminalIndex: number = await this.getTerminalIndex(terminalTab); | ||
const terminalID: string = await this.getTerminalID(terminalTab); | ||
const terminalRowsLocator: By = this.getTerminalEditorTerminalRowsLocator(terminalID); | ||
await this.selectTerminalTab(terminalTab, timeout); | ||
return await this.driverHelper.waitAndGetText(By.xpath(Terminal.TERMINAL_ROWS_XPATH_LOCATOR_PREFFIX + `[${terminalIndex}]`), timeout); | ||
return await this.driverHelper.waitAndGetText(terminalRowsLocator, timeout); | ||
} | ||
@@ -118,9 +118,9 @@ | ||
const terminalTabLocatorWithPreffix: string = `//li[contains(@title, '${terminalTab}')]`; | ||
const terminalIndex: number = await this.getTerminalIndex(terminalTab); | ||
const terminalID: string = await this.getTerminalID(terminalTab); | ||
const terminalRowsLocator: By = this.getTerminalEditorTerminalRowsLocator(terminalID); | ||
await this.driverHelper.waitAndClick(By.xpath(terminalTabLocatorWithPreffix), timeout); | ||
await this.driverHelper.waitUntilTrue(async () => { | ||
const terminalText: string = await this.driverHelper.waitAndGetText(By.xpath(Terminal.TERMINAL_ROWS_XPATH_LOCATOR_PREFFIX + `[${terminalIndex}]`), timeout); | ||
const terminalText: string = await this.driverHelper.waitAndGetText(terminalRowsLocator, timeout); | ||
return terminalText.includes(expectedText); | ||
}, timeout); | ||
@@ -200,18 +200,13 @@ } | ||
private async getTerminalIndex(terminalTitle: string): Promise<number> { | ||
for (let i: number = 0; i < 10; i++) { | ||
try { | ||
return await this.searchTerminalIndex(terminalTitle); | ||
} catch (err) { | ||
if (!(err instanceof error.NoSuchElementError)) { | ||
throw err; | ||
} | ||
private async getTerminalID(terminalTitle: string): Promise<string> { | ||
const terminalTabXpathLocator: string = `//div[@id='theia-bottom-content-panel']//li[contains(@title, '${terminalTitle}')]`; | ||
if ((err instanceof error.NoSuchElementError) && (i === 9)) { | ||
throw err; | ||
} | ||
const terminalTabs: WebElement[] = await this.driverHelper.waitAllPresence(By.xpath(terminalTabXpathLocator)); | ||
await this.driverHelper.wait(2000); | ||
} | ||
if (terminalTabs.length > 1) { | ||
throw new error.InvalidSelectorError(`Terminal.getTerminalID Selector is too generic, found more than one terminal with title:${terminalTitle}`); | ||
} | ||
if (terminalTabs.length === 1) { | ||
return await (await terminalTabs[0].getAttribute('id')).replace('shell-tab-', ''); | ||
} | ||
@@ -221,31 +216,10 @@ throw new error.NoSuchElementError(`The terminal with title '${terminalTitle}' has not been found.`); | ||
private async searchTerminalIndex(terminalTitle: string): Promise<number> { | ||
const terminalTabTitleXpathLocator: string = `//div[@id='theia-bottom-content-panel']` + | ||
`//li[contains(@id, 'shell-tab-terminal') or contains(@id, 'shell-tab-plugin')]` + | ||
`//div[@class='p-TabBar-tabLabel']`; | ||
const terminalTabs: WebElement[] = await this.driverHelper.waitAllPresence(By.xpath(terminalTabTitleXpathLocator)); | ||
let terminalTitles: string[] = []; | ||
for (let i: number = 1; i <= terminalTabs.length; i++) { | ||
const terminalTabLocator: By = By.xpath(`(${terminalTabTitleXpathLocator})[${i}]`); | ||
const currentTerminalTitle: string = await this.driverHelper.waitAndGetText(terminalTabLocator); | ||
if (currentTerminalTitle.search(terminalTitle) > -1) { | ||
return i; | ||
} | ||
terminalTitles.push(currentTerminalTitle); | ||
} | ||
throw new error.NoSuchElementError(`The terminal with title '${terminalTitle}' has not been found.\n` + | ||
` > List of the tabs:\n > ${terminalTitles}`); | ||
private getTerminalEditorInteractionEditorLocator(terminalID: string): By { | ||
return By.xpath(`//div[@id='${terminalID}']//textarea[@aria-label='Terminal input']`); | ||
} | ||
private getTerminalEditorInteractionEditorLocator(terminalIndex: number): By { | ||
return By.xpath(`(//textarea[@aria-label='Terminal input'])[${terminalIndex}]`); | ||
private getTerminalEditorTerminalRowsLocator(terminalID: string): By { | ||
return By.xpath(`//div[@id='${terminalID}']//div[@class='xterm-rows xterm-focus']`); | ||
} | ||
} |
@@ -144,3 +144,3 @@ // /********************************************************************* | ||
test('Run application', async () => { | ||
const taskName: string = 'run'; | ||
const taskName: string = 'run-with-hsqldb'; | ||
await topMenu.runTask(`${taskName}, ${globalTaskScope}`); | ||
@@ -158,4 +158,4 @@ await ide.waitNotification('Process 8080-tcp is now listening on port 8080. Open it ?', 120_000); | ||
test('Close the terminal running tasks', async () => { | ||
await terminal.rejectTerminalProcess('run'); | ||
await terminal.closeTerminalTab('run'); | ||
await terminal.rejectTerminalProcess('run-with-hsqldb'); | ||
await terminal.closeTerminalTab('run-with-hsqldb'); | ||
await warningDialog.waitAndCloseIfAppear(); | ||
@@ -162,0 +162,0 @@ await terminal.closeTerminalTab('build'); |
@@ -67,3 +67,3 @@ /********************************************************************* | ||
await projectTree.expandPathAndOpenFile(pathToFile, docFileName); | ||
await editor.waitInfoInLine(16,docFileName); | ||
await editor.waitInfoInLine(16, docFileName); | ||
}); | ||
@@ -70,0 +70,0 @@ |
@@ -76,2 +76,21 @@ import { injectable } from 'inversify'; | ||
async deletePublicSshKeyByName(authToken: string, keyName: string) { | ||
const gitHubApiSshURL: string = GitHubUtil.GITHUB_API_ENTRIPOINT_URL + 'user/keys'; | ||
const authHeader = { headers: { 'Authorization': 'token ' + authToken, 'Content-Type': 'application/json' } }; | ||
try { | ||
const response = await axios.get(gitHubApiSshURL, authHeader); | ||
const stringified = JSON.stringify(response.data); | ||
const arrayOfPublicKeys = JSON.parse(stringified); | ||
for (let entry of arrayOfPublicKeys) { | ||
if (entry.title === keyName) { | ||
this.removePublicSshKey(authToken, entry.id); | ||
break; | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Cannot delete the ' + keyName + ' public key from the GitHub account'); | ||
console.error(error); | ||
throw error; | ||
} | ||
} | ||
@@ -78,0 +97,0 @@ async removeAllPublicSshKeys(authToken: string) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20073
0
1492542