lib-e2e-cypress-for-dummys-ts 0.2.0 → 0.3.0
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/README.md +80 -1
- package/dist/index.cjs +322 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +319 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -578,7 +578,9 @@ var I18N_ES = {
|
|
|
578
578
|
NO_TAGS: "Sin etiquetas",
|
|
579
579
|
SAVE_BTN: "\u{1F4BE} Guardar",
|
|
580
580
|
SAVE_AND_EDIT: "\u{1F4DD} Guardar y editar",
|
|
581
|
-
REMOVE_TAG_TITLE: "Quitar"
|
|
581
|
+
REMOVE_TAG_TITLE: "Quitar",
|
|
582
|
+
NOTES_LABEL: "Descripci\xF3n / Notas (opcional):",
|
|
583
|
+
NOTES_PLACEHOLDER: "Qu\xE9 valida este test, condiciones previas, etc."
|
|
582
584
|
},
|
|
583
585
|
TEST_EDITOR: {
|
|
584
586
|
NO_TAGS: "Sin etiquetas",
|
|
@@ -627,7 +629,10 @@ var I18N_ES = {
|
|
|
627
629
|
JSON_BAD_FORMAT: "El archivo no tiene el formato esperado.",
|
|
628
630
|
SMART_SELECTOR_SECTION: "\u{1F50D} Selector inteligente",
|
|
629
631
|
SMART_SELECTOR_TITLE: "Selector inteligente",
|
|
630
|
-
SMART_SELECTOR_SUB: "Muestra un picker al hacer click en elementos sin selector v\xE1lido."
|
|
632
|
+
SMART_SELECTOR_SUB: "Muestra un picker al hacer click en elementos sin selector v\xE1lido.",
|
|
633
|
+
START_HIDDEN_SECTION: "\u{1F441} Visibilidad del widget",
|
|
634
|
+
START_HIDDEN_TITLE: "Iniciar oculto",
|
|
635
|
+
START_HIDDEN_SUB: "El widget arranca invisible. Usa Ctrl+Shift+E para mostrarlo u ocultarlo."
|
|
631
636
|
},
|
|
632
637
|
SELECTOR_PICKER: {
|
|
633
638
|
TITLE: "Selecciona un elemento del DOM",
|
|
@@ -740,7 +745,9 @@ var I18N_EN = {
|
|
|
740
745
|
NO_TAGS: "No tags",
|
|
741
746
|
SAVE_BTN: "\u{1F4BE} Save",
|
|
742
747
|
SAVE_AND_EDIT: "\u{1F4DD} Save and edit",
|
|
743
|
-
REMOVE_TAG_TITLE: "Remove"
|
|
748
|
+
REMOVE_TAG_TITLE: "Remove",
|
|
749
|
+
NOTES_LABEL: "Description / Notes (optional):",
|
|
750
|
+
NOTES_PLACEHOLDER: "What this test validates, preconditions, etc."
|
|
744
751
|
},
|
|
745
752
|
TEST_EDITOR: {
|
|
746
753
|
NO_TAGS: "No tags",
|
|
@@ -789,7 +796,10 @@ var I18N_EN = {
|
|
|
789
796
|
JSON_BAD_FORMAT: "The file does not have the expected format.",
|
|
790
797
|
SMART_SELECTOR_SECTION: "\u{1F50D} Smart selector",
|
|
791
798
|
SMART_SELECTOR_TITLE: "Smart selector",
|
|
792
|
-
SMART_SELECTOR_SUB: "Shows a picker when clicking elements with no valid selector."
|
|
799
|
+
SMART_SELECTOR_SUB: "Shows a picker when clicking elements with no valid selector.",
|
|
800
|
+
START_HIDDEN_SECTION: "\u{1F441} Widget visibility",
|
|
801
|
+
START_HIDDEN_TITLE: "Start hidden",
|
|
802
|
+
START_HIDDEN_SUB: "The widget starts invisible. Use Ctrl+Shift+E to show or hide it."
|
|
793
803
|
},
|
|
794
804
|
SELECTOR_PICKER: {
|
|
795
805
|
TITLE: "Select a DOM element",
|
|
@@ -902,7 +912,9 @@ var I18N_FR = {
|
|
|
902
912
|
NO_TAGS: "Sans \xE9tiquettes",
|
|
903
913
|
SAVE_BTN: "\u{1F4BE} Enregistrer",
|
|
904
914
|
SAVE_AND_EDIT: "\u{1F4DD} Enregistrer et \xE9diter",
|
|
905
|
-
REMOVE_TAG_TITLE: "Retirer"
|
|
915
|
+
REMOVE_TAG_TITLE: "Retirer",
|
|
916
|
+
NOTES_LABEL: "Description / Notes (optionnel) :",
|
|
917
|
+
NOTES_PLACEHOLDER: "Ce que ce test valide, conditions pr\xE9alables, etc."
|
|
906
918
|
},
|
|
907
919
|
TEST_EDITOR: {
|
|
908
920
|
NO_TAGS: "Sans \xE9tiquettes",
|
|
@@ -951,7 +963,10 @@ var I18N_FR = {
|
|
|
951
963
|
JSON_BAD_FORMAT: "Le fichier n'a pas le format attendu.",
|
|
952
964
|
SMART_SELECTOR_SECTION: "\u{1F50D} S\xE9lecteur intelligent",
|
|
953
965
|
SMART_SELECTOR_TITLE: "S\xE9lecteur intelligent",
|
|
954
|
-
SMART_SELECTOR_SUB: "Affiche un s\xE9lecteur lors du clic sur des \xE9l\xE9ments sans s\xE9lecteur valide."
|
|
966
|
+
SMART_SELECTOR_SUB: "Affiche un s\xE9lecteur lors du clic sur des \xE9l\xE9ments sans s\xE9lecteur valide.",
|
|
967
|
+
START_HIDDEN_SECTION: "\u{1F441} Visibilit\xE9 du widget",
|
|
968
|
+
START_HIDDEN_TITLE: "D\xE9marrer masqu\xE9",
|
|
969
|
+
START_HIDDEN_SUB: "Le widget d\xE9marre invisible. Utilisez Ctrl+Shift+E pour l'afficher ou le masquer."
|
|
955
970
|
},
|
|
956
971
|
SELECTOR_PICKER: {
|
|
957
972
|
TITLE: "S\xE9lectionnez un \xE9l\xE9ment du DOM",
|
|
@@ -1064,7 +1079,9 @@ var I18N_IT = {
|
|
|
1064
1079
|
NO_TAGS: "Nessuna etichetta",
|
|
1065
1080
|
SAVE_BTN: "\u{1F4BE} Salva",
|
|
1066
1081
|
SAVE_AND_EDIT: "\u{1F4DD} Salva e modifica",
|
|
1067
|
-
REMOVE_TAG_TITLE: "Rimuovi"
|
|
1082
|
+
REMOVE_TAG_TITLE: "Rimuovi",
|
|
1083
|
+
NOTES_LABEL: "Descrizione / Note (opzionale):",
|
|
1084
|
+
NOTES_PLACEHOLDER: "Cosa valida questo test, condizioni preliminari, ecc."
|
|
1068
1085
|
},
|
|
1069
1086
|
TEST_EDITOR: {
|
|
1070
1087
|
NO_TAGS: "Nessuna etichetta",
|
|
@@ -1113,7 +1130,10 @@ var I18N_IT = {
|
|
|
1113
1130
|
JSON_BAD_FORMAT: "Il file non ha il formato previsto.",
|
|
1114
1131
|
SMART_SELECTOR_SECTION: "\u{1F50D} Selettore intelligente",
|
|
1115
1132
|
SMART_SELECTOR_TITLE: "Selettore intelligente",
|
|
1116
|
-
SMART_SELECTOR_SUB: "Mostra un selettore quando si fa clic su elementi senza selettore valido."
|
|
1133
|
+
SMART_SELECTOR_SUB: "Mostra un selettore quando si fa clic su elementi senza selettore valido.",
|
|
1134
|
+
START_HIDDEN_SECTION: "\u{1F441} Visibilit\xE0 del widget",
|
|
1135
|
+
START_HIDDEN_TITLE: "Avvia nascosto",
|
|
1136
|
+
START_HIDDEN_SUB: "Il widget si avvia invisibile. Usa Ctrl+Shift+E per mostrarlo o nasconderlo."
|
|
1117
1137
|
},
|
|
1118
1138
|
SELECTOR_PICKER: {
|
|
1119
1139
|
TITLE: "Seleziona un elemento DOM",
|
|
@@ -1226,7 +1246,9 @@ var I18N_DE = {
|
|
|
1226
1246
|
NO_TAGS: "Keine Tags",
|
|
1227
1247
|
SAVE_BTN: "\u{1F4BE} Speichern",
|
|
1228
1248
|
SAVE_AND_EDIT: "\u{1F4DD} Speichern und bearbeiten",
|
|
1229
|
-
REMOVE_TAG_TITLE: "Entfernen"
|
|
1249
|
+
REMOVE_TAG_TITLE: "Entfernen",
|
|
1250
|
+
NOTES_LABEL: "Beschreibung / Notizen (optional):",
|
|
1251
|
+
NOTES_PLACEHOLDER: "Was dieser Test validiert, Voraussetzungen usw."
|
|
1230
1252
|
},
|
|
1231
1253
|
TEST_EDITOR: {
|
|
1232
1254
|
NO_TAGS: "Keine Tags",
|
|
@@ -1275,7 +1297,10 @@ var I18N_DE = {
|
|
|
1275
1297
|
JSON_BAD_FORMAT: "Die Datei hat nicht das erwartete Format.",
|
|
1276
1298
|
SMART_SELECTOR_SECTION: "\u{1F50D} Intelligenter Selektor",
|
|
1277
1299
|
SMART_SELECTOR_TITLE: "Intelligenter Selektor",
|
|
1278
|
-
SMART_SELECTOR_SUB: "Zeigt ein Auswahlfeld, wenn auf Elemente ohne g\xFCltigen Selektor geklickt wird."
|
|
1300
|
+
SMART_SELECTOR_SUB: "Zeigt ein Auswahlfeld, wenn auf Elemente ohne g\xFCltigen Selektor geklickt wird.",
|
|
1301
|
+
START_HIDDEN_SECTION: "\u{1F441} Widget-Sichtbarkeit",
|
|
1302
|
+
START_HIDDEN_TITLE: "Versteckt starten",
|
|
1303
|
+
START_HIDDEN_SUB: "Das Widget startet unsichtbar. Verwenden Sie Ctrl+Shift+E zum Ein-/Ausblenden."
|
|
1279
1304
|
},
|
|
1280
1305
|
SELECTOR_PICKER: {
|
|
1281
1306
|
TITLE: "DOM-Element ausw\xE4hlen",
|
|
@@ -1401,13 +1426,37 @@ var TranslationService = class {
|
|
|
1401
1426
|
};
|
|
1402
1427
|
var translationService = new TranslationService();
|
|
1403
1428
|
|
|
1429
|
+
// src/utils/code-format.utils.ts
|
|
1430
|
+
function gcd(a, b) {
|
|
1431
|
+
while (b) {
|
|
1432
|
+
const t = b;
|
|
1433
|
+
b = a % b;
|
|
1434
|
+
a = t;
|
|
1435
|
+
}
|
|
1436
|
+
return a;
|
|
1437
|
+
}
|
|
1438
|
+
function normalizeBlock(code, baseIndent) {
|
|
1439
|
+
const lines = code.split("\n").map((l) => l.trimEnd());
|
|
1440
|
+
const nonEmpty = lines.filter((l) => l.trim().length > 0);
|
|
1441
|
+
if (!nonEmpty.length) return "";
|
|
1442
|
+
const indents = nonEmpty.map((l) => l.length - l.trimStart().length);
|
|
1443
|
+
const minIndent = Math.min(...indents);
|
|
1444
|
+
const relIndents = [...new Set(indents.map((n) => n - minIndent).filter((n) => n > 0))];
|
|
1445
|
+
const step = relIndents.length > 0 ? relIndents.reduce(gcd) : 2;
|
|
1446
|
+
return lines.map((l) => {
|
|
1447
|
+
if (!l.trim()) return "";
|
|
1448
|
+
const level = Math.round((l.length - l.trimStart().length - minIndent) / step);
|
|
1449
|
+
return baseIndent + " ".repeat(level) + l.trimStart();
|
|
1450
|
+
}).join("\n");
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1404
1453
|
// src/services/transformation.service.ts
|
|
1405
1454
|
var TransformationService = class {
|
|
1406
1455
|
toLang(lang) {
|
|
1407
1456
|
return isLang(lang) ? lang : "en";
|
|
1408
1457
|
}
|
|
1409
1458
|
generateItDescription(description, commands) {
|
|
1410
|
-
const commandsBlock = commands.map((cmd) =>
|
|
1459
|
+
const commandsBlock = commands.map((cmd) => normalizeBlock(cmd, " ")).join("\n");
|
|
1411
1460
|
return `it('${description}', () => {
|
|
1412
1461
|
${commandsBlock}
|
|
1413
1462
|
});`;
|
|
@@ -1438,6 +1487,13 @@ ${interceptors} })
|
|
|
1438
1487
|
}
|
|
1439
1488
|
return content.slice(0, idx) + "\n" + itBlock + "\n" + content.slice(idx);
|
|
1440
1489
|
}
|
|
1490
|
+
buildBlockComment(notes) {
|
|
1491
|
+
if (!notes.trim()) return "";
|
|
1492
|
+
const lines = notes.split("\n").map((l) => ` * ${l}`).join("\n");
|
|
1493
|
+
return `/**
|
|
1494
|
+
${lines}
|
|
1495
|
+
*/`;
|
|
1496
|
+
}
|
|
1441
1497
|
isFile(file) {
|
|
1442
1498
|
return !!file && file.kind === "file";
|
|
1443
1499
|
}
|
|
@@ -1849,9 +1905,9 @@ var PersistenceService = class {
|
|
|
1849
1905
|
return this._db;
|
|
1850
1906
|
}
|
|
1851
1907
|
// ── Tests ─────────────────────────────────────────────────────────────────
|
|
1852
|
-
async insertTest(name, commands = [], interceptors = [], tags = []) {
|
|
1908
|
+
async insertTest(name, commands = [], interceptors = [], tags = [], notes) {
|
|
1853
1909
|
const db = await this.getDB();
|
|
1854
|
-
const record = { name, createdAt: Date.now(), ...tags.length ? { tags } : {} };
|
|
1910
|
+
const record = { name, createdAt: Date.now(), ...tags.length ? { tags } : {}, ...notes ? { notes } : {} };
|
|
1855
1911
|
const id = await db.add("tests", record);
|
|
1856
1912
|
if (commands.length) await this.insertCommands(commands, id);
|
|
1857
1913
|
if (interceptors.length) await this.insertInterceptors(interceptors, id);
|
|
@@ -1875,9 +1931,9 @@ var PersistenceService = class {
|
|
|
1875
1931
|
const commands = await this.getCommandStrings(testId);
|
|
1876
1932
|
const interceptors = await this.getInterceptorStrings(testId);
|
|
1877
1933
|
const itBlock = `it('${record.name}', () => {
|
|
1878
|
-
|
|
1934
|
+
${commands.map((c) => normalizeBlock(c, " ")).join("\n")}
|
|
1879
1935
|
});`;
|
|
1880
|
-
const interceptorsBlock = interceptors.length ? " // Auto-generated Cypress interceptors\n" + interceptors.map((i) => " "
|
|
1936
|
+
const interceptorsBlock = interceptors.length ? " // Auto-generated Cypress interceptors\n" + interceptors.map((i) => normalizeBlock(i, " ")).join("\n") + "\n" : "";
|
|
1881
1937
|
return { ...record, commands, interceptors, cypressCommands: commands, itBlock, interceptorsBlock };
|
|
1882
1938
|
}
|
|
1883
1939
|
async deleteTest(id) {
|
|
@@ -2617,7 +2673,8 @@ if (!customElements.get("test-previsualizer")) {
|
|
|
2617
2673
|
var SAVE_TEST_STYLES = `
|
|
2618
2674
|
:host { display: block; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #e6edf3; }
|
|
2619
2675
|
* { box-sizing: border-box; }
|
|
2620
|
-
.container { padding: 24px 28px; text-align:
|
|
2676
|
+
.container { padding: 24px 28px; text-align: left; }
|
|
2677
|
+
.btn-row, p { text-align: center; }
|
|
2621
2678
|
p { margin: 0 0 20px; font-size: 14px; color: #8b949e; line-height: 1.5; }
|
|
2622
2679
|
.btn-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
|
|
2623
2680
|
button {
|
|
@@ -2639,6 +2696,15 @@ var SAVE_TEST_STYLES = `
|
|
|
2639
2696
|
}
|
|
2640
2697
|
input[type="text"]:focus { border-color: #2f81f7; box-shadow: 0 0 0 3px rgba(47,129,247,0.15); }
|
|
2641
2698
|
input[type="text"]::placeholder { color: #484f58; }
|
|
2699
|
+
textarea {
|
|
2700
|
+
width: 100%; padding: 10px 14px; border: 1px solid #30363d;
|
|
2701
|
+
border-radius: 8px; background: #0d1117; color: #e6edf3;
|
|
2702
|
+
font-size: 14px; outline: none; margin-bottom: 4px;
|
|
2703
|
+
font-family: inherit; resize: vertical; line-height: 1.5;
|
|
2704
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
2705
|
+
}
|
|
2706
|
+
textarea:focus { border-color: #2f81f7; box-shadow: 0 0 0 3px rgba(47,129,247,0.15); }
|
|
2707
|
+
textarea::placeholder { color: #484f58; }
|
|
2642
2708
|
.tag-label {
|
|
2643
2709
|
font-size: 11px; color: #484f58; text-align: left; margin-bottom: 5px; display: block;
|
|
2644
2710
|
}
|
|
@@ -2678,7 +2744,7 @@ function renderSaveTestAsk(t) {
|
|
|
2678
2744
|
</div>
|
|
2679
2745
|
</div>`;
|
|
2680
2746
|
}
|
|
2681
|
-
function renderSaveTestDesc(description, tags, t) {
|
|
2747
|
+
function renderSaveTestDesc(description, notes, tags, t) {
|
|
2682
2748
|
const chipsHtml = tags.map(
|
|
2683
2749
|
(tag) => `<span class="chip">${escHtml(tag)}<button class="chip-del" data-tag="${escAttr(tag)}" title="${t("SAVE_TEST.REMOVE_TAG_TITLE")}">\u2715</button></span>`
|
|
2684
2750
|
).join("");
|
|
@@ -2687,6 +2753,8 @@ function renderSaveTestDesc(description, tags, t) {
|
|
|
2687
2753
|
<p>${t("SAVE_TEST.DESC_LABEL")} (<code>it()</code>):</p>
|
|
2688
2754
|
<input id="desc-input" type="text" placeholder="${t("SAVE_TEST.DESC_PLACEHOLDER")}"
|
|
2689
2755
|
value="${escAttr(description)}" autocomplete="off" />
|
|
2756
|
+
<span class="tag-label">${t("SAVE_TEST.NOTES_LABEL")}</span>
|
|
2757
|
+
<textarea id="notes-input" rows="3" placeholder="${escAttr(t("SAVE_TEST.NOTES_PLACEHOLDER"))}">${escHtml(notes)}</textarea>
|
|
2690
2758
|
<span class="tag-label">${t("SAVE_TEST.TAGS_LABEL")}</span>
|
|
2691
2759
|
<div class="tag-input-row">
|
|
2692
2760
|
<input id="tag-input" type="text" placeholder="${t("SAVE_TEST.TAGS_PLACEHOLDER")}" autocomplete="off" />
|
|
@@ -2706,6 +2774,7 @@ var SaveTestElement = class extends HTMLElement {
|
|
|
2706
2774
|
shadow;
|
|
2707
2775
|
_step = "ask";
|
|
2708
2776
|
description = "";
|
|
2777
|
+
notes = "";
|
|
2709
2778
|
tags = [];
|
|
2710
2779
|
translation = translationService;
|
|
2711
2780
|
constructor() {
|
|
@@ -2723,17 +2792,18 @@ var SaveTestElement = class extends HTMLElement {
|
|
|
2723
2792
|
this.render();
|
|
2724
2793
|
}
|
|
2725
2794
|
confirmSave() {
|
|
2726
|
-
this.dispatch("savetest", { description: this.description.trim(), tags: [...this.tags] });
|
|
2795
|
+
this.dispatch("savetest", { description: this.description.trim(), notes: this.notes, tags: [...this.tags] });
|
|
2727
2796
|
}
|
|
2728
2797
|
confirmSaveAndExport() {
|
|
2729
|
-
this.dispatch("saveandexport", { description: this.description.trim(), tags: [...this.tags] });
|
|
2798
|
+
this.dispatch("saveandexport", { description: this.description.trim(), notes: this.notes, tags: [...this.tags] });
|
|
2730
2799
|
}
|
|
2731
2800
|
cancel() {
|
|
2732
|
-
this.dispatch("savetest", { description: null, tags: [] });
|
|
2801
|
+
this.dispatch("savetest", { description: null, notes: "", tags: [] });
|
|
2733
2802
|
}
|
|
2734
2803
|
restartComponent() {
|
|
2735
2804
|
this._step = "ask";
|
|
2736
2805
|
this.description = "";
|
|
2806
|
+
this.notes = "";
|
|
2737
2807
|
this.tags = [];
|
|
2738
2808
|
this.render();
|
|
2739
2809
|
}
|
|
@@ -2760,12 +2830,16 @@ var SaveTestElement = class extends HTMLElement {
|
|
|
2760
2830
|
this.shadow.getElementById("btn-yes")?.addEventListener("click", () => this.askSave());
|
|
2761
2831
|
this.shadow.getElementById("btn-no")?.addEventListener("click", () => this.cancel());
|
|
2762
2832
|
} else {
|
|
2763
|
-
this.shadow.innerHTML = `<style>${SAVE_TEST_STYLES}</style>${renderSaveTestDesc(this.description, this.tags, this.t.bind(this))}`;
|
|
2833
|
+
this.shadow.innerHTML = `<style>${SAVE_TEST_STYLES}</style>${renderSaveTestDesc(this.description, this.notes, this.tags, this.t.bind(this))}`;
|
|
2764
2834
|
const descInput = this.shadow.getElementById("desc-input");
|
|
2835
|
+
const notesInput = this.shadow.getElementById("notes-input");
|
|
2765
2836
|
const tagInput = this.shadow.getElementById("tag-input");
|
|
2766
2837
|
descInput.addEventListener("input", () => {
|
|
2767
2838
|
this.description = descInput.value;
|
|
2768
2839
|
});
|
|
2840
|
+
notesInput.addEventListener("input", () => {
|
|
2841
|
+
this.notes = notesInput.value;
|
|
2842
|
+
});
|
|
2769
2843
|
const tryAddTag = () => {
|
|
2770
2844
|
this.addTag(tagInput.value);
|
|
2771
2845
|
tagInput.value = "";
|
|
@@ -2871,17 +2945,129 @@ var TEST_EDITOR_STYLES = `
|
|
|
2871
2945
|
background: #0d1117; padding: 10px 14px;
|
|
2872
2946
|
border-top: 1px solid #21262d;
|
|
2873
2947
|
}
|
|
2874
|
-
.
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
.
|
|
2948
|
+
.test-notes {
|
|
2949
|
+
margin: 0 0 10px; padding: 8px 12px;
|
|
2950
|
+
background: rgba(47,129,247,0.06); border-left: 3px solid rgba(47,129,247,0.4);
|
|
2951
|
+
border-radius: 0 6px 6px 0; font-size: 12px; color: #8b949e;
|
|
2952
|
+
line-height: 1.6; white-space: pre-wrap; word-break: break-word;
|
|
2953
|
+
}
|
|
2954
|
+
.code-preview {
|
|
2955
|
+
margin: 0; padding: 10px 12px; background: #161b22;
|
|
2956
|
+
border-radius: 6px; border: 1px solid #21262d;
|
|
2957
|
+
font-size: 11px; color: #c9d1d9; line-height: 1.7;
|
|
2958
|
+
font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
|
|
2959
|
+
overflow-x: auto; white-space: pre;
|
|
2960
|
+
scrollbar-width: thin; scrollbar-color: #30363d transparent;
|
|
2961
|
+
}
|
|
2962
|
+
.code-preview::-webkit-scrollbar { height: 4px; }
|
|
2963
|
+
.code-preview::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }
|
|
2964
|
+
.code-preview-icp { margin-top: 8px; }
|
|
2965
|
+
.sh-kw { color: #ff7b72; }
|
|
2966
|
+
.sh-bi { color: #d2a8ff; }
|
|
2967
|
+
.sh-str { color: #a5d6ff; }
|
|
2968
|
+
.sh-cmt { color: #8b949e; font-style: italic; }
|
|
2969
|
+
.sh-num { color: #79c0ff; }
|
|
2881
2970
|
`;
|
|
2882
2971
|
|
|
2883
2972
|
// src/components/test-editor/test-editor.template.ts
|
|
2884
2973
|
init_html_utils();
|
|
2974
|
+
|
|
2975
|
+
// src/utils/syntax-highlight.utils.ts
|
|
2976
|
+
init_html_utils();
|
|
2977
|
+
var KEYWORDS = /* @__PURE__ */ new Set([
|
|
2978
|
+
"describe",
|
|
2979
|
+
"it",
|
|
2980
|
+
"xit",
|
|
2981
|
+
"fit",
|
|
2982
|
+
"xdescribe",
|
|
2983
|
+
"fdescribe",
|
|
2984
|
+
"beforeEach",
|
|
2985
|
+
"afterEach",
|
|
2986
|
+
"before",
|
|
2987
|
+
"after",
|
|
2988
|
+
"context",
|
|
2989
|
+
"const",
|
|
2990
|
+
"let",
|
|
2991
|
+
"var",
|
|
2992
|
+
"function",
|
|
2993
|
+
"return",
|
|
2994
|
+
"if",
|
|
2995
|
+
"else",
|
|
2996
|
+
"import",
|
|
2997
|
+
"export",
|
|
2998
|
+
"from",
|
|
2999
|
+
"new",
|
|
3000
|
+
"this",
|
|
3001
|
+
"null",
|
|
3002
|
+
"undefined",
|
|
3003
|
+
"true",
|
|
3004
|
+
"false",
|
|
3005
|
+
"async",
|
|
3006
|
+
"await",
|
|
3007
|
+
"of",
|
|
3008
|
+
"in",
|
|
3009
|
+
"typeof",
|
|
3010
|
+
"void"
|
|
3011
|
+
]);
|
|
3012
|
+
var BUILTINS = /* @__PURE__ */ new Set(["cy", "expect", "assert", "Cypress", "chai"]);
|
|
3013
|
+
function syntaxHighlight(code) {
|
|
3014
|
+
return code.split("\n").map(highlightLine).join("\n");
|
|
3015
|
+
}
|
|
3016
|
+
function highlightLine(line) {
|
|
3017
|
+
let result = "";
|
|
3018
|
+
let i = 0;
|
|
3019
|
+
const len = line.length;
|
|
3020
|
+
while (i < len) {
|
|
3021
|
+
if (line[i] === "/" && i + 1 < len && line[i + 1] === "/") {
|
|
3022
|
+
result += `<span class="sh-cmt">${escHtml(line.slice(i))}</span>`;
|
|
3023
|
+
return result;
|
|
3024
|
+
}
|
|
3025
|
+
const q = line[i];
|
|
3026
|
+
if (q === "'" || q === '"' || q === "`") {
|
|
3027
|
+
let j = i + 1;
|
|
3028
|
+
while (j < len) {
|
|
3029
|
+
if (line[j] === "\\") {
|
|
3030
|
+
j += 2;
|
|
3031
|
+
continue;
|
|
3032
|
+
}
|
|
3033
|
+
if (line[j] === q) {
|
|
3034
|
+
j++;
|
|
3035
|
+
break;
|
|
3036
|
+
}
|
|
3037
|
+
j++;
|
|
3038
|
+
}
|
|
3039
|
+
result += `<span class="sh-str">${escHtml(line.slice(i, j))}</span>`;
|
|
3040
|
+
i = j;
|
|
3041
|
+
continue;
|
|
3042
|
+
}
|
|
3043
|
+
if (/[0-9]/.test(line[i]) && (i === 0 || !/[a-zA-Z_$]/.test(line[i - 1]))) {
|
|
3044
|
+
let j = i;
|
|
3045
|
+
while (j < len && /[0-9.]/.test(line[j])) j++;
|
|
3046
|
+
result += `<span class="sh-num">${escHtml(line.slice(i, j))}</span>`;
|
|
3047
|
+
i = j;
|
|
3048
|
+
continue;
|
|
3049
|
+
}
|
|
3050
|
+
if (/[a-zA-Z_$]/.test(line[i])) {
|
|
3051
|
+
let j = i;
|
|
3052
|
+
while (j < len && /[a-zA-Z0-9_$]/.test(line[j])) j++;
|
|
3053
|
+
const word = line.slice(i, j);
|
|
3054
|
+
if (KEYWORDS.has(word)) {
|
|
3055
|
+
result += `<span class="sh-kw">${escHtml(word)}</span>`;
|
|
3056
|
+
} else if (BUILTINS.has(word)) {
|
|
3057
|
+
result += `<span class="sh-bi">${escHtml(word)}</span>`;
|
|
3058
|
+
} else {
|
|
3059
|
+
result += escHtml(word);
|
|
3060
|
+
}
|
|
3061
|
+
i = j;
|
|
3062
|
+
continue;
|
|
3063
|
+
}
|
|
3064
|
+
result += escHtml(line[i]);
|
|
3065
|
+
i++;
|
|
3066
|
+
}
|
|
3067
|
+
return result;
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
// src/components/test-editor/test-editor.template.ts
|
|
2885
3071
|
function renderTestEditor(state, t) {
|
|
2886
3072
|
const { tags, visible, selectedVisible, activeTag, selectMode, selectedIds, describeName, expandedIndex, interceptorsByTest } = state;
|
|
2887
3073
|
const tagFilterHtml = tags.length ? `<div class="tag-filter">
|
|
@@ -2898,18 +3084,20 @@ function renderTestEditor(state, t) {
|
|
|
2898
3084
|
const icps = interceptorsByTest[test.id] ?? test.interceptors ?? [];
|
|
2899
3085
|
const tagsHtml = (test.tags ?? []).length ? `<span class="test-tags">${(test.tags ?? []).map((tag) => `<span class="test-tag">${escHtml(tag)}</span>`).join("")}</span>` : "";
|
|
2900
3086
|
const checkbox = selectMode ? `<input type="checkbox" ${selectedIds.has(test.id) ? "checked" : ""} data-select="${test.id}" />` : "";
|
|
3087
|
+
const hasIcps = (test.interceptors ?? []).length > 0;
|
|
3088
|
+
const itBlockCode = `it('${test.name}', () => {
|
|
3089
|
+
${(test.commands ?? []).map((c) => normalizeBlock(c, " ")).join("\n")}
|
|
3090
|
+
});`;
|
|
3091
|
+
const icpBlockCode = icps.length ? `beforeEach(() => {
|
|
3092
|
+
// Auto-generated Cypress interceptors
|
|
3093
|
+
${icps.map((c) => normalizeBlock(c, " ")).join("\n")}
|
|
3094
|
+
});` : "";
|
|
3095
|
+
const notesHtml = expanded && test.notes ? `<p class="test-notes">${escHtml(test.notes)}</p>` : "";
|
|
2901
3096
|
const body = expanded ? `
|
|
2902
3097
|
<div class="row-body">
|
|
2903
|
-
|
|
2904
|
-
<
|
|
2905
|
-
${
|
|
2906
|
-
<div class="section-title" style="margin-top:8px">${t("TEST_EDITOR.SECTION_INTERCEPTORS")}</div>
|
|
2907
|
-
${icps.map(escHtml).join("<br>")}
|
|
2908
|
-
</div>` : ""}
|
|
2909
|
-
<div class="copy-row">
|
|
2910
|
-
<button class="btn-icon" data-action="copy-cmds" data-idx="${i}">${t("TEST_EDITOR.COPY_CMDS_BTN")}</button>
|
|
2911
|
-
${icps.length ? `<button class="btn-icon" data-action="copy-icps" data-idx="${i}">${t("TEST_EDITOR.COPY_ICPS_BTN")}</button>` : ""}
|
|
2912
|
-
</div>
|
|
3098
|
+
${notesHtml}
|
|
3099
|
+
<pre class="code-preview">${syntaxHighlight(itBlockCode)}</pre>
|
|
3100
|
+
${icpBlockCode ? `<pre class="code-preview code-preview-icp">${syntaxHighlight(icpBlockCode)}</pre>` : ""}
|
|
2913
3101
|
</div>` : "";
|
|
2914
3102
|
return `
|
|
2915
3103
|
<div class="row${selectedIds.has(test.id) ? " selected-row" : ""}">
|
|
@@ -2918,6 +3106,8 @@ function renderTestEditor(state, t) {
|
|
|
2918
3106
|
<span class="test-name">${escHtml(test.name)}</span>
|
|
2919
3107
|
${tagsHtml}
|
|
2920
3108
|
<span class="test-date">${date}</span>
|
|
3109
|
+
<button class="btn-icon" data-action="copy-cmds" data-idx="${i}" title="${t("TEST_EDITOR.COPY_CMDS_BTN")}">${t("TEST_EDITOR.COPY_CMDS_BTN")}</button>
|
|
3110
|
+
${hasIcps ? `<button class="btn-icon" data-action="copy-icps" data-idx="${i}" title="${t("TEST_EDITOR.COPY_ICPS_BTN")}">${t("TEST_EDITOR.COPY_ICPS_BTN")}</button>` : ""}
|
|
2921
3111
|
<button class="btn-icon btn-del" data-action="delete" data-id="${test.id}" title="${t("TEST_EDITOR.DELETE_TITLE")}">\u{1F5D1}</button>
|
|
2922
3112
|
</div>
|
|
2923
3113
|
${body}
|
|
@@ -3096,7 +3286,7 @@ ${beforeEach}${itBlocks}
|
|
|
3096
3286
|
ev.stopPropagation();
|
|
3097
3287
|
const idx = Number(el.dataset["idx"]);
|
|
3098
3288
|
const t = visible[idx];
|
|
3099
|
-
this.copyToClipboard((this.interceptorsByTest[t?.id] ?? []).join("\n"));
|
|
3289
|
+
this.copyToClipboard((this.interceptorsByTest[t?.id] ?? t?.interceptors ?? []).join("\n"));
|
|
3100
3290
|
});
|
|
3101
3291
|
});
|
|
3102
3292
|
}
|
|
@@ -3209,7 +3399,7 @@ var LANGS = [
|
|
|
3209
3399
|
{ value: "de", label: "Deutsch" }
|
|
3210
3400
|
];
|
|
3211
3401
|
function renderConfiguration(state, t) {
|
|
3212
|
-
const { selectedLanguage, advancedHttpConfig, selectorStrategy, filesystemGranted, cypressFolderName, smartSelectorEnabled } = state;
|
|
3402
|
+
const { selectedLanguage, advancedHttpConfig, selectorStrategy, filesystemGranted, cypressFolderName, smartSelectorEnabled, startHidden } = state;
|
|
3213
3403
|
const langOptions = LANGS.map(
|
|
3214
3404
|
(l) => `<option value="${l.value}" ${selectedLanguage === l.value ? "selected" : ""}>${l.label}</option>`
|
|
3215
3405
|
).join("");
|
|
@@ -3249,6 +3439,18 @@ function renderConfiguration(state, t) {
|
|
|
3249
3439
|
</label>
|
|
3250
3440
|
</div>
|
|
3251
3441
|
|
|
3442
|
+
<!-- Start Hidden -->
|
|
3443
|
+
<div class="card">
|
|
3444
|
+
<div class="card-hd">${t("CONFIG.START_HIDDEN_SECTION")}</div>
|
|
3445
|
+
<label class="check-row">
|
|
3446
|
+
<input type="checkbox" id="start-hidden-toggle" ${startHidden ? "checked" : ""} />
|
|
3447
|
+
<div>
|
|
3448
|
+
<div class="check-title">${t("CONFIG.START_HIDDEN_TITLE")}</div>
|
|
3449
|
+
<div class="check-sub">${t("CONFIG.START_HIDDEN_SUB")}</div>
|
|
3450
|
+
</div>
|
|
3451
|
+
</label>
|
|
3452
|
+
</div>
|
|
3453
|
+
|
|
3252
3454
|
<!-- Selector Strategy -->
|
|
3253
3455
|
<div class="card card-wide">
|
|
3254
3456
|
<div class="card-hd">${t("CONFIG.SELECTOR_SECTION")}</div>
|
|
@@ -3311,6 +3513,7 @@ var ConfigurationElement = class extends HTMLElement {
|
|
|
3311
3513
|
advancedHttpConfig = false;
|
|
3312
3514
|
selectorStrategy = "data-cy";
|
|
3313
3515
|
smartSelectorEnabled = true;
|
|
3516
|
+
startHidden = false;
|
|
3314
3517
|
filesystemGranted = false;
|
|
3315
3518
|
cypressFolderName = null;
|
|
3316
3519
|
constructor() {
|
|
@@ -3336,6 +3539,7 @@ var ConfigurationElement = class extends HTMLElement {
|
|
|
3336
3539
|
this.advancedHttpConfig = localStorage.getItem("extendedHttpCommands") === "true";
|
|
3337
3540
|
this.selectorStrategy = config?.["selectorStrategy"] ?? "data-cy";
|
|
3338
3541
|
this.smartSelectorEnabled = config?.["smartSelectorEnabled"] !== "false";
|
|
3542
|
+
this.startHidden = config?.["startHidden"] === "true";
|
|
3339
3543
|
this.filesystemGranted = config?.["allowReadWriteFiles"] === "true";
|
|
3340
3544
|
const handle = config?.["cypressDirectoryHandle"];
|
|
3341
3545
|
this.cypressFolderName = handle?.name ?? null;
|
|
@@ -3353,6 +3557,12 @@ var ConfigurationElement = class extends HTMLElement {
|
|
|
3353
3557
|
this.persistence.setConfig({ extendedHttpCommands: checked ? "true" : "false" });
|
|
3354
3558
|
this.render();
|
|
3355
3559
|
}
|
|
3560
|
+
async onStartHiddenChange(checked) {
|
|
3561
|
+
this.startHidden = checked;
|
|
3562
|
+
await this.persistence.setConfig({ startHidden: checked ? "true" : "false" });
|
|
3563
|
+
this.dispatchEvent(new CustomEvent("starthiddenchange", { detail: checked, bubbles: true, composed: true }));
|
|
3564
|
+
this.render();
|
|
3565
|
+
}
|
|
3356
3566
|
async onSmartSelectorChange(enabled) {
|
|
3357
3567
|
this.smartSelectorEnabled = enabled;
|
|
3358
3568
|
await this.persistence.setConfig({ smartSelectorEnabled: enabled ? "true" : "false" });
|
|
@@ -3413,7 +3623,8 @@ var ConfigurationElement = class extends HTMLElement {
|
|
|
3413
3623
|
selectorStrategy: this.selectorStrategy,
|
|
3414
3624
|
filesystemGranted: this.filesystemGranted,
|
|
3415
3625
|
cypressFolderName: this.cypressFolderName,
|
|
3416
|
-
smartSelectorEnabled: this.smartSelectorEnabled
|
|
3626
|
+
smartSelectorEnabled: this.smartSelectorEnabled,
|
|
3627
|
+
startHidden: this.startHidden
|
|
3417
3628
|
}, this.t.bind(this))}`;
|
|
3418
3629
|
;
|
|
3419
3630
|
this.shadow.getElementById("lang-select").addEventListener(
|
|
@@ -3428,6 +3639,10 @@ var ConfigurationElement = class extends HTMLElement {
|
|
|
3428
3639
|
"change",
|
|
3429
3640
|
(e) => this.onSmartSelectorChange(e.target.checked)
|
|
3430
3641
|
);
|
|
3642
|
+
this.shadow.getElementById("start-hidden-toggle").addEventListener(
|
|
3643
|
+
"change",
|
|
3644
|
+
(e) => this.onStartHiddenChange(e.target.checked)
|
|
3645
|
+
);
|
|
3431
3646
|
this.shadow.getElementById("selector-strategy").addEventListener(
|
|
3432
3647
|
"change",
|
|
3433
3648
|
(e) => this.onSelectorStrategyChange(e.target.value)
|
|
@@ -3500,12 +3715,21 @@ var ADVANCED_TEST_EDITOR_STYLES = `
|
|
|
3500
3715
|
.file-name { font-size: 11px; color: #484f58; margin-bottom: 8px; font-family: monospace; }
|
|
3501
3716
|
pre {
|
|
3502
3717
|
background: #0d1117; padding: 12px; border-radius: 8px;
|
|
3503
|
-
font-size: 11px; color: #c9d1d9;
|
|
3504
|
-
white-space: pre-wrap; word-break: break-all; margin: 0;
|
|
3718
|
+
font-size: 11px; color: #c9d1d9; margin: 0;
|
|
3505
3719
|
font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
|
|
3506
|
-
line-height: 1.7;
|
|
3507
|
-
|
|
3720
|
+
line-height: 1.7; border: 1px solid #21262d;
|
|
3721
|
+
white-space: pre; overflow-x: auto; overflow-y: auto;
|
|
3722
|
+
scrollbar-width: thin; scrollbar-color: #30363d transparent;
|
|
3508
3723
|
}
|
|
3724
|
+
pre::-webkit-scrollbar { width: 4px; height: 4px; }
|
|
3725
|
+
pre::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }
|
|
3726
|
+
.pre-block { font-size: 10.5px; }
|
|
3727
|
+
.pre-icp .sh-str { color: #85e89d; }
|
|
3728
|
+
.sh-kw { color: #ff7b72; }
|
|
3729
|
+
.sh-bi { color: #d2a8ff; }
|
|
3730
|
+
.sh-str { color: #a5d6ff; }
|
|
3731
|
+
.sh-cmt { color: #8b949e; font-style: italic; }
|
|
3732
|
+
.sh-num { color: #79c0ff; }
|
|
3509
3733
|
.footer {
|
|
3510
3734
|
padding: 10px 14px; border-top: 1px solid #21262d;
|
|
3511
3735
|
display: flex; gap: 8px; justify-content: flex-end; background: #161b22;
|
|
@@ -3521,6 +3745,12 @@ var ADVANCED_TEST_EDITOR_STYLES = `
|
|
|
3521
3745
|
.btn-save:hover { background: #1f6feb; border-color: #1f6feb; color: #fff; }
|
|
3522
3746
|
.btn-save:disabled { background: #21262d; border-color: #30363d; color: #8b949e; }
|
|
3523
3747
|
.placeholder { color: #484f58; font-size: 13px; padding: 28px; text-align: center; }
|
|
3748
|
+
.test-notes {
|
|
3749
|
+
margin: 0 0 10px; padding: 8px 12px;
|
|
3750
|
+
background: rgba(47,129,247,0.06); border-left: 3px solid rgba(47,129,247,0.4);
|
|
3751
|
+
border-radius: 0 6px 6px 0; font-size: 12px; color: #8b949e;
|
|
3752
|
+
line-height: 1.6; white-space: pre-wrap; word-break: break-word;
|
|
3753
|
+
}
|
|
3524
3754
|
.block-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
|
|
3525
3755
|
.btn-copy {
|
|
3526
3756
|
padding: 3px 10px; border: 1px solid #30363d; border-radius: 5px; cursor: pointer;
|
|
@@ -3574,23 +3804,24 @@ function renderNoPermission(needsReauth, t) {
|
|
|
3574
3804
|
</div>`;
|
|
3575
3805
|
}
|
|
3576
3806
|
function renderAdvancedEditor(state, t) {
|
|
3577
|
-
const { e2eTree, selectedFile, selectedFileContent, testItBlock, interceptorsBlock, saveButtonEnabled, isCreatingFile, collapsedDirs, sidebarWidth } = state;
|
|
3807
|
+
const { e2eTree, selectedFile, selectedFileContent, testItBlock, interceptorsBlock, testNotes, saveButtonEnabled, isCreatingFile, collapsedDirs, sidebarWidth } = state;
|
|
3578
3808
|
const treeHtml = e2eTree.length ? renderTree(e2eTree, selectedFile, collapsedDirs) : `<div class="tree-item" style="color:#6c7a99">${t("ADVANCED_EDITOR.NO_FILES")}</div>`;
|
|
3579
3809
|
const contentHtml = selectedFileContent ? `<div class="file-name">\u{1F4C4} ${escHtml(selectedFile?.name ?? "")}</div>
|
|
3580
|
-
<pre>${
|
|
3810
|
+
<pre class="pre-file">${syntaxHighlight(selectedFileContent.slice(0, 6e3))}${selectedFileContent.length > 6e3 ? "\n..." : ""}</pre>` : `<div class="placeholder">${t("ADVANCED_EDITOR.SELECT_FILE")}</div>`;
|
|
3811
|
+
const notesHtml = testItBlock && testNotes ? `<p class="test-notes">${escHtml(testNotes)}</p>` : "";
|
|
3581
3812
|
const itHtml = testItBlock ? `<div style="margin-top:10px">
|
|
3582
3813
|
<div class="file-name block-header">
|
|
3583
3814
|
<span>${t("ADVANCED_EDITOR.IT_LABEL")}</span>
|
|
3584
3815
|
<button id="btn-copy-it" class="btn-copy">${t("ADVANCED_EDITOR.COPY_IT_BTN")}</button>
|
|
3585
3816
|
</div>
|
|
3586
|
-
<pre
|
|
3817
|
+
<pre class="pre-block">${syntaxHighlight(testItBlock.slice(0, 3e3))}</pre>
|
|
3587
3818
|
</div>` : "";
|
|
3588
3819
|
const interceptorsHtml = interceptorsBlock ? `<div style="margin-top:10px">
|
|
3589
3820
|
<div class="file-name block-header">
|
|
3590
3821
|
<span>${t("ADVANCED_EDITOR.BEFORE_EACH_LABEL")}</span>
|
|
3591
3822
|
<button id="btn-copy-interceptors" class="btn-copy">${t("ADVANCED_EDITOR.COPY_ICP_BTN")}</button>
|
|
3592
3823
|
</div>
|
|
3593
|
-
<pre
|
|
3824
|
+
<pre class="pre-block pre-icp">${syntaxHighlight(interceptorsBlock.slice(0, 3e3))}</pre>
|
|
3594
3825
|
</div>` : "";
|
|
3595
3826
|
const newFileForm = isCreatingFile ? `<div class="new-file-form">
|
|
3596
3827
|
<input id="input-new-file" type="text" placeholder="${escHtml(t("ADVANCED_EDITOR.NEW_FILE_PLACEHOLDER"))}" autocomplete="off" />
|
|
@@ -3614,7 +3845,7 @@ function renderAdvancedEditor(state, t) {
|
|
|
3614
3845
|
</div>
|
|
3615
3846
|
<div id="resize-handle" class="resize-handle"></div>
|
|
3616
3847
|
<div class="main">
|
|
3617
|
-
<div class="content-area">${contentHtml}${itHtml}${interceptorsHtml}</div>
|
|
3848
|
+
<div class="content-area">${contentHtml}${notesHtml}${itHtml}${interceptorsHtml}</div>
|
|
3618
3849
|
<div class="footer">
|
|
3619
3850
|
<button id="btn-save" class="btn-save"
|
|
3620
3851
|
${!saveButtonEnabled || !testItBlock ? "disabled" : ""}>
|
|
@@ -3675,6 +3906,7 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3675
3906
|
selectedFileContent = null;
|
|
3676
3907
|
testItBlock = "";
|
|
3677
3908
|
interceptorsBlock = "";
|
|
3909
|
+
testNotes = "";
|
|
3678
3910
|
isPreviewMode = false;
|
|
3679
3911
|
previewFileName = null;
|
|
3680
3912
|
previewFileContent = null;
|
|
@@ -3768,7 +4000,8 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3768
4000
|
if (this.interceptorsBlock) {
|
|
3769
4001
|
content = this.transformationService.insertBeforeEach(content, this.interceptorsBlock);
|
|
3770
4002
|
}
|
|
3771
|
-
|
|
4003
|
+
const comment = this.testNotes ? this.transformationService.buildBlockComment(this.testNotes) + "\n" : "";
|
|
4004
|
+
content = this.transformationService.insertItBlock(content, comment + this.testItBlock);
|
|
3772
4005
|
if (!content) return;
|
|
3773
4006
|
const writable = await this.selectedFileHandle.createWritable();
|
|
3774
4007
|
await writable.write(content);
|
|
@@ -3795,9 +4028,11 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3795
4028
|
if (test) {
|
|
3796
4029
|
this.testItBlock = test.itBlock ?? "";
|
|
3797
4030
|
this.interceptorsBlock = test.interceptorsBlock ?? "";
|
|
4031
|
+
this.testNotes = test.notes ?? "";
|
|
3798
4032
|
} else {
|
|
3799
4033
|
this.testItBlock = "";
|
|
3800
4034
|
this.interceptorsBlock = "";
|
|
4035
|
+
this.testNotes = "";
|
|
3801
4036
|
}
|
|
3802
4037
|
this.render();
|
|
3803
4038
|
}
|
|
@@ -3887,6 +4122,7 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3887
4122
|
selectedFileContent: this.selectedFileContent,
|
|
3888
4123
|
testItBlock: this.testItBlock,
|
|
3889
4124
|
interceptorsBlock: this.interceptorsBlock,
|
|
4125
|
+
testNotes: this.testNotes,
|
|
3890
4126
|
saveButtonEnabled: this.saveButtonEnabled,
|
|
3891
4127
|
isCreatingFile: this.isCreatingFile,
|
|
3892
4128
|
collapsedDirs: this.collapsedDirs,
|
|
@@ -4454,6 +4690,7 @@ var LibE2eRecorderElement = class extends HTMLElement {
|
|
|
4454
4690
|
recording;
|
|
4455
4691
|
persistence;
|
|
4456
4692
|
translation;
|
|
4693
|
+
isVisible = false;
|
|
4457
4694
|
isRecording = false;
|
|
4458
4695
|
isPaused = false;
|
|
4459
4696
|
cypressCommands = [];
|
|
@@ -4488,6 +4725,7 @@ var LibE2eRecorderElement = class extends HTMLElement {
|
|
|
4488
4725
|
this.initSelectorStrategy();
|
|
4489
4726
|
this.initSubscriptions();
|
|
4490
4727
|
this.render();
|
|
4728
|
+
this.initVisibility();
|
|
4491
4729
|
this.keydownHandler = (e) => this.handleKeyboardEvent(e);
|
|
4492
4730
|
window.addEventListener("keydown", this.keydownHandler);
|
|
4493
4731
|
}
|
|
@@ -4553,6 +4791,16 @@ var LibE2eRecorderElement = class extends HTMLElement {
|
|
|
4553
4791
|
document.body.appendChild(picker);
|
|
4554
4792
|
});
|
|
4555
4793
|
}
|
|
4794
|
+
async initVisibility() {
|
|
4795
|
+
if (this.hasAttribute("start-hidden")) {
|
|
4796
|
+
this.isVisible = this.getAttribute("start-hidden") === "false";
|
|
4797
|
+
this.style.display = this.isVisible ? "" : "none";
|
|
4798
|
+
return;
|
|
4799
|
+
}
|
|
4800
|
+
const config = await this.persistence.getGeneralConfig();
|
|
4801
|
+
this.isVisible = config?.["startHidden"] !== "true";
|
|
4802
|
+
this.style.display = this.isVisible ? "" : "none";
|
|
4803
|
+
}
|
|
4556
4804
|
async initSelectorStrategy() {
|
|
4557
4805
|
const config = await this.persistence.getGeneralConfig();
|
|
4558
4806
|
const strategy = config?.["selectorStrategy"];
|
|
@@ -4572,6 +4820,12 @@ var LibE2eRecorderElement = class extends HTMLElement {
|
|
|
4572
4820
|
handleKeyboardEvent(event) {
|
|
4573
4821
|
if (!event.ctrlKey) return;
|
|
4574
4822
|
const key = event.key.toLowerCase();
|
|
4823
|
+
if (key === "e" && event.shiftKey) {
|
|
4824
|
+
event.preventDefault();
|
|
4825
|
+
this.toggleVisibility();
|
|
4826
|
+
return;
|
|
4827
|
+
}
|
|
4828
|
+
if (!this.isVisible) return;
|
|
4575
4829
|
if (key === "r") {
|
|
4576
4830
|
event.preventDefault();
|
|
4577
4831
|
this.toggle();
|
|
@@ -4589,6 +4843,10 @@ var LibE2eRecorderElement = class extends HTMLElement {
|
|
|
4589
4843
|
this.showSettingsDialog();
|
|
4590
4844
|
}
|
|
4591
4845
|
}
|
|
4846
|
+
toggleVisibility() {
|
|
4847
|
+
this.isVisible = !this.isVisible;
|
|
4848
|
+
this.style.display = this.isVisible ? "" : "none";
|
|
4849
|
+
}
|
|
4592
4850
|
// ── recording history (task 5) ────────────────────────────────────────────
|
|
4593
4851
|
saveRecordingHistory() {
|
|
4594
4852
|
if (!this.cypressCommands.length) return;
|
|
@@ -4824,13 +5082,13 @@ cypress/ <span style="color:#484f58">${this.translation.translate("RECOR
|
|
|
4824
5082
|
child.translation = this.translation;
|
|
4825
5083
|
container.appendChild(child);
|
|
4826
5084
|
child.addEventListener("savetest", (e) => {
|
|
4827
|
-
const { description, tags } = e.detail ?? {};
|
|
4828
|
-
this.onSaveTest(description ?? null, tags ?? []);
|
|
5085
|
+
const { description, notes, tags } = e.detail ?? {};
|
|
5086
|
+
this.onSaveTest(description ?? null, tags ?? [], notes ?? "");
|
|
4829
5087
|
import_sweetalert2.default.close();
|
|
4830
5088
|
});
|
|
4831
5089
|
child.addEventListener("saveandexport", (e) => {
|
|
4832
|
-
const { description, tags } = e.detail ?? {};
|
|
4833
|
-
this.onSaveAndExportTest(description ?? null, tags ?? []);
|
|
5090
|
+
const { description, notes, tags } = e.detail ?? {};
|
|
5091
|
+
this.onSaveAndExportTest(description ?? null, tags ?? [], notes ?? "");
|
|
4834
5092
|
import_sweetalert2.default.close();
|
|
4835
5093
|
});
|
|
4836
5094
|
},
|
|
@@ -4861,6 +5119,10 @@ cypress/ <span style="color:#484f58">${this.translation.translate("RECOR
|
|
|
4861
5119
|
child.addEventListener("smartselectorchange", (e) => {
|
|
4862
5120
|
this.smartSelectorEnabled = e.detail;
|
|
4863
5121
|
});
|
|
5122
|
+
child.addEventListener("starthiddenchange", (e) => {
|
|
5123
|
+
this.isVisible = !e.detail;
|
|
5124
|
+
this.style.display = this.isVisible ? "" : "none";
|
|
5125
|
+
});
|
|
4864
5126
|
},
|
|
4865
5127
|
willClose: () => {
|
|
4866
5128
|
this.isSettingsDialogOpen = false;
|
|
@@ -4972,18 +5234,18 @@ cypress/ <span style="color:#484f58">${this.translation.translate("RECOR
|
|
|
4972
5234
|
this.resizePopup();
|
|
4973
5235
|
}
|
|
4974
5236
|
// ── save handlers ─────────────────────────────────────────────────────────
|
|
4975
|
-
async onSaveTest(description, tags = []) {
|
|
5237
|
+
async onSaveTest(description, tags = [], notes = "") {
|
|
4976
5238
|
if (description) {
|
|
4977
|
-
await this.persistence.insertTest(description, this.cypressCommands, this.interceptors, tags);
|
|
5239
|
+
await this.persistence.insertTest(description, this.cypressCommands, this.interceptors, tags, notes);
|
|
4978
5240
|
this.recording.clearCommands();
|
|
4979
5241
|
this.clearRecordingHistory();
|
|
4980
5242
|
this.cypressCommands = [];
|
|
4981
5243
|
this.interceptors = [];
|
|
4982
5244
|
}
|
|
4983
5245
|
}
|
|
4984
|
-
async onSaveAndExportTest(description, tags = []) {
|
|
5246
|
+
async onSaveAndExportTest(description, tags = [], notes = "") {
|
|
4985
5247
|
if (description) {
|
|
4986
|
-
const id = await this.persistence.insertTest(description, this.cypressCommands, this.interceptors, tags);
|
|
5248
|
+
const id = await this.persistence.insertTest(description, this.cypressCommands, this.interceptors, tags, notes);
|
|
4987
5249
|
this.recording.clearCommands();
|
|
4988
5250
|
this.clearRecordingHistory();
|
|
4989
5251
|
this.cypressCommands = [];
|
|
@@ -5010,6 +5272,7 @@ cypress/ <span style="color:#484f58">${this.translation.translate("RECOR
|
|
|
5010
5272
|
render() {
|
|
5011
5273
|
const rec = this.isRecording;
|
|
5012
5274
|
const paused = this.isPaused;
|
|
5275
|
+
this.style.display = this.isVisible ? "" : "none";
|
|
5013
5276
|
this.shadow.innerHTML = `<style>${getRecorderStyles(rec, paused)}</style>${renderRecorderWidget(rec, paused, this.translation.translate.bind(this.translation))}`;
|
|
5014
5277
|
this.shadow.querySelector('[data-action="toggle"]')?.addEventListener("click", () => this.toggle());
|
|
5015
5278
|
this.shadow.querySelector('[data-action="pause"]')?.addEventListener("click", () => this.togglePause());
|