Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/webview/homescreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export class HomescreenViewProvider implements vscode.WebviewViewProvider {
<input
id="hs-search-input"
class="hs-search-input"
data-testid="hs-search-input-selector"
type="text"
placeholder="Search library…"
autocomplete="off"
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/specs/searchAssetFromSideBar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { CloudinarySDK } from '../src/sdks/cloudinarySDK.js';
import { activityBarUtils } from '../src/vscodeComponentsUtils/ActivityBarUtils.js';
import { SideBarViewActions, sideBarViewUtils } from '../src/vscodeComponentsUtils/SideBarViewUtils.js';
import { pathUtils } from '../src/utils/pathUtils.js';
import { inputBoxUtils } from '../src/vscodeComponentsUtils/InputBoxUtils.js';
import { browser } from '@wdio/globals';

describe('Search asset from side bar', () => {

Expand Down Expand Up @@ -38,7 +36,7 @@ describe('Search asset from side bar', () => {

await sideBarViewUtils.clickAction(SideBarViewActions.SEARCH);

await inputBoxUtils.fillAndConfirm(assetPublicID);
await sideBarViewUtils.homeScreenViewPage.fillSearchInput(assetPublicID);

await sideBarViewUtils.validateContentItemsExist(['Clear Search', assetPublicID]);
await sideBarViewUtils.validateContentItemsNumber(2);
Expand Down
12 changes: 11 additions & 1 deletion test/e2e/src/utils/wdioUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ class WdioUtils {
await element.waitForClickable();
return element.click(options);
}


/**
* Adds value to input an element.
*/
public async addValue(selector: string, value: string): Promise<void> {
await allureReporter.addStep(`Add value to an element '${selector}'`);
const element = $(selector);
await element.waitForExist();
await element.waitForEnabled();
return element.addValue(value);
}
}

export default new WdioUtils();
5 changes: 3 additions & 2 deletions test/e2e/src/vscodeComponentsUtils/WebViewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { browser } from "@wdio/globals"

class WebViewUtils {
/**
* Gets the WebView instance.
* Gets the WebView instance by exact title match.
*/
public async getWebView(title: string) {
const workbench = await browser.getWorkbench()
return browser.waitUntil(() => workbench.getWebviewByTitle(title), {
const exactMatch = new RegExp(`^${title}$`);
return browser.waitUntil(() => workbench.getWebviewByTitle(exactMatch), {
timeoutMsg: `WebView with title "${title}" not found`,
})
}
Expand Down
21 changes: 20 additions & 1 deletion test/e2e/src/webViewTabs/HomeScreenViewPage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { $, browser } from '@wdio/globals';
import wdioUtils from '../utils/wdioUtils.js';
import { WebViewTabBase } from './WebViewTabBase.js';
import allureReporter from '@wdio/allure-reporter';
import { Key } from 'webdriverio'

const HOME_SCREEN_BROWSE_LIBRARY_BUTTON_SELECTOR = '//*[@data-testid="hs-browse-library-button"]';
const SEARCH_INPUT_SELECTOR = '//*[@data-testid="hs-search-input-selector"]';

/**
* Page object for the Home Screen View.
Expand All @@ -26,5 +30,20 @@ export class HomeScreenViewPage extends WebViewTabBase {
await this.switchBack();
}
}


/**
* Fills the search input with a value and submits the search.
* Waits for the input to be displayed (handles view transitions where
* the homescreen webview needs time to load and reveal the search field).
*/
public async fillSearchInput(value: string) {
await allureReporter.addStep(`Fill search input with value '${value}'`);
await this.switchTo();
try {
await wdioUtils.addValue(SEARCH_INPUT_SELECTOR, value);
await browser.keys(Key.Enter);
} finally {
await this.switchBack();
}
}
}
Loading