From 8ca8e8982231cbb716c22d9d6721fe88a1435882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Tue, 26 Nov 2024 13:11:13 -0500 Subject: [PATCH] AAP-35216: lightspeed: Rename PlaybookGenerationActionType Rename `PlaybookGenerationActionType` as `WizardGenerationActionType` since the interface will also be used for the role generation. --- .sonarcloud.properties | 4 +++ src/definitions/lightspeed.ts | 2 +- src/features/lightspeed/playbookGeneration.ts | 12 +++---- src/features/lightspeed/roleGeneration.ts | 12 +++---- src/interfaces/lightspeed.ts | 4 +-- test/ui-test/lightspeedUiTest.ts | 34 +++++++++---------- 6 files changed, 36 insertions(+), 32 deletions(-) create mode 100644 .sonarcloud.properties diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 000000000..5d815d248 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,4 @@ +sonar.cpd.exclusions=\ + src/features/lightspeed/playbookGeneration.ts, \ + src/features/lightspeed/roleGeneration.ts, \ + test/ui-test/*.ts diff --git a/src/definitions/lightspeed.ts b/src/definitions/lightspeed.ts index cb284308a..9772e27c1 100644 --- a/src/definitions/lightspeed.ts +++ b/src/definitions/lightspeed.ts @@ -24,7 +24,7 @@ export enum ThumbsUpDownAction { DOWN = 1, //Thumbs Down } -export enum PlaybookGenerationActionType { +export enum WizardGenerationActionType { OPEN = 0, // Open wizard CLOSE_CANCEL = 1, // Close wizard without accepting the generated playbook TRANSITION = 2, // Page transition diff --git a/src/features/lightspeed/playbookGeneration.ts b/src/features/lightspeed/playbookGeneration.ts index e33c038f9..0716edf64 100644 --- a/src/features/lightspeed/playbookGeneration.ts +++ b/src/features/lightspeed/playbookGeneration.ts @@ -8,7 +8,7 @@ import { IError } from "./utils/errors"; import { GenerationResponseParams } from "../../interfaces/lightspeed"; import { LightSpeedCommands, - PlaybookGenerationActionType, + WizardGenerationActionType, } from "../../definitions/lightspeed"; import { isError, UNKNOWN_ERROR } from "./utils/errors"; import { getOneClickTrialProvider } from "./utils/oneClickTrial"; @@ -42,7 +42,7 @@ function contentMatch(generationId: string, playbook: string) { } async function sendActionEvent( - action: PlaybookGenerationActionType, + action: WizardGenerationActionType, toPage?: number, ) { if (wizardId) { @@ -116,7 +116,7 @@ export async function showPlaybookGenerationPage(extensionUri: vscode.Uri) { ); panel.onDidDispose(async () => { - await sendActionEvent(PlaybookGenerationActionType.CLOSE_CANCEL, undefined); + await sendActionEvent(WizardGenerationActionType.CLOSE_CANCEL, undefined); wizardId = undefined; }); @@ -223,14 +223,14 @@ export async function showPlaybookGenerationPage(extensionUri: vscode.Uri) { } case "transition": { const { toPage } = message; - await sendActionEvent(PlaybookGenerationActionType.TRANSITION, toPage); + await sendActionEvent(WizardGenerationActionType.TRANSITION, toPage); break; } case "openEditor": { const { playbook } = message; await openNewPlaybookEditor(playbook); await sendActionEvent( - PlaybookGenerationActionType.CLOSE_ACCEPT, + WizardGenerationActionType.CLOSE_ACCEPT, undefined, ); // Clear wizardId to suppress another CLOSE event at dispose() @@ -245,7 +245,7 @@ export async function showPlaybookGenerationPage(extensionUri: vscode.Uri) { panel.webview.html = getWebviewContent(panel.webview, extensionUri); panel.webview.postMessage({ command: "init" }); - await sendActionEvent(PlaybookGenerationActionType.OPEN, 1); + await sendActionEvent(WizardGenerationActionType.OPEN, 1); } export function getWebviewContent(webview: Webview, extensionUri: Uri) { diff --git a/src/features/lightspeed/roleGeneration.ts b/src/features/lightspeed/roleGeneration.ts index b2f3a1b11..3336f6edf 100644 --- a/src/features/lightspeed/roleGeneration.ts +++ b/src/features/lightspeed/roleGeneration.ts @@ -9,7 +9,7 @@ import { IError } from "./utils/errors"; import { GenerationResponseParams } from "../../interfaces/lightspeed"; import { LightSpeedCommands, - PlaybookGenerationActionType, + WizardGenerationActionType, } from "../../definitions/lightspeed"; import { isError, UNKNOWN_ERROR } from "./utils/errors"; import { getOneClickTrialProvider } from "./utils/oneClickTrial"; @@ -44,7 +44,7 @@ function contentMatch(generationId: string, playbook: string) { } async function sendActionEvent( - action: PlaybookGenerationActionType, + action: WizardGenerationActionType, toPage?: number, ) { if (currentPanel && wizardId) { @@ -139,7 +139,7 @@ export async function showRoleGenerationPage(extensionUri: vscode.Uri) { ); panel.onDidDispose(async () => { - await sendActionEvent(PlaybookGenerationActionType.CLOSE_CANCEL, undefined); + await sendActionEvent(WizardGenerationActionType.CLOSE_CANCEL, undefined); currentPanel = undefined; wizardId = undefined; }); @@ -248,13 +248,13 @@ export async function showRoleGenerationPage(extensionUri: vscode.Uri) { } case "transition": { const { toPage } = message; - await sendActionEvent(PlaybookGenerationActionType.TRANSITION, toPage); + await sendActionEvent(WizardGenerationActionType.TRANSITION, toPage); break; } case "openEditor": { const { playbook } = message; await sendActionEvent( - PlaybookGenerationActionType.CLOSE_ACCEPT, + WizardGenerationActionType.CLOSE_ACCEPT, undefined, ); await openNewPlaybookEditor(playbook); @@ -271,7 +271,7 @@ export async function showRoleGenerationPage(extensionUri: vscode.Uri) { panel.webview.html = await getWebviewContent(panel.webview, extensionUri); panel.webview.postMessage({ command: "init" }); - await sendActionEvent(PlaybookGenerationActionType.OPEN, 1); + await sendActionEvent(WizardGenerationActionType.OPEN, 1); } export async function getWebviewContent(webview: Webview, extensionUri: Uri) { diff --git a/src/interfaces/lightspeed.ts b/src/interfaces/lightspeed.ts index 01e6b9cfa..4b54bf235 100644 --- a/src/interfaces/lightspeed.ts +++ b/src/interfaces/lightspeed.ts @@ -1,7 +1,7 @@ import { AuthenticationSession } from "vscode"; import { LIGHTSPEED_USER_TYPE, - PlaybookGenerationActionType, + WizardGenerationActionType, ThumbsUpDownAction, UserAction, } from "../definitions/lightspeed"; @@ -84,7 +84,7 @@ export interface PlaybookFeedbackEvent { export interface PlaybookGenerationActionEvent { wizardId: string; - action: PlaybookGenerationActionType; + action: WizardGenerationActionType; fromPage?: number; toPage?: number; } diff --git a/test/ui-test/lightspeedUiTest.ts b/test/ui-test/lightspeedUiTest.ts index c0209a370..4fc646e10 100644 --- a/test/ui-test/lightspeedUiTest.ts +++ b/test/ui-test/lightspeedUiTest.ts @@ -24,7 +24,7 @@ import { workbenchExecuteCommand, openSettings, } from "./uiTestHelper"; -import { PlaybookGenerationActionType } from "../../src/definitions/lightspeed"; +import { WizardGenerationActionType } from "../../src/definitions/lightspeed"; import { PlaybookGenerationActionEvent } from "../../src/interfaces/lightspeed"; config.truncateThreshold = 0; @@ -433,18 +433,18 @@ export function lightspeedUIAssetsTest(): void { /* verify generated events */ const expected = [ - [PlaybookGenerationActionType.OPEN, undefined, 1], - [PlaybookGenerationActionType.TRANSITION, 1, 2], - [PlaybookGenerationActionType.TRANSITION, 2, 1], - [PlaybookGenerationActionType.TRANSITION, 1, 2], - [PlaybookGenerationActionType.TRANSITION, 2, 1], - [PlaybookGenerationActionType.TRANSITION, 1, 2], - [PlaybookGenerationActionType.TRANSITION, 2, 3], - [PlaybookGenerationActionType.TRANSITION, 3, 2], - [PlaybookGenerationActionType.TRANSITION, 2, 3], - [PlaybookGenerationActionType.TRANSITION, 3, 2], - [PlaybookGenerationActionType.TRANSITION, 2, 3], - [PlaybookGenerationActionType.CLOSE_ACCEPT, 3, undefined], + [WizardGenerationActionType.OPEN, undefined, 1], + [WizardGenerationActionType.TRANSITION, 1, 2], + [WizardGenerationActionType.TRANSITION, 2, 1], + [WizardGenerationActionType.TRANSITION, 1, 2], + [WizardGenerationActionType.TRANSITION, 2, 1], + [WizardGenerationActionType.TRANSITION, 1, 2], + [WizardGenerationActionType.TRANSITION, 2, 3], + [WizardGenerationActionType.TRANSITION, 3, 2], + [WizardGenerationActionType.TRANSITION, 2, 3], + [WizardGenerationActionType.TRANSITION, 3, 2], + [WizardGenerationActionType.TRANSITION, 2, 3], + [WizardGenerationActionType.CLOSE_ACCEPT, 3, undefined], ]; const res = await axios.get( `${process.env.TEST_LIGHTSPEED_URL}/__debug__/feedbacks`, @@ -560,10 +560,10 @@ export function lightspeedUIAssetsTest(): void { /* verify generated events */ const expected = [ - [PlaybookGenerationActionType.OPEN, undefined, 1], - [PlaybookGenerationActionType.TRANSITION, 1, 2], - [PlaybookGenerationActionType.TRANSITION, 2, 3], - [PlaybookGenerationActionType.CLOSE_ACCEPT, 3, undefined], + [WizardGenerationActionType.OPEN, undefined, 1], + [WizardGenerationActionType.TRANSITION, 1, 2], + [WizardGenerationActionType.TRANSITION, 2, 3], + [WizardGenerationActionType.CLOSE_ACCEPT, 3, undefined], ]; const res = await axios.get( `${process.env.TEST_LIGHTSPEED_URL}/__debug__/feedbacks`,