Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 94a72b8

Browse files
committed
test: onboard testing on pr quicktest not wdio
1 parent 687484a commit 94a72b8

File tree

18 files changed

+222
-165
lines changed

18 files changed

+222
-165
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ jobs:
3232
run: npm ci
3333
- name: Package
3434
run: npm run build
35-
# - name: Run tests
36-
# run: npm run wdio-test
35+
- name: Run tests
36+
run: npm run test:cov

.vscodeignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@ vsc-extension-quickstart.md
1010
**/*.ts
1111
node_modules
1212
.wdio-vscode-service
13-
**.vsix
13+
**.vsix
14+
15+
__mocks__
16+
test
17+
coverage
18+
*.log
19+
*.config.mjs
20+
*.config.js
21+
*.conf.ts
22+
.github

eslint.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export default [
1010
'node_modules/*',
1111
'.wdio-vscode-service',
1212
'build/*',
13+
'tailwind.config.js',
14+
'test/specs/test.e2e.ts',
15+
'webpack.config.js',
16+
'webviews/globals.d.ts',
1317
],
1418
},
1519
{

rollup.config.mjs

Lines changed: 74 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import svelte from "rollup-plugin-svelte";
2-
import resolve from "@rollup/plugin-node-resolve";
3-
import commonjs from "@rollup/plugin-commonjs";
4-
import terser from "@rollup/plugin-terser";
5-
import sveltePreprocess from "svelte-preprocess";
6-
import typescript from "@rollup/plugin-typescript";
7-
import json from "@rollup/plugin-json";
1+
import svelte from 'rollup-plugin-svelte';
2+
import resolve from '@rollup/plugin-node-resolve';
3+
import commonjs from '@rollup/plugin-commonjs';
4+
import terser from '@rollup/plugin-terser';
5+
import sveltePreprocess from 'svelte-preprocess';
6+
import typescript from '@rollup/plugin-typescript';
7+
import json from '@rollup/plugin-json';
88
import { svelteSVG } from 'rollup-plugin-svelte-svg';
99
import builtins from 'rollup-plugin-node-builtins';
1010
import path from 'path';
1111
import fs from 'fs';
1212
import css from 'rollup-plugin-css-only';
13-
import {fileURLToPath} from 'url';
13+
import { fileURLToPath } from 'url';
1414

15-
import tailwindcss from "tailwindcss";
16-
import autoprefixer from "autoprefixer";
15+
import tailwindcss from 'tailwindcss';
16+
import autoprefixer from 'autoprefixer';
1717

1818
const production = !process.env.ROLLUP_WATCH;
1919

@@ -22,61 +22,68 @@ const __filename = fileURLToPath(import.meta.url);
2222
const __dirname = path.dirname(__filename);
2323

2424
export default fs
25-
.readdirSync(path.join(__dirname, "webviews", "pages"))
26-
.map((input) => {
27-
const name = input.split(".")[0];
28-
return {
29-
input: "webviews/pages/" + input,
30-
output: {
31-
sourcemap: !production,
32-
format: "iife",
33-
name: "app",
34-
file: "out/compiled/" + name + ".js",
35-
assetFileNames: name + '.css',
25+
.readdirSync(path.join(__dirname, 'webviews', 'pages'))
26+
.map((input) => {
27+
const name = input.split('.')[0];
28+
return {
29+
input: 'webviews/pages/' + input,
30+
output: {
31+
sourcemap: !production,
32+
format: 'iife',
33+
name: 'app',
34+
file: 'out/compiled/' + name + '.js',
35+
assetFileNames: name + '.css',
36+
},
37+
onwarn: function (message) {
38+
if (message.code !== 'EVAL') {
39+
console.log(JSON.stringify(message));
40+
throw new Error(message);
41+
}
42+
},
43+
plugins: [
44+
svelte({
45+
compilerOptions: {
46+
// enable run-time checks when not in production
47+
dev: !production,
48+
},
49+
preprocess: sveltePreprocess({
50+
sourceMap: !production,
51+
postcss: {
52+
plugins: [tailwindcss, autoprefixer],
3653
},
37-
onwarn: function (message) {
38-
if (message.code !== 'EVAL'){
39-
console.log(JSON.stringify(message));
40-
throw new Error(message);
41-
}
42-
},
43-
plugins: [
44-
svelte({
45-
compilerOptions: {
46-
// enable run-time checks when not in production
47-
dev: !production,
48-
},
49-
preprocess: sveltePreprocess({
50-
sourceMap: !production,
51-
postcss: {
52-
plugins: [tailwindcss, autoprefixer],
53-
},
54-
}),
55-
emitCss: production,
56-
}),
57-
css(),
58-
json(),
59-
resolve({
60-
browser: true,
61-
dedupe: ["svelte"],
62-
preferBuiltins: false
63-
}),
64-
commonjs(),
65-
builtins(),
66-
svelteSVG({
67-
// optional SVGO options
68-
// pass empty object to enable defaults
69-
svgo: {},
70-
}),
71-
production && terser(),
72-
typescript({
73-
tsconfig: "webviews/tsconfig.json",
74-
sourceMap: !production,
75-
inlineSources: !production,
76-
}),
77-
],
78-
watch: {
79-
clearScreen: false,
80-
},
81-
};
82-
});
54+
}),
55+
emitCss: production,
56+
}),
57+
css(),
58+
json(),
59+
resolve({
60+
browser: true,
61+
dedupe: ['svelte'],
62+
preferBuiltins: false,
63+
}),
64+
commonjs(),
65+
builtins(),
66+
svelteSVG({
67+
// optional SVGO options
68+
// pass empty object to enable defaults
69+
svgo: {},
70+
}),
71+
production && terser(),
72+
typescript({
73+
tsconfig: 'webviews/tsconfig.json',
74+
sourceMap: !production,
75+
inlineSources: !production,
76+
exclude: [
77+
'__mocks__',
78+
'.github',
79+
'eslint.config.mjs',
80+
'jest.config.mjs',
81+
'test/**',
82+
],
83+
}),
84+
],
85+
watch: {
86+
clearScreen: false,
87+
},
88+
};
89+
});

src/commands/handlers.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { findFlowCoverage } from '../libs/FindFlowCoverage';
88
import { CacheProvider } from '../providers/cache-provider';
99
import { testdata } from '../store/testdata';
1010
import { OutputChannel } from '../providers/outputChannel';
11+
import { IRulesConfig } from 'lightning-flow-scanner-core/main/interfaces/IRulesConfig';
1112

1213
export default class Commands {
1314
constructor(private context: vscode.ExtensionContext) {}
1415

1516
get handlers() {
16-
1717
return Object.entries({
1818
'lightningflowscanner.viewDefaulFlowRules': () =>
1919
this.viewDefaulFlowRules(),
@@ -101,7 +101,7 @@ export default class Commands {
101101
}
102102

103103
private async calculateFlowTestCoverage() {
104-
const results = CacheProvider.instance.get('results');
104+
const results = CacheProvider.instance.get('results') as core.ScanResult[];
105105
ScanOverview.createOrShow(this.context.extensionUri, []);
106106
if (results && results.length > 0) {
107107
const coverageMap = await findFlowCoverage(results);
@@ -133,10 +133,7 @@ export default class Commands {
133133
);
134134
if (selectedUris.length > 0) {
135135
let results: core.ScanResult[] = [];
136-
const panel = ScanOverview.createOrShow(
137-
this.context.extensionUri,
138-
results
139-
);
136+
ScanOverview.createOrShow(this.context.extensionUri, results);
140137
OutputChannel.getInstance().logChannel.trace('create panel');
141138
const configReset: vscode.WorkspaceConfiguration =
142139
vscode.workspace
@@ -149,7 +146,9 @@ export default class Commands {
149146
OutputChannel.getInstance().logChannel.trace('reset configurations');
150147
await this.configRules();
151148
}
152-
const ruleConfig = CacheProvider.instance.get('ruleconfig');
149+
const ruleConfig = CacheProvider.instance.get(
150+
'ruleconfig'
151+
) as IRulesConfig;
153152
results = core.scan(await core.parse(selectedUris), ruleConfig);
154153
OutputChannel.getInstance().logChannel.debug('Scan Results', ...results);
155154
await CacheProvider.instance.set('results', results);
@@ -160,7 +159,9 @@ export default class Commands {
160159
}
161160

162161
private async fixFlows() {
163-
const storedResults = CacheProvider.instance.get('results');
162+
const storedResults = CacheProvider.instance.get(
163+
'results'
164+
) as core.ScanResult[];
164165
OutputChannel.getInstance().logChannel.trace(
165166
'has scan results?',
166167
storedResults.length

src/libs/CheckOS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os = require('os');
1+
import os from 'os';
22

33
export function isWindows() {
44
return os.platform().startsWith('win');

src/libs/FindFlowCoverage.ts

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
1-
import { GetOrgInfo } from "./GetOrgInfo";
2-
import { GetFlowCoverage } from "./GetFlowCoverage";
3-
import { GetFlowDefinitionViews } from "./GetFlowDefinitionViews";
1+
import { GetOrgInfo } from './GetOrgInfo';
2+
import { GetFlowCoverage } from './GetFlowCoverage';
3+
import { GetFlowDefinitionViews } from './GetFlowDefinitionViews';
44

55
export async function findFlowCoverage(results): Promise<Map<string, number>> {
66
const flowCoverageMap = new Map<string, number>();
77

88
try {
99
const orgInfo = await new GetOrgInfo().getOrgInfo();
1010
if (orgInfo && orgInfo.result && orgInfo.result.username) {
11-
const flowCoverage = await new GetFlowCoverage().getFlowCoverage(orgInfo.result.username);
12-
const flowDefinitions = await new GetFlowDefinitionViews().getFlowDefinitionViews(orgInfo.result.username);
11+
const flowCoverage = await new GetFlowCoverage().getFlowCoverage(
12+
orgInfo.result.username
13+
);
14+
const flowDefinitions =
15+
await new GetFlowDefinitionViews().getFlowDefinitionViews(
16+
orgInfo.result.username
17+
);
1318

1419
for (const scanResult of results) {
1520
try {
16-
const matchingFlowDefinition = flowDefinitions.result.records.find((record) => scanResult.flow.name === record.ApiName);
21+
const matchingFlowDefinition = flowDefinitions.result.records.find(
22+
(record) => scanResult.flow.name === record.ApiName
23+
);
1724
if (matchingFlowDefinition) {
18-
const matchingFlowCoverage = flowCoverage.result.records.find(record => matchingFlowDefinition.ActiveVersionId === record.FlowVersionId);
19-
const coverage = matchingFlowCoverage ? (matchingFlowCoverage.NumElementsCovered / (matchingFlowCoverage.NumElementsCovered + matchingFlowCoverage.NumElementsNotCovered) * 100) : 0;
20-
flowCoverageMap.set(scanResult.flow.name , coverage);
25+
const matchingFlowCoverage = flowCoverage.result.records.find(
26+
(record) =>
27+
matchingFlowDefinition.ActiveVersionId === record.FlowVersionId
28+
);
29+
const coverage = matchingFlowCoverage
30+
? (matchingFlowCoverage.NumElementsCovered /
31+
(matchingFlowCoverage.NumElementsCovered +
32+
matchingFlowCoverage.NumElementsNotCovered)) *
33+
100
34+
: 0;
35+
flowCoverageMap.set(scanResult.flow.name, coverage);
2136
} else {
22-
flowCoverageMap.set(scanResult.flow.name , 0);
37+
flowCoverageMap.set(scanResult.flow.name, 0);
2338
}
39+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2440
} catch (e) {
25-
flowCoverageMap.set(scanResult.flow.name , 0);
41+
flowCoverageMap.set(scanResult.flow.name, 0);
2642
}
2743
}
28-
2944
} else {
3045
for (const scanResult of results) {
31-
flowCoverageMap.set(scanResult.flow.name , 0);
46+
flowCoverageMap.set(scanResult.flow.name, 0);
3247
}
3348
}
49+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3450
} catch (exception) {
3551
for (const scanResult of results) {
3652
flowCoverageMap.set(scanResult.flow.name, 0);
3753
}
3854
}
3955

4056
return flowCoverageMap;
41-
}
57+
}

src/libs/GetFlowDefinitionViews.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import * as vscode from 'vscode';
2-
import * as child from 'child_process';
31
import { RunSFDXCommand } from './RunCommand';
4-
import { SFDX } from './GetOrgInfo';
52

63
export interface FlowDefinitionViewResult {
74
status: number;

src/libs/GetOrgInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class GetOrgInfo {
1717
public getOrgInfo(): Promise<SFDX> {
1818
try {
1919
return RunSFDXCommand('sf org display --json') as Promise<SFDX>;
20+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2021
} catch (e) {}
2122
}
2223
}

src/libs/RunCommand.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
import * as vscode from "vscode";
2-
import * as child from "child_process";
3-
import { isWindows } from "./CheckOS";
4-
5-
export function RunSFDXCommand(commandString: string): Promise<any> {
6-
7-
return new Promise<any>((resolve, reject) => {
1+
import * as vscode from 'vscode';
2+
import * as child from 'child_process';
3+
import { isWindows } from './CheckOS';
84

5+
export function RunSFDXCommand(commandString: string): Promise<unknown> {
6+
return new Promise<unknown>((resolve, reject) => {
97
if (isWindows()) {
108
commandString = 'cmd /c ' + commandString;
119
}
1210

1311
const workspacePath = vscode.workspace.workspaceFolders;
1412
const foo: child.ChildProcess = child.exec(commandString, {
1513
maxBuffer: 1024 * 1024 * 6,
16-
cwd: workspacePath ? workspacePath[0].uri.fsPath : ""
14+
cwd: workspacePath ? workspacePath[0].uri.fsPath : '',
1715
});
1816

1917
let bufferOutData = '';
2018

21-
foo.stdout.on("data", (dataArg: any) => {
19+
foo.stdout.on('data', (dataArg: string) => {
2220
bufferOutData += dataArg;
2321
});
2422

25-
foo.stderr.on("data", (data: any) => {
23+
foo.stderr.on('data', (data: string) => {
2624
// Handle error message
2725
vscode.window.showErrorMessage(data);
2826
// Reject the promise with the error message
2927
reject(new Error(data));
3028
});
3129

32-
foo.stdin.on("data", (data: any) => {
30+
foo.stdin.on('data', (data: string) => {
3331
// Handle input data if needed
3432
vscode.window.showInformationMessage(data);
3533
});
3634

35+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3736
foo.on('exit', (code, signal) => {
3837
if (code === 0) {
3938
const data = JSON.parse(bufferOutData);

0 commit comments

Comments
 (0)