Skip to content

Commit

Permalink
Delete component using context menu instead of filesystem
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Grossmann <[email protected]>
  • Loading branch information
Lukas Grossmann authored and vrubezhny committed Aug 28, 2024
1 parent 28c204a commit c8a7a5f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 7 additions & 1 deletion test/ui/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export const INPUTS = {
yes: 'Yes',
no: 'No',
logout: 'Logout',
deleteConfiguration: 'Delete Configuration',
deleteSourceFolder: 'Delete Source Folder',
};

export const MENUS = {
Expand All @@ -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 = {
Expand All @@ -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}?`,
};
25 changes: 22 additions & 3 deletions test/ui/suite/createComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c8a7a5f

Please sign in to comment.