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
96 changes: 93 additions & 3 deletions test/ui/suite/createComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
});
}

Expand All @@ -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;
}
}
Expand Down
54 changes: 27 additions & 27 deletions test/ui/suite/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExtensionsViewItem> {
const section = await new SideBarView().getContent().getSection(VIEWS.installed);
return await section.findItem(`@installed ${pjson.displayName}`) as ExtensionsViewItem;
}
});
}
}
Loading
Loading