From c8a7a5f0110b9211f9504d0e766f47e24c8fa25f Mon Sep 17 00:00:00 2001 From: Lukas Grossmann Date: Tue, 27 Aug 2024 16:53:50 +0200 Subject: [PATCH] Delete component using context menu instead of filesystem Signed-off-by: Lukas Grossmann --- test/ui/common/constants.ts | 8 +++++++- test/ui/suite/createComponent.ts | 25 ++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/test/ui/common/constants.ts b/test/ui/common/constants.ts index c468e523c..71e741d89 100644 --- a/test/ui/common/constants.ts +++ b/test/ui/common/constants.ts @@ -35,6 +35,8 @@ export const INPUTS = { yes: 'Yes', no: 'No', logout: 'Logout', + deleteConfiguration: 'Delete Configuration', + deleteSourceFolder: 'Delete Source Folder', }; export const MENUS = { @@ -50,6 +52,8 @@ export const MENUS = { showLog: 'Show Log', followLog: 'Follow Log', debug: 'Debug', + deleteConfiguration: 'Delete Component Configuration', + deleteSourceCodeFolder: 'Delete Source Code Folder', }; export const COMPONENTS = { @@ -65,5 +69,7 @@ export const NOTIFICATIONS = { savePasswordPrompt: 'Do you want to save username and password?', loginSuccess: (cluster: string) => `Successfully logged in to '${cluster}'`, doYouWantLogOut: 'Do you want to logout of cluster?', - logoutSuccess: 'Successfully logged out. Do you want to login to a new cluster' + logoutSuccess: 'Successfully logged out. Do you want to login to a new cluster', + deleteConfig: (path: string) => `Are you sure you want to delete the configuration for the component ${path}? OpenShift Toolkit will no longer recognize the project as a component.`, + deleteSourceCodeFolder: (path: string) => `Are you sure you want to delete the folder containing the source code for ${path}?`, }; diff --git a/test/ui/suite/createComponent.ts b/test/ui/suite/createComponent.ts index 16c56805a..9668ed08e 100644 --- a/test/ui/suite/createComponent.ts +++ b/test/ui/suite/createComponent.ts @@ -14,10 +14,11 @@ import { NotificationType, SideBarView, ViewSection, + VSBrowser, WelcomeContentButton, Workbench, } from 'vscode-extension-tester'; -import { BUTTONS, VIEWS } from '../common/constants'; +import { BUTTONS, INPUTS, MENUS, NOTIFICATIONS, VIEWS } from '../common/constants'; import { collapse } from '../common/overdrives'; import { CreateComponentWebView, @@ -29,6 +30,7 @@ import { RegistryWebViewDevfileWindow, RegistryWebViewEditor, } from '../common/ui/webview/registryWebViewEditor'; +import { notificationExists } from '../common/conditions'; //TODO: Add more checks for different elements export function testCreateComponent(path: string) { @@ -88,7 +90,19 @@ export function testCreateComponent(path: string) { it('Create component from local folder', async function test() { this.timeout(25_000); - fs.rmSync(pth.join(path, componentName, 'devfile.yaml'), { force: true }); + const component = await section.findItem(componentName); + const contextMenu = await component.openContextMenu(); + await contextMenu.select(MENUS.deleteConfiguration); + + const notification = await notificationExists(NOTIFICATIONS.deleteConfig(pth.join(path, componentName)), VSBrowser.instance.driver); + await notification.takeAction(INPUTS.deleteConfiguration); + + const notificationCenter = await new Workbench().openNotificationsCenter(); + const notifications = await notificationCenter.getNotifications(NotificationType.Any); + if (notifications.length > 0) { + await notificationCenter.close(); + } + await refreshView(); await loadCreateComponentButton(); await clickCreateComponent(); @@ -155,7 +169,12 @@ export function testCreateComponent(path: string) { afterEach(async function context() { this.timeout(30_000); if (componentName && dlt) { - fs.rmSync(pth.join(path, componentName), { recursive: true, force: true }); + const component = await section.findItem(componentName); + const contextMenu = await component.openContextMenu(); + await contextMenu.select(MENUS.deleteSourceCodeFolder); + const notification = await notificationExists(NOTIFICATIONS.deleteSourceCodeFolder(pth.join(path, componentName)), VSBrowser.instance.driver); + await notification.takeAction(INPUTS.deleteSourceFolder); + //fs.rmSync(pth.join(path, componentName), { recursive: true, force: true }); componentName = undefined; await refreshView(); await loadCreateComponentButton();