testomatio-editor-blocks 0.4.39 → 0.4.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/editor/customMarkdownConverter.js +4 -2
- package/package/editor/snippetAutocomplete.js +6 -6
- package/package/editor/stepAutocomplete.js +6 -6
- package/package.json +1 -1
- package/src/editor/customMarkdownConverter.test.ts +27 -0
- package/src/editor/customMarkdownConverter.ts +4 -2
- package/src/editor/snippetAutocomplete.ts +5 -6
- package/src/editor/stepAutocomplete.tsx +5 -6
|
@@ -652,7 +652,7 @@ function parseList(lines, startIndex, listType, indentLevel, allowEmptySteps = f
|
|
|
652
652
|
// Check if this line should be parsed as nested content
|
|
653
653
|
// Only go deeper if indent is at least 2 more than the next level's expected indent
|
|
654
654
|
const nextLevelExpectedIndent = (indentLevel + 1) * 2;
|
|
655
|
-
if (indent >= nextLevelExpectedIndent) {
|
|
655
|
+
if (indent >= nextLevelExpectedIndent && items.length > 0) {
|
|
656
656
|
const lastItem = items.at(-1);
|
|
657
657
|
if (!lastItem) {
|
|
658
658
|
break;
|
|
@@ -795,9 +795,11 @@ function parseTestStep(lines, index, allowEmpty = false, snippetId) {
|
|
|
795
795
|
let expectedResult = "";
|
|
796
796
|
let next = index + 1;
|
|
797
797
|
let inExpectedResult = false;
|
|
798
|
+
const stepIndent = current.length - current.trimStart().length;
|
|
798
799
|
while (next < lines.length) {
|
|
799
800
|
const line = lines[next];
|
|
800
|
-
const
|
|
801
|
+
const lineIndent = line.length - line.trimStart().length;
|
|
802
|
+
const hasIndent = lineIndent > stepIndent;
|
|
801
803
|
const rawTrimmed = line.trim();
|
|
802
804
|
if (!rawTrimmed) {
|
|
803
805
|
if (stepDataLines.length > 0 || inExpectedResult) {
|
|
@@ -13,14 +13,14 @@ export function useSnippetAutocomplete() {
|
|
|
13
13
|
return cachedSuggestions;
|
|
14
14
|
if (!globalFetcher)
|
|
15
15
|
return [];
|
|
16
|
+
if (inflightPromise)
|
|
17
|
+
return [];
|
|
16
18
|
const result = globalFetcher();
|
|
17
19
|
if (result && typeof result.then === "function") {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return []; });
|
|
23
|
-
}
|
|
20
|
+
inflightPromise = result
|
|
21
|
+
.then((r) => normalizeSnippetSuggestions(r))
|
|
22
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
23
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return []; });
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
26
|
const normalized = normalizeSnippetSuggestions(result);
|
|
@@ -13,14 +13,14 @@ export function useStepAutocomplete() {
|
|
|
13
13
|
return cachedSuggestions;
|
|
14
14
|
if (!globalFetcher)
|
|
15
15
|
return [];
|
|
16
|
+
if (inflightPromise)
|
|
17
|
+
return [];
|
|
16
18
|
const result = globalFetcher();
|
|
17
19
|
if (result && typeof result.then === "function") {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return []; });
|
|
23
|
-
}
|
|
20
|
+
inflightPromise = result
|
|
21
|
+
.then((r) => normalizeStepSuggestions(r))
|
|
22
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
23
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return []; });
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
26
|
const normalized = normalizeStepSuggestions(result);
|
package/package.json
CHANGED
|
@@ -1008,6 +1008,33 @@ describe("markdownToBlocks", () => {
|
|
|
1008
1008
|
expect(nestedChildren.some((child) => child.type === "bulletListItem")).toBe(true);
|
|
1009
1009
|
});
|
|
1010
1010
|
|
|
1011
|
+
it("does not freeze on indented list items without a parent", () => {
|
|
1012
|
+
const markdown = [
|
|
1013
|
+
"### Requirements",
|
|
1014
|
+
"",
|
|
1015
|
+
" * The system should log in the user {{username}} with password ${password} successfully.",
|
|
1016
|
+
"",
|
|
1017
|
+
" ### Steps",
|
|
1018
|
+
"",
|
|
1019
|
+
" * Open login page",
|
|
1020
|
+
" *Expected*: The main page is opened",
|
|
1021
|
+
" * Enter username {{username}} and password ${password}",
|
|
1022
|
+
" * Click login button",
|
|
1023
|
+
" * Verify user is redirected to the dashboard",
|
|
1024
|
+
].join("\n");
|
|
1025
|
+
|
|
1026
|
+
const blocks = markdownToBlocks(markdown);
|
|
1027
|
+
expect(blocks.length).toBeGreaterThan(0);
|
|
1028
|
+
|
|
1029
|
+
const steps = blocks.filter((b) => b.type === "testStep");
|
|
1030
|
+
expect(steps).toHaveLength(4);
|
|
1031
|
+
expect((steps[0].props as any).stepTitle).toBe("Open login page");
|
|
1032
|
+
expect((steps[0].props as any).expectedResult).toBe("The main page is opened");
|
|
1033
|
+
expect((steps[1].props as any).stepTitle).toBe("Enter username {{username}} and password ${password}");
|
|
1034
|
+
expect((steps[2].props as any).stepTitle).toBe("Click login button");
|
|
1035
|
+
expect((steps[3].props as any).stepTitle).toBe("Verify user is redirected to the dashboard");
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1011
1038
|
it("parses expected result prefixes with emphasis", () => {
|
|
1012
1039
|
const markdown = [
|
|
1013
1040
|
"* Open the form.",
|
|
@@ -796,7 +796,7 @@ function parseList(
|
|
|
796
796
|
// Check if this line should be parsed as nested content
|
|
797
797
|
// Only go deeper if indent is at least 2 more than the next level's expected indent
|
|
798
798
|
const nextLevelExpectedIndent = (indentLevel + 1) * 2;
|
|
799
|
-
if (indent >= nextLevelExpectedIndent) {
|
|
799
|
+
if (indent >= nextLevelExpectedIndent && items.length > 0) {
|
|
800
800
|
const lastItem = items.at(-1);
|
|
801
801
|
if (!lastItem) {
|
|
802
802
|
break;
|
|
@@ -964,10 +964,12 @@ function parseTestStep(
|
|
|
964
964
|
let expectedResult = "";
|
|
965
965
|
let next = index + 1;
|
|
966
966
|
let inExpectedResult = false;
|
|
967
|
+
const stepIndent = current.length - current.trimStart().length;
|
|
967
968
|
|
|
968
969
|
while (next < lines.length) {
|
|
969
970
|
const line = lines[next];
|
|
970
|
-
const
|
|
971
|
+
const lineIndent = line.length - line.trimStart().length;
|
|
972
|
+
const hasIndent = lineIndent > stepIndent;
|
|
971
973
|
const rawTrimmed = line.trim();
|
|
972
974
|
|
|
973
975
|
if (!rawTrimmed) {
|
|
@@ -45,14 +45,13 @@ export function useSnippetAutocomplete(): SnippetSuggestion[] {
|
|
|
45
45
|
const [suggestions, setSuggestions] = useState<SnippetSuggestion[]>(() => {
|
|
46
46
|
if (cachedSuggestions.length > 0) return cachedSuggestions;
|
|
47
47
|
if (!globalFetcher) return [];
|
|
48
|
+
if (inflightPromise) return [];
|
|
48
49
|
const result = globalFetcher();
|
|
49
50
|
if (result && typeof (result as Promise<unknown>).then === "function") {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return [] as SnippetSuggestion[]; });
|
|
55
|
-
}
|
|
51
|
+
inflightPromise = (result as Promise<SnippetInput>)
|
|
52
|
+
.then((r) => normalizeSnippetSuggestions(r))
|
|
53
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
54
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return [] as SnippetSuggestion[]; });
|
|
56
55
|
return [];
|
|
57
56
|
}
|
|
58
57
|
const normalized = normalizeSnippetSuggestions(result as SnippetInput);
|
|
@@ -51,14 +51,13 @@ export function useStepAutocomplete(): StepSuggestion[] {
|
|
|
51
51
|
const [suggestions, setSuggestions] = useState<StepSuggestion[]>(() => {
|
|
52
52
|
if (cachedSuggestions.length > 0) return cachedSuggestions;
|
|
53
53
|
if (!globalFetcher) return [];
|
|
54
|
+
if (inflightPromise) return [];
|
|
54
55
|
const result = globalFetcher();
|
|
55
56
|
if (result && typeof (result as Promise<unknown>).then === "function") {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return [] as StepSuggestion[]; });
|
|
61
|
-
}
|
|
57
|
+
inflightPromise = (result as Promise<StepInput>)
|
|
58
|
+
.then((r) => normalizeStepSuggestions(r))
|
|
59
|
+
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
|
|
60
|
+
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return [] as StepSuggestion[]; });
|
|
62
61
|
return [];
|
|
63
62
|
}
|
|
64
63
|
const normalized = normalizeStepSuggestions(result as StepInput);
|