-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Create component from local codebase UI test
Signed-off-by: Lukas Grossmann <[email protected]>
- Loading branch information
Showing
2 changed files
with
161 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
*-----------------------------------------------------------------------------------------------*/ | ||
import { By, WebElement, WebView } from 'vscode-extension-tester'; | ||
import { By, Key, WebElement, WebView } from 'vscode-extension-tester'; | ||
import { WebViewForm } from './WebViewForm'; | ||
|
||
//TODO: Add support for create from git page and from local codebase page | ||
|
@@ -69,6 +69,15 @@ export class SetNameAndFolderPage extends WebViewForm { | |
}); | ||
} | ||
|
||
public async clearProjectFolderPath(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const pathField = await this.getProjectFolderPathField(webView); | ||
const controlKey = process.platform === 'darwin' ? Key.COMMAND : Key.CONTROL | ||
await pathField.sendKeys(`${controlKey} ${'a'}`); | ||
await pathField.sendKeys(Key.DELETE); | ||
}); | ||
} | ||
|
||
public async clickSelectFolder(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getSelectFolderButton(webView); | ||
|
@@ -96,14 +105,45 @@ export class SetNameAndFolderPage extends WebViewForm { | |
} | ||
} | ||
|
||
abstract class Page extends WebViewForm { | ||
public constructor() { | ||
super('Create Component') | ||
} | ||
|
||
public async clickNextButton(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getNextButton(webView); | ||
await button.click(); | ||
}) | ||
} | ||
|
||
/** | ||
* The button is shown only after filling all necessary fields and clicking the "Next" button | ||
*/ | ||
public async clickSelectDifferentDevfileButton(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getSelectDifferentDevfileButton(webView); | ||
await button.click() | ||
}); | ||
} | ||
|
||
private async getNextButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//button[contains(text(), "NEXT")]')); | ||
} | ||
|
||
private async getSelectDifferentDevfileButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//button[contains(text(), "SELECT A DIFFERENT DEVFILE")]')); | ||
} | ||
} | ||
|
||
/** | ||
* Class represents page that shows up after selecting to create a component from Git | ||
* @author Lukas Grossmann <[email protected]> | ||
*/ | ||
export class GitProjectPage extends WebViewForm { | ||
export class GitProjectPage extends Page { | ||
|
||
public constructor() { | ||
super('Create Component'); | ||
super(); | ||
} | ||
|
||
public async insertGitLink(link: string): Promise<void> { | ||
|
@@ -113,41 +153,60 @@ export class GitProjectPage extends WebViewForm { | |
}); | ||
} | ||
|
||
public async clickNextButton(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getNextButton(webView); | ||
await button.click(); | ||
}) | ||
} | ||
|
||
/** | ||
* The button is shown only after filling all necessary fields and clicking the "Next" button | ||
*/ | ||
public async clickContinueButton(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getContinueButton(webView); | ||
await button.click() | ||
}); | ||
} | ||
|
||
public async clickSelectDifferentDevfileButton(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getSelectDifferentDevfileButton(webView); | ||
await button.click() | ||
}); | ||
private async getContinueButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//button[contains(text(), "CONTINUE WITH THIS DEVFILE")]')); | ||
} | ||
|
||
private async getGitRepositoryLinkField(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//div[./label[contains(text(), "Link to Git Repository")]]//input')); | ||
} | ||
} | ||
|
||
private async getNextButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//button[contains(text(), "NEXT")]')); | ||
export class LocalCodeBasePage extends Page { | ||
public constructor() { | ||
super(); | ||
} | ||
|
||
private async getContinueButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//button[contains(text(), "CONTINUE WITH THIS DEVFILE")]')); | ||
public async insertComponentName(name: string): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const nameField = await this.getComponentNameField(webView); | ||
await nameField.sendKeys(name) | ||
}); | ||
} | ||
|
||
private async getSelectDifferentDevfileButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//button[contains(text(), "SELECT A DIFFERENT DEVFILE")]')); | ||
public async clickSelectFolderButton(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getSelectFolderButton(webView); | ||
await button.click() | ||
}); | ||
} | ||
|
||
public async clickCreateComponent(): Promise<void> { | ||
await this.enterWebView(async (webView) => { | ||
const button = await this.getCreateComponentButton(webView); | ||
await button.click() | ||
}); | ||
} | ||
|
||
private async getComponentNameField(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//div[./label[contains(text(), "Component Name")]]//input')); | ||
} | ||
|
||
private async getSelectFolderButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//button[contains(text(), "Select Folder")]')); | ||
} | ||
|
||
private async getCreateComponentButton(webView: WebView): Promise<WebElement> { | ||
return await webView.findWebElement(By.xpath('//span[contains(text(), "Create Component")]')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters