Skip to content

Commit

Permalink
add tests and sonarcloud exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed Dec 17, 2024
1 parent 3ebed86 commit 929ddad
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
sonar.cpd.exclusions=\
src/features/lightspeed/playbookGeneration.ts, \
src/features/lightspeed/roleGeneration.ts, \
src/features/contentCreator/addPluginPage.ts, \
src/webview/apps/contentCreator/addPluginPageApp.ts, \
test/ui-test/*.ts
68 changes: 68 additions & 0 deletions test/ui-test/contentCreatorUiTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,71 @@ describe("Test Ansible playbook project scaffolding", () => {
);
});
});

describe("Test collection plugins scaffolding", () => {
let createButton: WebElement;
let editorView: EditorView;

async function testWebViewElements(
command: string,
editorTitle: string,
pluginName: string,
pluginType: string,
) {
await workbenchExecuteCommand(command);
await sleep(4000);

await new EditorView().openEditor(editorTitle);
const webview = await getWebviewByLocator(
By.xpath("//vscode-text-field[@id='plugin-name']"),
);

const pluginNameTextField = await webview.findWebElement(
By.xpath("//vscode-text-field[@id='plugin-name']"),
);
expect(pluginNameTextField, "pluginNameTextField should not be undefined")
.not.to.be.undefined;
await pluginNameTextField.sendKeys(pluginName);

const pluginTypeDropdown = await webview.findWebElement(
By.xpath("//vscode-dropdown[@id='plugin-dropdown']"),
);
expect(pluginTypeDropdown, "pluginTypeDropdown should not be undefined").not
.to.be.undefined;
await pluginTypeDropdown.sendKeys(pluginType);

const overwriteCheckbox = await webview.findWebElement(
By.xpath("//vscode-checkbox[@id='overwrite-checkbox']"),
);
expect(overwriteCheckbox, "overwriteCheckbox should not be undefined").not
.to.be.undefined;
await overwriteCheckbox.click();

createButton = await webview.findWebElement(
By.xpath("//vscode-button[@id='create-button']"),
);
expect(createButton, "createButton should not be undefined").not.to.be
.undefined;

expect(
await createButton.isEnabled(),
"Create button should be enabled now",
).to.be.true;

await createButton.click();
await webview.switchBack();
editorView = new EditorView();
if (editorView) {
await editorView.closeAllEditors();
}
}

it("Check add-plugin webview elements", async () => {
await testWebViewElements(
"Ansible: Add a Plugin",
"Add Plugin",
"test_plugin_name",
"filter",
);
});
});

0 comments on commit 929ddad

Please sign in to comment.