Skip to content

Commit

Permalink
Public UI tests (#741)
Browse files Browse the repository at this point in the history
* added public ui tests

* activity test edit
  • Loading branch information
xbabalov authored Feb 8, 2023
1 parent e210de7 commit 97afeb1
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@
"watch:webview": "webpack-cli -w --mode development",
"generate:hub-client": "openapi-generator-cli generate -i https://raw.githubusercontent.com/tektoncd/hub/main/api/gen/http/openapi3.json -g typescript-axios -o src/tekton-hub-client --additional-properties=supportsES6=true",
"ui-test": "extest setup-and-run ./out/ui-test/all.js",
"public-ui-test": "extest setup-and-run ./out/ui-test/publicAllTests.js -c max"
"public-ui-test": "extest setup-and-run ./out/ui-test/public-suite/all-public.js"
},
"devDependencies": {
"@babel/core": "7.19.6",
Expand Down
7 changes: 7 additions & 0 deletions ui-test/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
*-----------------------------------------------------------------------------------------------*/
import * as taskTest from './suite/task-test';
import * as tektonViewTest from './suite/tekton-view-test';
import * as extensionActivityTest from './public-suite/extension-activity-test';
import * as commandPaletteTest from './public-suite/command-palette-test';
import * as extensionViewTest from './public-suite/extension-view-test';

describe('VSCode Tekton UI Tests Suite', () => {
commandPaletteTest.commandPaletteTest()
extensionActivityTest.extensionActivityTest();
extensionViewTest.extensionViewTest();

const clusterUrl = process.env.CLUSTER_URL || 'https://api.openshift4.cluster.adapters-crs-qe.com:6443';
const username = process.env.CLUSTER_USER || 'kubeadmin';
const password = process.env.CLUSTER_PASSWORD || 'password';
Expand Down
1 change: 1 addition & 0 deletions ui-test/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export namespace commands {

export namespace views {
export const TEKTON_TITLE = 'Tekton Pipelines';
export const TEKTON_CATS = [TEKTON_TITLE, 'Debug Sessions', 'TektonHub'];
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import { dummyTest } from './suite/dummy-test';
import * as extensionActivityTest from './extension-activity-test';
import * as commandPaletteTest from './command-palette-test';
import * as extensionViewTest from './extension-view-test';

describe('VSCode Tekton Public UI Tests Suite', () => {
dummyTest();
commandPaletteTest.commandPaletteTest()
extensionActivityTest.extensionActivityTest();
extensionViewTest.extensionViewTest();
});
32 changes: 32 additions & 0 deletions ui-test/public-suite/command-palette-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import { InputBox, Workbench, EditorView } from 'vscode-extension-tester';
import { expect } from 'chai';

export function commandPaletteTest() : void{

describe('Tekton Command Palette Test', () => {

before(async function() {
this.timeout(20000);
await new EditorView().closeAllEditors();
});

it('Search Tekton', async function(){
this.timeout(20000);
await new Workbench().openCommandPrompt();
const paletteInput = await InputBox.create();
await paletteInput.setText('> tekton');

const tektonPicks = await paletteInput.getQuickPicks();
expect(tektonPicks).not.empty;
});

after(async function() {
this.timeout(20000);
await new EditorView().closeAllEditors();
});
});
}
49 changes: 49 additions & 0 deletions ui-test/public-suite/extension-activity-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import { SideBarView, ActivityBar, EditorView } from 'vscode-extension-tester';
import { expect } from 'chai';
import { views } from '../common/constants';

export function extensionActivityTest() : void{

describe('Tekton Activity Test', () => {

before(async function() {
this.timeout(20000);
await new EditorView().closeAllEditors();
});

it('Check Tekton Pipelines Exists', async function(){
this.timeout(20000);
const tektonPip = await new ActivityBar().getViewControl(views.TEKTON_TITLE);
expect(tektonPip).not.undefined;
});

it('Check Tekton View Categories', async function(){
this.timeout(20000);
await (await new ActivityBar().getViewControl(views.TEKTON_TITLE)).openView();
const tektonCats = await new SideBarView().getContent().getSections();
expect(tektonCats.length).equals(3);
expect(await Promise.all(tektonCats.map(async item => await item.getTitle()))).to.has.members(views.TEKTON_CATS);
});

it('Check Tekton Pipelines Actions', async function(){
this.timeout(20000);
await (await new ActivityBar().getViewControl(views.TEKTON_TITLE)).openView();
const tektonPipSection = await new SideBarView().getContent().getSection(views.TEKTON_TITLE);
await tektonPipSection.expand();
expect(tektonPipSection.isExpanded());


const actions = await tektonPipSection.getActions();
expect(actions.length).greaterThan(0);
});

after(async function() {
this.timeout(20000);
await new EditorView().closeAllEditors();
});
});
}
37 changes: 37 additions & 0 deletions ui-test/public-suite/extension-view-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import { ActivityBar, EditorView, ExtensionsViewItem } from 'vscode-extension-tester';
import { expect } from 'chai';

export function extensionViewTest() : void{

describe('Tekton Extension View Test', () => {

before(async function() {
this.timeout(20000);
await new EditorView().closeAllEditors();
});

it('Check Tekton Installation And Information', async function(){
this.timeout(20000);
const extensionView = await (await new ActivityBar().getViewControl('Extensions')).openView();
const installedSection = await extensionView.getContent().getSection('Installed');
const tektonItem = await installedSection.findItem('@installed Tekton Pipelines') as ExtensionsViewItem;
expect(tektonItem).not.undefined;

const tektonTitle = await tektonItem.getTitle();
const tektonInstalled = await tektonItem.isInstalled();
const tektonAuthor = await tektonItem.getAuthor();
expect(tektonTitle).equals('Tekton Pipelines');
expect(tektonInstalled).is.true;
expect(tektonAuthor).equals('Red Hat');
});

after(async function() {
this.timeout(20000);
await new EditorView().closeAllEditors();
});
});
}

0 comments on commit 97afeb1

Please sign in to comment.