diff --git a/test/ui/suite/createComponent.ts b/test/ui/suite/createComponent.ts index bf0b36bde..bdb379b2b 100644 --- a/test/ui/suite/createComponent.ts +++ b/test/ui/suite/createComponent.ts @@ -32,6 +32,8 @@ import { RegistryWebViewEditor, } from '../common/ui/webview/registryWebViewEditor'; +/* eslint-disable no-console */ + //TODO: Add more checks for different elements export function testCreateComponent(path: string) { describe('Create Component Wizard', function () { @@ -46,6 +48,12 @@ export function testCreateComponent(path: string) { await new EditorView().closeAllEditors(); fs.ensureDirSync(path, 0o6777); view = await (await new ActivityBar().getViewControl(VIEWS.openshift)).openView(); + try { + const notifications = await new Workbench().getNotifications(); + for (const n of notifications) { + try { await n.dismiss(); } catch { /* Ignore */ } + } + } catch { /* Ignore */ } for (const item of [ VIEWS.appExplorer, VIEWS.compRegistries, @@ -90,42 +98,78 @@ export function testCreateComponent(path: string) { it('Create component from local folder', async function test() { this.timeout(25_000); + + // Remove the configuration for the component created in the previous testcase, + // so the component folder stays untouched + // console.log('Create component from local folder: Search for component to delete: ', componentName); const component = await section.findItem(componentName); + // console.log('Create component from local folder: ', componentName, ' found: ', !!component); + + // console.log('Create component from local folder: deleting configuration for: ', componentName); + // console.log('Create component from local folder: Openning Context Menu...'); const contextMenu = await component.openContextMenu(); + // console.log('Create component from local folder: context menu is opened: ', !!contextMenu); + // console.log('Create component from local folder: Selecting "', MENUS.deleteConfiguration, '...'); + await contextMenu.select(MENUS.deleteConfiguration); + await new Promise((res) => { + setTimeout(res, 500); + }); + // console.log('Create component from local folder: Waiting for "Delete Configuration" notification...'); const notification = await notificationExists( NOTIFICATIONS.deleteConfig(pth.join(path, componentName)), VSBrowser.instance.driver, ); + + // console.log('Create component from local folder: Delete Configuration notification found: ', !!notification); + // console.log('Create component from local folder: Confirming "', MENUS.deleteConfiguration, '...'); + await notification.takeAction(INPUTS.deleteConfiguration); + // console.log('Create component from local folder: Delete Configuration notification "clicked"'); + const notificationCenter = await new Workbench().openNotificationsCenter(); const notifications = await notificationCenter.getNotifications(NotificationType.Any); if (notifications.length > 0) { await notificationCenter.close(); + // console.log('Create component from local folder: Notification center closed'); + } else { + // console.log('Create component from local folder: Notification center NOT closed (due to absent notifications)'); } + // console.log('Create component from local folder: Refreshing the view...'); await refreshView(); + // console.log('Create component from local folder: Loading component buton...'); await loadCreateComponentButton(); + // console.log('Create component from local folder: Clicking "Create Component"...'); await clickCreateComponent(); + // console.log('Create component from local folder: Initializing "Create Component" editor...'); const createCompView = await initializeEditor(); + // console.log('Create component from local folder: Clicking "Create Component from local folder"...'); await createCompView.createComponentFromLocalCodebase(); + // console.log('Create component from local folder: Initializing "...from Local code Base" page...'); const localCodeBasePage = new LocalCodeBasePage(); await localCodeBasePage.initializeEditor(); + // console.log('Create component from local folder: Setting up component name...'); await localCodeBasePage.insertComponentName(componentName); + // console.log('Create component from local folder: Clicking "Select Folder" button...'); await localCodeBasePage.clickSelectFolderButton(); + // console.log('Create component from local folder: Setting up the component path...'); const input = await InputBox.create(); await input.setText(pth.join(path, componentName)); + // console.log('Create component from local folder: Setting up the component path - confirming...'); await input.confirm(); + // console.log('Create component from local folder: Clicking "Next" button...'); await localCodeBasePage.clickNextButton(); await new Promise((res) => { setTimeout(res, 500); }); + // console.log('Create component from local folder: Clicking "Create Component" button...'); await localCodeBasePage.clickCreateComponent(); await new Promise((res) => { setTimeout(res, 6_000); @@ -156,6 +200,9 @@ export function testCreateComponent(path: string) { //Initialize stack window and click Use Devfile const devFileWindow = new RegistryWebViewDevfileWindow(createCompView.editorName); await devFileWindow.initializeEditor(); + await new Promise((res) => { + setTimeout(res, 1_500); + }); await devFileWindow.useDevfile(); //Initialize next page, fill out path and select create component @@ -171,26 +218,55 @@ export function testCreateComponent(path: string) { //Delete the component using file system afterEach(async function context() { this.timeout(30_000); + // console.log('Create component afterEach: componentName: ', componentName, ', delete: ', dlt); if (componentName && dlt) { + // console.log('Create component afterEach: componentName: trying to delete...'); const component = await section.findItem(componentName); + // console.log('Create component afterEach: ', componentName, ' found: ', !!component); + + // console.log('Create component afterEach: deleting source code folder for: ', componentName); + // console.log('Create component afterEach: Openning Context Menu...'); const contextMenu = await component.openContextMenu(); + // console.log('Create component afterEach: context menu is opened: ', !!contextMenu); + // console.log('Create component afterEach: Selecting "', MENUS.deleteSourceCodeFolder, '...'); + await contextMenu.select(MENUS.deleteSourceCodeFolder); + await new Promise((res) => { + setTimeout(res, 500); + }); + // console.log('Create component afterEach: Waiting for "Delete Source Code Folder" notification...'); + const notification = await notificationExists( NOTIFICATIONS.deleteSourceCodeFolder(pth.join(path, componentName)), VSBrowser.instance.driver, ); + + // console.log('Create component afterEach: Delete Source Code Folder notification found: ', !!notification); + // console.log('Create component afterEach: Confirming "', MENUS.deleteSourceCodeFolder, '...'); + await notification.takeAction(INPUTS.deleteSourceFolder); + + // console.log('Create component afterEach: Delete Source Code Folder notification "clicked"'); + //fs.rmSync(pth.join(path, componentName), { recursive: true, force: true }); componentName = undefined; + // console.log('Create component from local folder: Refreshing the view...'); await refreshView(); + // console.log('Create component from local folder: Loading component buton...'); await loadCreateComponentButton(); } + await new EditorView().closeAllEditors(); + const notificationCenter = await new Workbench().openNotificationsCenter(); const notifications = await notificationCenter.getNotifications(NotificationType.Any); if (notifications.length > 0) { await notificationCenter.close(); + // console.log('Create component afterEach: Notification center closed'); + } else { + // console.log('Create component afterEach: Notification center NOT closed (due to absent notifications)'); } + }); after(async function context() { @@ -224,12 +300,19 @@ export function testCreateComponent(path: string) { } async function refreshView() { + // console.log('Create component refreshView: section found: ', !!section); + // console.log('Create component refreshView: section is about to collapse...'); await section.collapse(); + // console.log('Create component refreshView: section is about to expand...'); await section.expand(); + // console.log('Create component refreshView: getting "Refresh Components View" action...'); const refresh = await section.getAction('Refresh Components View'); + // console.log('Create component refreshView: refresh action found: ', !!refresh); + // console.log('Create component refreshView: about to click "Refresh Components View" action...'); await refresh.click(); + // console.log('Create component refreshView: clicked "Refresh Components View" action'); await new Promise((res) => { - setTimeout(res, 1_000); + setTimeout(res, 2_000); }); } @@ -241,12 +324,19 @@ export function testCreateComponent(path: string) { } async function loadCreateComponentButton() { - section = await view.getContent().getSection(VIEWS.components); + // console.log('Create component loadCreateComponentButton: view found: ', !!view); await VSBrowser.instance.driver.wait(async () => { - const buttons = await (await section.findWelcomeContent()).getButtons(); + section = await view?.getContent().getSection(VIEWS.components); + // console.log('Create component loadCreateComponentButton: section found: ', !!section); + const welcome = await section?.findWelcomeContent(); + // console.log('Create component loadCreateComponentButton: welcome found: ', !!welcome); + + const buttons = await welcome?.getButtons(); + // console.log('Create component loadCreateComponentButton: buttons found: ', !!buttons); for (const btn of buttons) { if ((await btn.getTitle()) === BUTTONS.newComponent) { button = btn; + // console.log('Create component loadCreateComponentButton: button "', BUTTONS.newComponent, ': found: ', !!btn); return true; } } diff --git a/test/ui/suite/extension.ts b/test/ui/suite/extension.ts index 688fd2953..178f90420 100644 --- a/test/ui/suite/extension.ts +++ b/test/ui/suite/extension.ts @@ -4,46 +4,46 @@ *-----------------------------------------------------------------------------------------------*/ import { expect } from 'chai'; -import { ActivityBar, ExtensionsViewItem, ExtensionsViewSection, SideBarView } from 'vscode-extension-tester'; +import { ActivityBar, ExtensionsViewItem, SideBarView } from 'vscode-extension-tester'; import * as pjson from '../../../package.json'; import { VIEWS } from '../common/constants'; export function checkExtension() { describe('Extensions view check', () => { - let extView: ExtensionsViewSection; - let item: ExtensionsViewItem; - - before(async function () { - this.timeout(15_000); - const btn = await new ActivityBar().getViewControl(VIEWS.extensions); - await btn.openView(); - extView = await new SideBarView().getContent().getSection(VIEWS.installed); - item = await extView.findItem(`@installed ${pjson.displayName}`); + + beforeEach(async function () { + this.timeout(15000); + + const view = await new ActivityBar().getViewControl(VIEWS.extensions); + await view.openView(); + + await new Promise(res => setTimeout(res, 500)); }); - it('Openshift Toolkit is installed', () => { + it('Openshift Toolkit is installed', async function () { + this.timeout(30000); + + const item = await getItem(); expect(item).not.undefined; }); - it('Openshift toolkit has the correct attributes', async function() { - this.timeout(15_000) - let version: string; - let author: string; - let desc: string; - try{ - version = await item.getVersion(); - author = await item.getAuthor(); - desc = await item.getDescription(); - } catch { - await new Promise(res => setTimeout(res, 5_000)); - version = await item.getVersion(); - author = await item.getAuthor(); - desc = await item.getDescription(); - } + it('Openshift toolkit has the correct attributes', async function () { + this.timeout(30000); + + const item = await getItem(); + + const version = await item.getVersion(); + const author = await item.getAuthor(); + const desc = await item.getDescription(); expect(version).equals(pjson.version); expect(author).equals(pjson.author); expect(desc).equals(pjson.description); }); + + async function getItem(): Promise { + const section = await new SideBarView().getContent().getSection(VIEWS.installed); + return await section.findItem(`@installed ${pjson.displayName}`) as ExtensionsViewItem; + } }); -} +} \ No newline at end of file diff --git a/test/ui/suite/project.ts b/test/ui/suite/project.ts index df3607d9c..4a7da2381 100644 --- a/test/ui/suite/project.ts +++ b/test/ui/suite/project.ts @@ -4,22 +4,21 @@ *-----------------------------------------------------------------------------------------------*/ import { - SideBarView, - ViewSection, + ActivityBar, EditorView, InputBox, - ActivityBar, - NotificationType, - Workbench, + SideBarView, TreeItem, VSBrowser, - before, - beforeEach, + ViewSection, + Workbench, after, + before, + beforeEach } from 'vscode-extension-tester'; +import { activateCommand } from '../common/command-activator'; import { itemExists, notificationExists } from '../common/conditions'; import { INPUTS, MENUS, NOTIFICATIONS, VIEWS } from '../common/constants'; -import { activateCommand } from '../common/command-activator'; export function projectTest(isOpenshiftCluster: boolean) { describe('Work with project', function () { @@ -33,7 +32,6 @@ export function projectTest(isOpenshiftCluster: boolean) { const deleteProject = isOpenshiftCluster ? MENUS.deleteProject : MENUS.deleteNamespace; let view: SideBarView; - let explorer: ViewSection; let projectName: string; let anotherProjectName: string; @@ -41,17 +39,18 @@ export function projectTest(isOpenshiftCluster: boolean) { before(async function () { this.timeout(10_000); view = await (await new ActivityBar().getViewControl(VIEWS.openshift)).openView(); - explorer = await view.getContent().getSection(VIEWS.appExplorer); + try { + const notifications = await new Workbench().getNotifications(); + for (const n of notifications) { + try { await n.dismiss(); } catch { /* Ignore */ } + } + } catch { /* Ignore */ } + const explorer = await getExplorer(); await explorer.expand(); await itemExists(clusterName, explorer); }); beforeEach(async function () { - const notificationCenter = await new Workbench().openNotificationsCenter(); - const notifications = await notificationCenter.getNotifications(NotificationType.Any); - if (notifications.length > 0) { - await notificationCenter.close(); - } await new EditorView().closeAllEditors(); }); @@ -65,12 +64,13 @@ export function projectTest(isOpenshiftCluster: boolean) { await input.setText(anotherProjectName); await input.confirm(); + const explorer = await getExplorer(); (await itemExists(anotherProjectName, explorer)) as TreeItem; }); it('Create a new project', async function () { this.timeout(30_000); - const clusterItem = (await explorer.findItem(clusterName)) as TreeItem; + const clusterItem = (await (await getExplorer()).findItem(clusterName)) as TreeItem; await clusterItem.expand(); const contextMenu = await clusterItem.openContextMenu(); await contextMenu.select(newProject); @@ -84,6 +84,7 @@ export function projectTest(isOpenshiftCluster: boolean) { await input.setText(projectName); await input.confirm(); + const explorer = await getExplorer(); await itemExists(projectName, explorer); }); @@ -91,7 +92,7 @@ export function projectTest(isOpenshiftCluster: boolean) { this.timeout(30_000); anotherProjectName = getProjectName(); - const clusterItem = (await explorer.findItem(clusterName)) as TreeItem; + const clusterItem = (await (await getExplorer()).findItem(clusterName)) as TreeItem; await clusterItem.expand(); const contextMenu = await clusterItem.openContextMenu(); await contextMenu.select(newProject); @@ -100,6 +101,7 @@ export function projectTest(isOpenshiftCluster: boolean) { await input.setText(anotherProjectName); await input.confirm(); + let explorer = await getExplorer(); const item = (await itemExists(anotherProjectName, explorer)) as TreeItem; const changeActiveProjectButton = await item.getActionButton(changeProject); @@ -112,15 +114,15 @@ export function projectTest(isOpenshiftCluster: boolean) { await input.setText(projectName); await input.confirm(); + explorer = await getExplorer(); await itemExists(projectName, explorer); }); it('Delete a project', async function () { this.timeout(30_000); - const projectItem = await explorer.findItem(projectName); - const contextMenu = await projectItem.openContextMenu(); - await contextMenu.select(deleteProject); + const projectItem = await (await getExplorer()).findItem(projectName); + const contextMenu = await projectItem.openContextMenu(); await contextMenu.select(deleteProject); @@ -156,5 +158,9 @@ export function projectTest(isOpenshiftCluster: boolean) { function getProjectName() { return `project${Math.floor(Math.random() * 100)}`; } + + async function getExplorer(): Promise { + return await view.getContent().getSection(VIEWS.appExplorer); + } }); }