-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for Extension Editor View (#1527)
Co-authored-by: Dominik Jelinek <[email protected]>
- Loading branch information
Showing
8 changed files
with
441 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<img width="1512" alt="ExtensionEditorDetailsSections" src="https://github.com/user-attachments/assets/b795e36c-41b2-4251-9d2a-58585377dfe0"> | ||
|
||
#### Lookup | ||
|
||
```typescript | ||
import { ExtensionEditorDetailsSection } from 'vscode-extension-tester'; | ||
... | ||
const extensionEditorDetails = new ExtensionEditorDetailsSection(); | ||
``` | ||
|
||
You can get values using following functions: | ||
|
||
```typescript | ||
await extensionEditorDetails.getCategories(); | ||
|
||
await extensionEditorDetails.getResources(); | ||
|
||
await extensionEditorDetails.getMoreInfo(); | ||
|
||
await extensionEditorDetails.getMoreInfoItem("Identifier"); | ||
|
||
await extensionEditorDetails.getReadme(); // currently not supported (Blocked by https://github.com/redhat-developer/vscode-extension-tester/issues/1492) | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<img width="1512" alt="ExtensionEditorView" src="https://github.com/user-attachments/assets/df5a4809-7fa6-4417-9024-a9a35b8257e4"> | ||
|
||
#### Lookup | ||
|
||
```typescript | ||
import { ExtensionEditorView } from 'vscode-extension-tester'; | ||
... | ||
const extensionEditor = new ExtensionEditorView(); | ||
``` | ||
|
||
#### Get values from opened extension | ||
|
||
You can get individual values using following functions: | ||
|
||
```typescript | ||
await extensionEditor.getName(); | ||
|
||
await extensionEditor.getVersion(); | ||
|
||
await extensionEditor.getPublisher(); | ||
|
||
await extensionEditor.getDescription(); | ||
|
||
await extensionEditor.getCount(); | ||
``` | ||
|
||
#### Manage tabs | ||
|
||
Tabs section can be managed by this editor as well. For work with 'Details' you can use ExtensionEditorDetailsSection. | ||
|
||
```typescript | ||
await extensionEditor.getTabs(); | ||
|
||
await extensionEditor.switchToTab("tabname"); | ||
|
||
await extensionEditor.getActiveTab(); | ||
``` |
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
92 changes: 92 additions & 0 deletions
92
packages/page-objects/src/components/editor/ExtensionEditorDetailsSection.ts
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License", destination); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { ExtensionEditorView, WebView } from '../..'; | ||
|
||
export class ExtensionEditorDetailsSection extends ExtensionEditorView { | ||
/** | ||
* Get all categories of extension. | ||
* @returns Promise resolving categories of extension. | ||
*/ | ||
async getCategories(): Promise<string[]> { | ||
const categories: string[] = []; | ||
|
||
const container = await this.findElement(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.categoriesContainer); | ||
const categoriesInContainer = await container.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.category); | ||
|
||
for (const cat of categoriesInContainer) { | ||
categories.push(await cat.getText()); | ||
} | ||
return categories; | ||
} | ||
|
||
/** | ||
* Get all resources of extension. | ||
* @returns Promise resolving resources of extension. | ||
*/ | ||
async getResources(): Promise<string[]> { | ||
const resources: string[] = []; | ||
|
||
const container = await this.findElement(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.resourcesContainer); | ||
const resourcesInContainer = await container.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.resource); | ||
|
||
for (const res of resourcesInContainer) { | ||
resources.push(await res.getText()); | ||
} | ||
|
||
return resources; | ||
} | ||
|
||
/** | ||
* Get content of More Info section. | ||
* @returns Promise resolving content of 'More Info' section. | ||
*/ | ||
async getMoreInfo(): Promise<{ [key: string]: string }> { | ||
const moreInfo: { [key: string]: string } = {}; | ||
|
||
const container = await this.findElement(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.moreInfoContainer); | ||
const moreInfoInContainer = await container.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.moreInfo); | ||
|
||
for (const entry of moreInfoInContainer) { | ||
const elmnts = await entry.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.moreInfoElements); | ||
const name = await (await elmnts.at(0))?.getText(); | ||
const value = await (await elmnts.at(1))?.getText(); | ||
if (name !== undefined && value !== undefined) { | ||
moreInfo[name] = value; | ||
} | ||
} | ||
|
||
return moreInfo; | ||
} | ||
|
||
/** | ||
* Get value of specific attribute from 'More Info' section. | ||
* @param key Name of attribute. | ||
* @returns Promise resolving value for specified attribute. | ||
*/ | ||
async getMoreInfoItem(key: string): Promise<string> { | ||
const moreInfo = await this.getMoreInfo(); | ||
return moreInfo[key]; | ||
} | ||
|
||
/** | ||
* Blocked by https://github.com/redhat-developer/vscode-extension-tester/issues/1492 | ||
*/ | ||
async getReadme(): Promise<WebView> { | ||
throw Error('Not implemented yet.'); | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
packages/page-objects/src/components/editor/ExtensionEditorView.ts
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License", destination); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Editor, EditorGroup, EditorView } from '../..'; | ||
|
||
export class ExtensionEditorView extends Editor { | ||
constructor(view: EditorView | EditorGroup = new EditorView()) { | ||
super(view, ExtensionEditorView.locators.ExtensionEditorView.constructor); | ||
} | ||
|
||
/** | ||
* Get name of extension. | ||
* @returns Promise resolving name of extension. | ||
*/ | ||
async getName(): Promise<string> { | ||
const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.name); | ||
return await name?.getText(); | ||
} | ||
|
||
/** | ||
* Get version of extension. | ||
* @returns Promise resolving version of extension. | ||
*/ | ||
async getVersion(): Promise<string> { | ||
const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.version); | ||
return await name?.getText(); | ||
} | ||
|
||
/** | ||
* Get publisher of extension. | ||
* @returns Promise resolving publisher of extension. | ||
*/ | ||
async getPublisher(): Promise<string> { | ||
const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.publisher); | ||
return await name?.getText(); | ||
} | ||
|
||
/** | ||
* Get description of extension. | ||
* @returns Promise description name of opened extension. | ||
*/ | ||
async getDescription(): Promise<string> { | ||
const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.description); | ||
return await name?.getText(); | ||
} | ||
|
||
/** | ||
* Get count of extension. | ||
* @returns Promise resolving count of opened extension. | ||
*/ | ||
async getCount(): Promise<string> { | ||
const count = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.count); | ||
return await count?.getText(); | ||
} | ||
|
||
/** | ||
* Get available tabs. | ||
* @returns Promise resolving tabs of opened extension. | ||
*/ | ||
async getTabs(): Promise<string[]> { | ||
const tabs: string[] = []; | ||
const navbar = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.navbar); | ||
const els = await navbar.findElements(ExtensionEditorView.locators.ExtensionEditorView.tab); | ||
for (const element of els) { | ||
tabs.push(await element.getText()); | ||
} | ||
return tabs; | ||
} | ||
|
||
/** | ||
* Switch to different tab. | ||
* @param tabName Name of required tab to be switched on. | ||
* @returns Promise resolving to true if tabs were switched successfully, false otherwise. | ||
*/ | ||
async switchToTab(tabName: string): Promise<boolean> { | ||
const navbar = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.navbar); | ||
const requiredTab = await navbar.findElement(ExtensionEditorView.locators.ExtensionEditorView.specificTab(tabName)); | ||
await requiredTab.click(); | ||
return (await this.getActiveTab()).toLowerCase() === tabName.toLowerCase(); | ||
} | ||
|
||
/** | ||
* Get name of opened tab. | ||
* @returns Promise resolving name of opened tab. | ||
*/ | ||
async getActiveTab(): Promise<string> { | ||
const navbar = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.navbar); | ||
const features = await navbar.findElement(ExtensionEditorView.locators.ExtensionEditorView.activeTab); | ||
return await features.getText(); | ||
} | ||
} |
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
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
Oops, something went wrong.