Skip to content

Commit

Permalink
Revert "AAP-34643: Add "Are you sure?" Confirmation for Reset Button (#…
Browse files Browse the repository at this point in the history
…1689)"

This reverts commit 9c07e17.
  • Loading branch information
manstis authored and goneri committed Dec 3, 2024
1 parent 9c07e17 commit f0981fd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 128 deletions.
19 changes: 0 additions & 19 deletions src/features/lightspeed/playbookGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,25 +238,6 @@ export async function showPlaybookGenerationPage(extensionUri: vscode.Uri) {
panel.dispose();
break;
}
case "resetOutline": {
vscode.window
.showInformationMessage(
"Are you sure?",
{
modal: true,
detail: "Resetting the outline will loose your changes.",
},
"Ok",
)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.then((value: any) => {
if (value === "Ok") {
panel.webview.postMessage({
command: "resetOutline",
});
}
});
}
}
});

Expand Down
10 changes: 2 additions & 8 deletions src/webview/apps/lightspeed/playbookGeneration/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ window.addEventListener("message", async (event) => {
}
break;
}
case "resetOutline": {
setButtonEnabled("reset-button", false);
outline.reset();
outline.focus();
}
}
});

Expand Down Expand Up @@ -184,9 +179,8 @@ async function submitInput() {
}

function reset() {
vscode.postMessage({
command: "resetOutline",
});
outline.reset();
outline.focus();
}

function backToPage1() {
Expand Down
102 changes: 1 addition & 101 deletions test/ui-test/lightspeedUiTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export function lightspeedUIAssetsTest(): void {
let outlineList: WebElement;
let resetButton: WebElement;
let adtView: ViewSection;
let webView: WebView;
let webviewView: InstanceType<typeof WebviewView>;

before(async function () {
Expand Down Expand Up @@ -199,23 +198,6 @@ export function lightspeedUIAssetsTest(): void {
}
});

async function handleResetOutlineDialog(title: string = "Ok") {
await webView.switchBack();
const resetOutlineDialog = new ModalDialog();
await resetOutlineDialog.pushButton(title);
await sleep(250);
// Sadly we need to switch context and so we must reload the WebView elements
webView = await getWebviewByLocator(
By.xpath("//*[text()='Create a playbook with Ansible Lightspeed']"),
);
outlineList = await webView.findWebElement(
By.xpath("//ol[@id='outline-list']"),
);
resetButton = await webView.findWebElement(
By.xpath("//vscode-button[@id='reset-button']"),
);
}

it("Playbook generation webview works as expected (full path) - part 1", async function () {
// Open Ansible Development Tools by clicking the Getting started button on the side bar
const view = (await new ActivityBar().getViewControl(
Expand Down Expand Up @@ -264,7 +246,7 @@ export function lightspeedUIAssetsTest(): void {
await sleep(2000);

// Start operations on Playbook Generation UI
webView = await getWebviewByLocator(
const webView = await getWebviewByLocator(
By.xpath("//*[text()='Create a playbook with Ansible Lightspeed']"),
);

Expand Down Expand Up @@ -318,10 +300,6 @@ export function lightspeedUIAssetsTest(): void {
.undefined;
await resetButton.click();
await sleep(500);

// Confirm reset of Outline
await handleResetOutlineDialog();

text = await outlineList.getText();
expect(!text.includes("# COMMENT\n"));

Expand Down Expand Up @@ -384,10 +362,6 @@ export function lightspeedUIAssetsTest(): void {
// Click reset button and make sure the string "(status=400)" is removed
await resetButton.click();
await sleep(500);

// Confirm reset of Outline
await handleResetOutlineDialog();

text = await outlineList.getText();
expect(!text.includes("(status=400)"));

Expand Down Expand Up @@ -604,80 +578,6 @@ export function lightspeedUIAssetsTest(): void {
}
});

it("Playbook generation (outline reset)", async function () {
// Execute only when TEST_LIGHTSPEED_URL environment variable is defined.
if (!process.env.TEST_LIGHTSPEED_URL) {
this.skip();
}

// Open playbook generation webview.
await workbenchExecuteCommand("Ansible Lightspeed: Playbook generation");
await sleep(2000);
const webView = await getWebviewByLocator(
By.xpath("//*[text()='Create a playbook with Ansible Lightspeed']"),
);

// Set input text and invoke summaries API
const textArea = await webView.findWebElement(
By.xpath("//vscode-text-area"),
);
expect(textArea, "textArea should not be undefined").not.to.be.undefined;
const submitButton = await webView.findWebElement(
By.xpath("//vscode-button[@id='submit-button']"),
);
expect(submitButton, "submitButton should not be undefined").not.to.be
.undefined;
//
// Note: Following line should succeed, but fails for some unknown reasons.
//
// expect((await submitButton.isEnabled()), "submit button should be disabled by default").is.false;
await textArea.sendKeys("Create an azure network.");
expect(
await submitButton.isEnabled(),
"submit button should be enabled now",
).to.be.true;
await submitButton.click();
await sleep(1000);

// Verify outline output and text edit
const outlineList = await webView.findWebElement(
By.xpath("//ol[@id='outline-list']"),
);
expect(outlineList, "An ordered list should exist.").to.be.not.undefined;
let text = await outlineList.getText();
expect(text.includes("Create virtual network peering")).to.be.true;

// Test Reset button
await outlineList.sendKeys("# COMMENT\n");
text = await outlineList.getText();
expect(text.includes("# COMMENT\n"));

resetButton = await webView.findWebElement(
By.xpath("//vscode-button[@id='reset-button']"),
);
expect(resetButton, "resetButton should not be undefined").not.to.be
.undefined;
expect(
await resetButton.isEnabled(),
"submit button should be enabled now",
).to.be.true;

await resetButton.click();
await sleep(500);

// Cancel reset of Outline
await handleResetOutlineDialog("Cancel");

text = await outlineList.getText();
expect(text.includes("# COMMENT\n"));
expect(
await resetButton.isEnabled(),
"submit button should be enabled now",
).to.be.true;

await workbenchExecuteCommand("View: Close All Editor Groups");
});

it("Playbook generation webview works as expected (feature unavailable)", async function () {
// Execute only when TEST_LIGHTSPEED_URL environment variable is defined.
if (!process.env.TEST_LIGHTSPEED_URL) {
Expand Down

0 comments on commit f0981fd

Please sign in to comment.