Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue266 - automated test for view test report for gradle project #470

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2fe17aa
commented code for test
SuparnaSuresh Jan 8, 2025
8dc481c
test for integration test
SuparnaSuresh Jan 8, 2025
39bcdd5
removed unwanted code
SuparnaSuresh Jan 8, 2025
e14f498
Automated test debug entries added
SuparnaSuresh Jan 13, 2025
0087a64
print for debug added - devCommands
SuparnaSuresh Jan 13, 2025
1845977
print for debug added
SuparnaSuresh Jan 13, 2025
7b7a797
fix for test report issue
SuparnaSuresh Jan 13, 2025
a1e688f
delay added for command palette
SuparnaSuresh Jan 13, 2025
0889282
time delay increased
SuparnaSuresh Jan 13, 2025
4a2f01f
Removed unwanted lines
SuparnaSuresh Jan 14, 2025
c843c29
code modified
SuparnaSuresh Jan 14, 2025
4bc0e41
enabled commented test cases
SuparnaSuresh Jan 14, 2025
975ce88
code modified to display test report
SuparnaSuresh Jan 14, 2025
d5719ed
code added in macUtils
SuparnaSuresh Jan 14, 2025
522e306
Documentation added
SuparnaSuresh Jan 14, 2025
3e03b21
removed print statements from helperUtils
SuparnaSuresh Jan 14, 2025
c9d101b
Print statements removed from devCommands
SuparnaSuresh Jan 14, 2025
7d85a4f
removed unwanted imports
SuparnaSuresh Jan 14, 2025
8e8a5ca
Reverted the aligment related changes for the code
SuparnaSuresh Jan 14, 2025
9b69f6f
reverted launch.json changes
SuparnaSuresh Jan 14, 2025
5f7720c
changes made to resolve conflict
SuparnaSuresh Jan 24, 2025
10060a5
Merge branch 'OpenLiberty:main' into issue266_AutomatedTestForViewTes…
SuparnaSuresh Jan 24, 2025
75be6ed
resolved conflict and updated branch
SuparnaSuresh Jan 24, 2025
2c5c2bb
formatted macUtils
SuparnaSuresh Jan 28, 2025
4dc52da
addressed review comments
SuparnaSuresh Jan 29, 2025
97c75c5
addressed review comment
SuparnaSuresh Jan 29, 2025
39c3ac7
removed console
SuparnaSuresh Jan 29, 2025
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
35 changes: 19 additions & 16 deletions src/test/GradleTestDevModeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { InputBox, Workbench,SideBarView, ViewSection,EditorView,DefaultTreeItem
import * as utils from './utils/testUtils';
import * as constants from './definitions/constants';
import path = require('path');
import { viewTestReportForMac } from './utils/macUtils';

describe('Devmode action tests for Gradle Project', () => {
let sidebar: SideBarView;
Expand Down Expand Up @@ -184,6 +185,24 @@ it('start gradle with history from liberty dashboard', async () => {

}).timeout(350000);


it('View test report for gradle project', async () => {

if ((process.platform === 'darwin')) {
//Function call to enter corresponding command in the command prompt to display test report for gradle project in mac
await viewTestReportForMac();
} else {
await utils.launchDashboardAction(item, constants.GRADLE_TR_DASHABOARD_ACTION, constants.GRADLE_TR_DASHABOARD_MAC_ACTION);
// expect (tabs[1]], "Gradle test report not found").to.equal(constants.GRADLE_TEST_REPORT_TITLE);
}
tabs = await new EditorView().getOpenEditorTitles();
await utils.delay(1000);
console.log("Tabs opened: " + tabs.indexOf(constants.GRADLE_TEST_REPORT_TITLE));

expect(tabs.indexOf(constants.GRADLE_TEST_REPORT_TITLE) > -1, "Gradle test report not found").to.equal(true);
Copy link
Contributor

@aparnamichael aparnamichael Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking for tab count > -1, can we close all the other tabs and open only the reports and check the tab header title?

it('View test report for gradle project', async () => {
  // Close all the tabs in editor.
  await new EditorView().closeAllEditors();
  utils.delay(5000);
  if ((process.platform === 'darwin')) {
    //Function call to enter corresponding command in the command prompt to display test report for gradle project in mac
    await viewTestReportForMac();
  } else {
    await utils.launchDashboardAction(item, constants.GRADLE_TR_DASHABOARD_ACTION, constants.GRADLE_TR_DASHABOARD_MAC_ACTION);
  }
  tabs = await new EditorView().getOpenEditorTitles();
  await utils.delay(1000);
  expect (tabs[0], "Gradle test report not found").to.equal(constants.GRADLE_TEST_REPORT_TITLE);
}).timeout(60000);

Also good to add an assert statement, if 'tabs' is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed. Thanks

}).timeout(60000);


/**
* All future test cases should be written before the test that attaches the debugger, as this will switch the UI to the debugger view.
* If, for any reason, a test case needs to be written after the debugger test, ensure that the UI is switched back to the explorer view before executing the subsequent tests.
Expand Down Expand Up @@ -237,26 +256,10 @@ it('attach debugger for gradle with custom parameter event', async () => {
expect(attachStatus).to.be.true;
}).timeout(550000);

it('View test report for gradle project', async () => {

if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux'))
{
//skip running for platforms , enable once https://github.com/OpenLiberty/liberty-tools-vscode/issues/266 is resolved
return true;
}

await utils.launchDashboardAction(item,constants.GRADLE_TR_DASHABOARD_ACTION, constants.GRADLE_TR_DASHABOARD_MAC_ACTION);
tabs = await new EditorView().getOpenEditorTitles();
// expect (tabs[1]], "Gradle test report not found").to.equal(constants.GRADLE_TEST_REPORT_TITLE);
expect (tabs.indexOf(constants.GRADLE_TEST_REPORT_TITLE)>-1, "Gradle test report not found").to.equal(true);

}).timeout(30000);

// Based on the UI testing code, it sometimes selects the wrong command in "command palette", such as choosing "Liberty: Start ..." instead of "Liberty: Start" from the recent suggestions. This discrepancy occurs because we specifically need "Liberty: Start" at that moment.
// Now, clear the command history of the "command palette" to avoid receiving "recently used" suggestions. This action should be performed at the end of Gradle Project tests.
it('Clear Command Palatte', async () => {
await utils.clearCommandPalette();
}).timeout(100000);

});

17 changes: 16 additions & 1 deletion src/test/utils/macUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
DefaultTreeItem, Workbench,
InputBox,
} from "vscode-extension-tester";

import * as utils from './testUtils';
import * as constants from '../definitions/constants';

// NOTE: For MAC OS, Open issue with vscode-extension-tester for ContextMenu Click -> https://github.com/redhat-developer/vscode-extension-tester/issues/444
// So workaround using InputBOx to Map the contextmenu input to its corresponding Action for MAC till the issue is resolved in tool
Expand All @@ -24,4 +25,18 @@ export async function setInputBox(MapActionString: string): Promise<boolean> {
} else {
return false;
}
}

/**
* Function to enter corresponding command in the command prompt to display test report for gradle project
*/
export async function viewTestReportForMac() {
const workbench = new Workbench();
await workbench.openCommandPrompt();
await utils.delay(3000);
await workbench.executeCommand(constants.GRADLE_TR_DASHABOARD_MAC_ACTION);
await utils.delay(3000);

setInputBox(constants.GRADLE_PROJECT);
await utils.delay(2500);
}
Loading