lib-e2e-cypress-for-dummys-ts 0.1.0 → 0.2.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 +7 -0
- package/dist/index.cjs +241 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +241 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -323,20 +323,28 @@ declare class AdvancedTestEditorElement extends HTMLElement {
|
|
|
323
323
|
isPreviewMode: boolean;
|
|
324
324
|
previewFileName: string | null;
|
|
325
325
|
previewFileContent: string | null;
|
|
326
|
+
isCreatingFile: boolean;
|
|
327
|
+
collapsedDirs: Set<string>;
|
|
328
|
+
sidebarWidth: number;
|
|
326
329
|
private hasPermission;
|
|
327
330
|
private needsReauth;
|
|
328
331
|
private _dirHandle;
|
|
332
|
+
private _e2eHandle;
|
|
329
333
|
constructor();
|
|
330
334
|
connectedCallback(): void;
|
|
331
335
|
private t;
|
|
332
336
|
private init;
|
|
333
337
|
getFoldersData(): Promise<void>;
|
|
338
|
+
createNewFile(rawName: string): Promise<void>;
|
|
339
|
+
refreshTree(): Promise<void>;
|
|
334
340
|
saveCommandsToFile(): Promise<void>;
|
|
335
341
|
onFileClick(file: unknown): Promise<void>;
|
|
336
342
|
markFileAsSelected(file: unknown): void;
|
|
337
343
|
loadCypressCommandsForTest(testId: number): Promise<void>;
|
|
338
344
|
copyToClipboard(text: string): void;
|
|
339
345
|
openEditManually(): void;
|
|
346
|
+
toggleDir(path: string): void;
|
|
347
|
+
private setupResizeHandle;
|
|
340
348
|
closePreview(): void;
|
|
341
349
|
private render;
|
|
342
350
|
}
|
|
@@ -369,6 +377,7 @@ declare class FilePreviewElement extends HTMLElement {
|
|
|
369
377
|
|
|
370
378
|
declare class LibE2eRecorderElement extends HTMLElement {
|
|
371
379
|
private shadow;
|
|
380
|
+
private _isDisabled;
|
|
372
381
|
private keydownHandler;
|
|
373
382
|
private recordingUnsub?;
|
|
374
383
|
private commandsUnsub?;
|
package/dist/index.d.ts
CHANGED
|
@@ -323,20 +323,28 @@ declare class AdvancedTestEditorElement extends HTMLElement {
|
|
|
323
323
|
isPreviewMode: boolean;
|
|
324
324
|
previewFileName: string | null;
|
|
325
325
|
previewFileContent: string | null;
|
|
326
|
+
isCreatingFile: boolean;
|
|
327
|
+
collapsedDirs: Set<string>;
|
|
328
|
+
sidebarWidth: number;
|
|
326
329
|
private hasPermission;
|
|
327
330
|
private needsReauth;
|
|
328
331
|
private _dirHandle;
|
|
332
|
+
private _e2eHandle;
|
|
329
333
|
constructor();
|
|
330
334
|
connectedCallback(): void;
|
|
331
335
|
private t;
|
|
332
336
|
private init;
|
|
333
337
|
getFoldersData(): Promise<void>;
|
|
338
|
+
createNewFile(rawName: string): Promise<void>;
|
|
339
|
+
refreshTree(): Promise<void>;
|
|
334
340
|
saveCommandsToFile(): Promise<void>;
|
|
335
341
|
onFileClick(file: unknown): Promise<void>;
|
|
336
342
|
markFileAsSelected(file: unknown): void;
|
|
337
343
|
loadCypressCommandsForTest(testId: number): Promise<void>;
|
|
338
344
|
copyToClipboard(text: string): void;
|
|
339
345
|
openEditManually(): void;
|
|
346
|
+
toggleDir(path: string): void;
|
|
347
|
+
private setupResizeHandle;
|
|
340
348
|
closePreview(): void;
|
|
341
349
|
private render;
|
|
342
350
|
}
|
|
@@ -369,6 +377,7 @@ declare class FilePreviewElement extends HTMLElement {
|
|
|
369
377
|
|
|
370
378
|
declare class LibE2eRecorderElement extends HTMLElement {
|
|
371
379
|
private shadow;
|
|
380
|
+
private _isDisabled;
|
|
372
381
|
private keydownHandler;
|
|
373
382
|
private recordingUnsub?;
|
|
374
383
|
private commandsUnsub?;
|
package/dist/index.js
CHANGED
|
@@ -180,7 +180,12 @@ var I18N_ES = {
|
|
|
180
180
|
COPY_ICP_BTN: "\u{1F4CB} Copiar interceptores",
|
|
181
181
|
INSERT_BTN: "\u{1F4BE} Insertar en archivo",
|
|
182
182
|
EDIT_MANUAL_BTN: "\u270F\uFE0F Editar manualmente",
|
|
183
|
-
CLOSE_BTN: "\u2715 Cerrar"
|
|
183
|
+
CLOSE_BTN: "\u2715 Cerrar",
|
|
184
|
+
NEW_FILE_BTN: "+ Nuevo archivo",
|
|
185
|
+
REFRESH_BTN: "\u21BB Actualizar",
|
|
186
|
+
NEW_FILE_PLACEHOLDER: "nombre-del-test",
|
|
187
|
+
NEW_FILE_CONFIRM: "Crear",
|
|
188
|
+
NEW_FILE_CANCEL: "Cancelar"
|
|
184
189
|
},
|
|
185
190
|
FILE_PREVIEW: {
|
|
186
191
|
NO_FILE: "Sin archivo",
|
|
@@ -337,7 +342,12 @@ var I18N_EN = {
|
|
|
337
342
|
COPY_ICP_BTN: "\u{1F4CB} Copy interceptors",
|
|
338
343
|
INSERT_BTN: "\u{1F4BE} Insert into file",
|
|
339
344
|
EDIT_MANUAL_BTN: "\u270F\uFE0F Edit manually",
|
|
340
|
-
CLOSE_BTN: "\u2715 Close"
|
|
345
|
+
CLOSE_BTN: "\u2715 Close",
|
|
346
|
+
NEW_FILE_BTN: "+ New file",
|
|
347
|
+
REFRESH_BTN: "\u21BB Refresh",
|
|
348
|
+
NEW_FILE_PLACEHOLDER: "test-name",
|
|
349
|
+
NEW_FILE_CONFIRM: "Create",
|
|
350
|
+
NEW_FILE_CANCEL: "Cancel"
|
|
341
351
|
},
|
|
342
352
|
FILE_PREVIEW: {
|
|
343
353
|
NO_FILE: "No file",
|
|
@@ -494,7 +504,12 @@ var I18N_FR = {
|
|
|
494
504
|
COPY_ICP_BTN: "\u{1F4CB} Copier les intercepteurs",
|
|
495
505
|
INSERT_BTN: "\u{1F4BE} Ins\xE9rer dans le fichier",
|
|
496
506
|
EDIT_MANUAL_BTN: "\u270F\uFE0F \xC9diter manuellement",
|
|
497
|
-
CLOSE_BTN: "\u2715 Fermer"
|
|
507
|
+
CLOSE_BTN: "\u2715 Fermer",
|
|
508
|
+
NEW_FILE_BTN: "+ Nouveau fichier",
|
|
509
|
+
REFRESH_BTN: "\u21BB Actualiser",
|
|
510
|
+
NEW_FILE_PLACEHOLDER: "nom-du-test",
|
|
511
|
+
NEW_FILE_CONFIRM: "Cr\xE9er",
|
|
512
|
+
NEW_FILE_CANCEL: "Annuler"
|
|
498
513
|
},
|
|
499
514
|
FILE_PREVIEW: {
|
|
500
515
|
NO_FILE: "Sans fichier",
|
|
@@ -651,7 +666,12 @@ var I18N_IT = {
|
|
|
651
666
|
COPY_ICP_BTN: "\u{1F4CB} Copia interceptor",
|
|
652
667
|
INSERT_BTN: "\u{1F4BE} Inserisci nel file",
|
|
653
668
|
EDIT_MANUAL_BTN: "\u270F\uFE0F Modifica manualmente",
|
|
654
|
-
CLOSE_BTN: "\u2715 Chiudi"
|
|
669
|
+
CLOSE_BTN: "\u2715 Chiudi",
|
|
670
|
+
NEW_FILE_BTN: "+ Nuovo file",
|
|
671
|
+
REFRESH_BTN: "\u21BB Aggiorna",
|
|
672
|
+
NEW_FILE_PLACEHOLDER: "nome-del-test",
|
|
673
|
+
NEW_FILE_CONFIRM: "Crea",
|
|
674
|
+
NEW_FILE_CANCEL: "Annulla"
|
|
655
675
|
},
|
|
656
676
|
FILE_PREVIEW: {
|
|
657
677
|
NO_FILE: "Nessun file",
|
|
@@ -808,7 +828,12 @@ var I18N_DE = {
|
|
|
808
828
|
COPY_ICP_BTN: "\u{1F4CB} Interceptors kopieren",
|
|
809
829
|
INSERT_BTN: "\u{1F4BE} In Datei einf\xFCgen",
|
|
810
830
|
EDIT_MANUAL_BTN: "\u270F\uFE0F Manuell bearbeiten",
|
|
811
|
-
CLOSE_BTN: "\u2715 Schlie\xDFen"
|
|
831
|
+
CLOSE_BTN: "\u2715 Schlie\xDFen",
|
|
832
|
+
NEW_FILE_BTN: "+ Neue Datei",
|
|
833
|
+
REFRESH_BTN: "\u21BB Aktualisieren",
|
|
834
|
+
NEW_FILE_PLACEHOLDER: "test-name",
|
|
835
|
+
NEW_FILE_CONFIRM: "Erstellen",
|
|
836
|
+
NEW_FILE_CANCEL: "Abbrechen"
|
|
812
837
|
},
|
|
813
838
|
FILE_PREVIEW: {
|
|
814
839
|
NO_FILE: "Keine Datei",
|
|
@@ -2944,26 +2969,38 @@ var ADVANCED_TEST_EDITOR_STYLES = `
|
|
|
2944
2969
|
* { box-sizing: border-box; }
|
|
2945
2970
|
.layout { display: flex; flex: 1; min-height: 0; }
|
|
2946
2971
|
.sidebar {
|
|
2947
|
-
|
|
2948
|
-
|
|
2972
|
+
border-right: none; display: flex; flex-direction: column;
|
|
2973
|
+
background: #0d1117; flex-shrink: 0; min-width: 140px; max-width: 500px;
|
|
2974
|
+
}
|
|
2975
|
+
.tree-scroll {
|
|
2976
|
+
flex: 1; overflow-y: auto; padding: 6px 4px;
|
|
2949
2977
|
scrollbar-width: thin; scrollbar-color: #30363d transparent;
|
|
2950
2978
|
}
|
|
2951
|
-
.
|
|
2952
|
-
.
|
|
2953
|
-
.
|
|
2979
|
+
.tree-scroll::-webkit-scrollbar { width: 4px; }
|
|
2980
|
+
.tree-scroll::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }
|
|
2981
|
+
.resize-handle {
|
|
2982
|
+
width: 4px; background: #21262d; cursor: col-resize; flex-shrink: 0;
|
|
2983
|
+
transition: background 0.15s;
|
|
2984
|
+
}
|
|
2985
|
+
.resize-handle:hover, .resize-handle.dragging { background: #2f81f7; }
|
|
2986
|
+
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #161b22; min-width: 0; }
|
|
2954
2987
|
.no-perm {
|
|
2955
2988
|
padding: 28px; color: #484f58; font-size: 13px; text-align: center;
|
|
2956
2989
|
display: flex; flex-direction: column; align-items: center; gap: 12px; line-height: 1.6;
|
|
2957
2990
|
}
|
|
2958
2991
|
.tree-item {
|
|
2959
|
-
padding:
|
|
2992
|
+
padding: 4px 6px; border-radius: 4px; cursor: pointer;
|
|
2960
2993
|
font-size: 12px; color: #8b949e; white-space: nowrap;
|
|
2961
2994
|
overflow: hidden; text-overflow: ellipsis;
|
|
2962
2995
|
transition: background 0.12s, color 0.12s;
|
|
2996
|
+
display: flex; align-items: center; gap: 4px; user-select: none;
|
|
2963
2997
|
}
|
|
2964
2998
|
.tree-item:hover { background: #161b22; color: #c9d1d9; }
|
|
2965
2999
|
.tree-item.selected { background: rgba(47,129,247,0.12); color: #2f81f7; }
|
|
2966
3000
|
.tree-item.dir { color: #e3b341; font-weight: 600; }
|
|
3001
|
+
.tree-item.dir:hover { background: rgba(227,179,65,0.08); color: #f0c040; }
|
|
3002
|
+
.dir-arrow { font-size: 8px; color: #484f58; width: 10px; flex-shrink: 0; line-height: 1; }
|
|
3003
|
+
.tree-connector { display: block; width: 1px; background: #21262d; margin-left: 13px; height: 100%; }
|
|
2967
3004
|
.content-area {
|
|
2968
3005
|
flex: 1; padding: 12px 14px; overflow-y: auto;
|
|
2969
3006
|
scrollbar-width: thin; scrollbar-color: #30363d transparent;
|
|
@@ -3001,6 +3038,34 @@ var ADVANCED_TEST_EDITOR_STYLES = `
|
|
|
3001
3038
|
transition: background 0.12s, color 0.12s; white-space: nowrap; flex-shrink: 0;
|
|
3002
3039
|
}
|
|
3003
3040
|
.btn-copy:hover { background: #30363d; color: #e6edf3; }
|
|
3041
|
+
.sidebar-toolbar {
|
|
3042
|
+
display: flex; gap: 4px; padding: 6px 6px 4px;
|
|
3043
|
+
border-bottom: 1px solid #21262d; flex-shrink: 0; background: #0d1117;
|
|
3044
|
+
}
|
|
3045
|
+
.btn-toolbar {
|
|
3046
|
+
flex: 1; padding: 4px 6px; border: 1px solid #30363d; border-radius: 5px; cursor: pointer;
|
|
3047
|
+
font-size: 10px; font-weight: 500; background: #161b22; color: #8b949e;
|
|
3048
|
+
transition: background 0.12s, color 0.12s; white-space: nowrap; overflow: hidden;
|
|
3049
|
+
text-overflow: ellipsis;
|
|
3050
|
+
}
|
|
3051
|
+
.btn-toolbar:hover { background: #30363d; color: #e6edf3; }
|
|
3052
|
+
.btn-toolbar.btn-new { color: #3fb950; border-color: #238636; }
|
|
3053
|
+
.btn-toolbar.btn-new:hover { background: #238636; color: #fff; }
|
|
3054
|
+
.new-file-form {
|
|
3055
|
+
padding: 6px; border-bottom: 1px solid #21262d; display: flex; flex-direction: column; gap: 4px;
|
|
3056
|
+
}
|
|
3057
|
+
.new-file-form input {
|
|
3058
|
+
width: 100%; padding: 4px 7px; background: #0d1117; border: 1px solid #30363d;
|
|
3059
|
+
border-radius: 5px; color: #e6edf3; font-size: 11px; font-family: monospace;
|
|
3060
|
+
outline: none;
|
|
3061
|
+
}
|
|
3062
|
+
.new-file-form input:focus { border-color: #2f81f7; }
|
|
3063
|
+
.new-file-form .ext { font-size: 9px; color: #484f58; padding: 0 2px; }
|
|
3064
|
+
.new-file-actions { display: flex; gap: 4px; }
|
|
3065
|
+
.btn-confirm { flex: 1; padding: 3px 6px; border: 1px solid #238636; border-radius: 5px; cursor: pointer; font-size: 10px; font-weight: 500; background: #238636; color: #fff; transition: background 0.12s; }
|
|
3066
|
+
.btn-confirm:hover { background: #2ea043; }
|
|
3067
|
+
.btn-cancel-form { flex: 1; padding: 3px 6px; border: 1px solid #30363d; border-radius: 5px; cursor: pointer; font-size: 10px; font-weight: 500; background: #21262d; color: #8b949e; transition: background 0.12s; }
|
|
3068
|
+
.btn-cancel-form:hover { background: #30363d; color: #e6edf3; }
|
|
3004
3069
|
`;
|
|
3005
3070
|
|
|
3006
3071
|
// src/components/advanced-test-editor/advanced-test-editor.template.ts
|
|
@@ -3018,8 +3083,8 @@ function renderNoPermission(needsReauth, t) {
|
|
|
3018
3083
|
</div>`;
|
|
3019
3084
|
}
|
|
3020
3085
|
function renderAdvancedEditor(state, t) {
|
|
3021
|
-
const { e2eTree, selectedFile, selectedFileContent, testItBlock, interceptorsBlock, saveButtonEnabled } = state;
|
|
3022
|
-
const treeHtml = e2eTree.length ? renderTree(e2eTree, selectedFile) : `<div class="tree-item" style="color:#6c7a99">${t("ADVANCED_EDITOR.NO_FILES")}</div>`;
|
|
3086
|
+
const { e2eTree, selectedFile, selectedFileContent, testItBlock, interceptorsBlock, saveButtonEnabled, isCreatingFile, collapsedDirs, sidebarWidth } = state;
|
|
3087
|
+
const treeHtml = e2eTree.length ? renderTree(e2eTree, selectedFile, collapsedDirs) : `<div class="tree-item" style="color:#6c7a99">${t("ADVANCED_EDITOR.NO_FILES")}</div>`;
|
|
3023
3088
|
const contentHtml = selectedFileContent ? `<div class="file-name">\u{1F4C4} ${escHtml(selectedFile?.name ?? "")}</div>
|
|
3024
3089
|
<pre>${escHtml(selectedFileContent.slice(0, 4e3))}${selectedFileContent.length > 4e3 ? "\n..." : ""}</pre>` : `<div class="placeholder">${t("ADVANCED_EDITOR.SELECT_FILE")}</div>`;
|
|
3025
3090
|
const itHtml = testItBlock ? `<div style="margin-top:10px">
|
|
@@ -3036,9 +3101,27 @@ function renderAdvancedEditor(state, t) {
|
|
|
3036
3101
|
</div>
|
|
3037
3102
|
<pre style="max-height:120px;font-size:10.5px;color:#3fb950">${escHtml(interceptorsBlock.slice(0, 500))}</pre>
|
|
3038
3103
|
</div>` : "";
|
|
3104
|
+
const newFileForm = isCreatingFile ? `<div class="new-file-form">
|
|
3105
|
+
<input id="input-new-file" type="text" placeholder="${escHtml(t("ADVANCED_EDITOR.NEW_FILE_PLACEHOLDER"))}" autocomplete="off" />
|
|
3106
|
+
<span class="ext">.cy.ts</span>
|
|
3107
|
+
<div class="new-file-actions">
|
|
3108
|
+
<button id="btn-new-file-confirm" class="btn-confirm">${t("ADVANCED_EDITOR.NEW_FILE_CONFIRM")}</button>
|
|
3109
|
+
<button id="btn-new-file-cancel" class="btn-cancel-form">${t("ADVANCED_EDITOR.NEW_FILE_CANCEL")}</button>
|
|
3110
|
+
</div>
|
|
3111
|
+
</div>` : "";
|
|
3112
|
+
const toolbar = `
|
|
3113
|
+
<div class="sidebar-toolbar">
|
|
3114
|
+
<button id="btn-new-file" class="btn-toolbar btn-new">${t("ADVANCED_EDITOR.NEW_FILE_BTN")}</button>
|
|
3115
|
+
<button id="btn-refresh" class="btn-toolbar">${t("ADVANCED_EDITOR.REFRESH_BTN")}</button>
|
|
3116
|
+
</div>`;
|
|
3039
3117
|
return `
|
|
3040
3118
|
<div class="layout">
|
|
3041
|
-
<div class="sidebar"
|
|
3119
|
+
<div class="sidebar" style="width:${sidebarWidth}px">
|
|
3120
|
+
${toolbar}
|
|
3121
|
+
${newFileForm}
|
|
3122
|
+
<div class="tree-scroll">${treeHtml}</div>
|
|
3123
|
+
</div>
|
|
3124
|
+
<div id="resize-handle" class="resize-handle"></div>
|
|
3042
3125
|
<div class="main">
|
|
3043
3126
|
<div class="content-area">${contentHtml}${itHtml}${interceptorsHtml}</div>
|
|
3044
3127
|
<div class="footer">
|
|
@@ -3054,16 +3137,24 @@ function renderAdvancedEditor(state, t) {
|
|
|
3054
3137
|
</div>
|
|
3055
3138
|
</div>`;
|
|
3056
3139
|
}
|
|
3057
|
-
function renderTree(nodes, selected, indent = 0) {
|
|
3140
|
+
function renderTree(nodes, selected, collapsedDirs, indent = 0, parentPath = "") {
|
|
3058
3141
|
return nodes.map((n) => {
|
|
3142
|
+
const currentPath = parentPath ? `${parentPath}/${n.name}` : n.name;
|
|
3059
3143
|
const isFile = n.kind === "file";
|
|
3060
|
-
const
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3144
|
+
const pad = `padding-left:${6 + indent * 14}px`;
|
|
3145
|
+
if (!isFile) {
|
|
3146
|
+
const dir = n;
|
|
3147
|
+
const hasChildren = (dir.children?.length ?? 0) > 0;
|
|
3148
|
+
const isCollapsed = collapsedDirs.has(currentPath);
|
|
3149
|
+
const arrow = hasChildren ? isCollapsed ? "\u25B6" : "\u25BC" : "\xB7";
|
|
3150
|
+
const dirHtml = `<div class="tree-item dir" style="${pad}" data-dir-path="${escAttr(currentPath)}">
|
|
3151
|
+
<span class="dir-arrow">${arrow}</span>\u{1F4C1} ${escHtml(n.name)}
|
|
3152
|
+
</div>`;
|
|
3153
|
+
if (!hasChildren || isCollapsed) return dirHtml;
|
|
3154
|
+
return dirHtml + renderTree(dir.children, selected, collapsedDirs, indent + 1, currentPath);
|
|
3066
3155
|
}
|
|
3156
|
+
const isSel = selected?.name === n.name;
|
|
3157
|
+
const cls = `tree-item${isSel ? " selected" : ""}`;
|
|
3067
3158
|
const data = JSON.stringify({ kind: n.kind, name: n.name }).replace(/"/g, """);
|
|
3068
3159
|
return `<div class="${cls}" style="${pad}" data-file="${data}">\u{1F4C4} ${escHtml(n.name)}</div>`;
|
|
3069
3160
|
}).join("");
|
|
@@ -3096,9 +3187,13 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3096
3187
|
isPreviewMode = false;
|
|
3097
3188
|
previewFileName = null;
|
|
3098
3189
|
previewFileContent = null;
|
|
3190
|
+
isCreatingFile = false;
|
|
3191
|
+
collapsedDirs = /* @__PURE__ */ new Set();
|
|
3192
|
+
sidebarWidth = 220;
|
|
3099
3193
|
hasPermission = false;
|
|
3100
3194
|
needsReauth = false;
|
|
3101
3195
|
_dirHandle = null;
|
|
3196
|
+
_e2eHandle = null;
|
|
3102
3197
|
constructor() {
|
|
3103
3198
|
super();
|
|
3104
3199
|
this.shadow = this.attachShadow({ mode: "open" });
|
|
@@ -3140,7 +3235,8 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3140
3235
|
try {
|
|
3141
3236
|
for await (const entry of this._dirHandle.values()) {
|
|
3142
3237
|
if (entry.kind === "directory" && entry.name === "e2e") {
|
|
3143
|
-
|
|
3238
|
+
this._e2eHandle = entry;
|
|
3239
|
+
const tree = await this.transformationService.scanDirectory(this._e2eHandle);
|
|
3144
3240
|
this.e2eTree = tree.children ?? [];
|
|
3145
3241
|
this.render();
|
|
3146
3242
|
return;
|
|
@@ -3149,6 +3245,32 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3149
3245
|
} catch {
|
|
3150
3246
|
}
|
|
3151
3247
|
}
|
|
3248
|
+
async createNewFile(rawName) {
|
|
3249
|
+
if (!this._e2eHandle) return;
|
|
3250
|
+
const name = rawName.trim().replace(/\.cy\.ts$/, "");
|
|
3251
|
+
if (!name) return;
|
|
3252
|
+
const fileName = `${name}.cy.ts`;
|
|
3253
|
+
const template = `describe('${name}', () => {
|
|
3254
|
+
|
|
3255
|
+
it('should ', () => {
|
|
3256
|
+
|
|
3257
|
+
});
|
|
3258
|
+
|
|
3259
|
+
});
|
|
3260
|
+
`;
|
|
3261
|
+
try {
|
|
3262
|
+
const fileHandle = await this._e2eHandle.getFileHandle(fileName, { create: true });
|
|
3263
|
+
const writable = await fileHandle.createWritable();
|
|
3264
|
+
await writable.write(template);
|
|
3265
|
+
await writable.close();
|
|
3266
|
+
} catch {
|
|
3267
|
+
}
|
|
3268
|
+
this.isCreatingFile = false;
|
|
3269
|
+
await this.getFoldersData();
|
|
3270
|
+
}
|
|
3271
|
+
async refreshTree() {
|
|
3272
|
+
await this.getFoldersData();
|
|
3273
|
+
}
|
|
3152
3274
|
async saveCommandsToFile() {
|
|
3153
3275
|
if (!this.selectedFileHandle || !this.selectedFileContent || !this.testItBlock) return;
|
|
3154
3276
|
let content = this.selectedFileContent;
|
|
@@ -3206,6 +3328,44 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3206
3328
|
composed: true
|
|
3207
3329
|
}));
|
|
3208
3330
|
}
|
|
3331
|
+
toggleDir(path) {
|
|
3332
|
+
if (this.collapsedDirs.has(path)) {
|
|
3333
|
+
this.collapsedDirs.delete(path);
|
|
3334
|
+
} else {
|
|
3335
|
+
this.collapsedDirs.add(path);
|
|
3336
|
+
}
|
|
3337
|
+
this.render();
|
|
3338
|
+
}
|
|
3339
|
+
setupResizeHandle() {
|
|
3340
|
+
const handle = this.shadow.getElementById("resize-handle");
|
|
3341
|
+
const sidebar = this.shadow.querySelector(".sidebar");
|
|
3342
|
+
if (!handle || !sidebar) return;
|
|
3343
|
+
let startX = 0;
|
|
3344
|
+
let startWidth = 0;
|
|
3345
|
+
const onMouseMove = (e) => {
|
|
3346
|
+
const delta = e.clientX - startX;
|
|
3347
|
+
const newWidth = Math.max(140, Math.min(500, startWidth + delta));
|
|
3348
|
+
this.sidebarWidth = newWidth;
|
|
3349
|
+
sidebar.style.width = `${newWidth}px`;
|
|
3350
|
+
};
|
|
3351
|
+
const onMouseUp = () => {
|
|
3352
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
3353
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
3354
|
+
document.body.style.cursor = "";
|
|
3355
|
+
document.body.style.userSelect = "";
|
|
3356
|
+
handle.classList.remove("dragging");
|
|
3357
|
+
};
|
|
3358
|
+
handle.addEventListener("mousedown", (e) => {
|
|
3359
|
+
startX = e.clientX;
|
|
3360
|
+
startWidth = sidebar.offsetWidth;
|
|
3361
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
3362
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
3363
|
+
document.body.style.cursor = "col-resize";
|
|
3364
|
+
document.body.style.userSelect = "none";
|
|
3365
|
+
handle.classList.add("dragging");
|
|
3366
|
+
e.preventDefault();
|
|
3367
|
+
});
|
|
3368
|
+
}
|
|
3209
3369
|
closePreview() {
|
|
3210
3370
|
this.isPreviewMode = false;
|
|
3211
3371
|
this.previewFileName = null;
|
|
@@ -3236,7 +3396,10 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3236
3396
|
selectedFileContent: this.selectedFileContent,
|
|
3237
3397
|
testItBlock: this.testItBlock,
|
|
3238
3398
|
interceptorsBlock: this.interceptorsBlock,
|
|
3239
|
-
saveButtonEnabled: this.saveButtonEnabled
|
|
3399
|
+
saveButtonEnabled: this.saveButtonEnabled,
|
|
3400
|
+
isCreatingFile: this.isCreatingFile,
|
|
3401
|
+
collapsedDirs: this.collapsedDirs,
|
|
3402
|
+
sidebarWidth: this.sidebarWidth
|
|
3240
3403
|
}, this.t.bind(this))}`;
|
|
3241
3404
|
this.shadow.querySelectorAll("[data-file]").forEach((el) => {
|
|
3242
3405
|
el.addEventListener("click", () => {
|
|
@@ -3244,11 +3407,41 @@ var AdvancedTestEditorElement = class extends HTMLElement {
|
|
|
3244
3407
|
if (data) this.onFileClick(JSON.parse(data));
|
|
3245
3408
|
});
|
|
3246
3409
|
});
|
|
3410
|
+
this.shadow.querySelectorAll("[data-dir-path]").forEach((el) => {
|
|
3411
|
+
el.addEventListener("click", () => {
|
|
3412
|
+
const path = el.dataset["dirPath"];
|
|
3413
|
+
if (path) this.toggleDir(path);
|
|
3414
|
+
});
|
|
3415
|
+
});
|
|
3416
|
+
this.setupResizeHandle();
|
|
3247
3417
|
this.shadow.getElementById("btn-save")?.addEventListener("click", () => this.saveCommandsToFile());
|
|
3248
3418
|
this.shadow.getElementById("btn-edit")?.addEventListener("click", () => this.openEditManually());
|
|
3249
3419
|
this.shadow.getElementById("btn-copy-it")?.addEventListener("click", () => this.copyToClipboard(this.testItBlock));
|
|
3250
3420
|
this.shadow.getElementById("btn-copy-interceptors")?.addEventListener("click", () => this.copyToClipboard(this.interceptorsBlock));
|
|
3251
3421
|
this.shadow.getElementById("btn-close")?.addEventListener("click", () => this.closePreview());
|
|
3422
|
+
this.shadow.getElementById("btn-new-file")?.addEventListener("click", () => {
|
|
3423
|
+
this.isCreatingFile = !this.isCreatingFile;
|
|
3424
|
+
this.render();
|
|
3425
|
+
if (this.isCreatingFile) this.shadow.getElementById("input-new-file")?.focus();
|
|
3426
|
+
});
|
|
3427
|
+
this.shadow.getElementById("btn-refresh")?.addEventListener("click", () => this.refreshTree());
|
|
3428
|
+
this.shadow.getElementById("btn-new-file-confirm")?.addEventListener("click", () => {
|
|
3429
|
+
const input2 = this.shadow.getElementById("input-new-file");
|
|
3430
|
+
this.createNewFile(input2?.value ?? "");
|
|
3431
|
+
});
|
|
3432
|
+
this.shadow.getElementById("btn-new-file-cancel")?.addEventListener("click", () => {
|
|
3433
|
+
this.isCreatingFile = false;
|
|
3434
|
+
this.render();
|
|
3435
|
+
});
|
|
3436
|
+
const input = this.shadow.getElementById("input-new-file");
|
|
3437
|
+
input?.addEventListener("keydown", (e) => {
|
|
3438
|
+
if (e.key === "Enter") {
|
|
3439
|
+
this.createNewFile(input.value);
|
|
3440
|
+
} else if (e.key === "Escape") {
|
|
3441
|
+
this.isCreatingFile = false;
|
|
3442
|
+
this.render();
|
|
3443
|
+
}
|
|
3444
|
+
});
|
|
3252
3445
|
}
|
|
3253
3446
|
};
|
|
3254
3447
|
if (!customElements.get("advanced-test-editor")) {
|
|
@@ -3755,6 +3948,7 @@ function renderRecorderWidget(rec, paused, t) {
|
|
|
3755
3948
|
// src/components/lib-e2e-recorder/lib-e2e-recorder.ts
|
|
3756
3949
|
var LibE2eRecorderElement = class extends HTMLElement {
|
|
3757
3950
|
shadow;
|
|
3951
|
+
_isDisabled = false;
|
|
3758
3952
|
keydownHandler;
|
|
3759
3953
|
recordingUnsub;
|
|
3760
3954
|
commandsUnsub;
|
|
@@ -3782,6 +3976,10 @@ var LibE2eRecorderElement = class extends HTMLElement {
|
|
|
3782
3976
|
this.shadow = this.attachShadow({ mode: "open" });
|
|
3783
3977
|
}
|
|
3784
3978
|
connectedCallback() {
|
|
3979
|
+
if ("Cypress" in window) {
|
|
3980
|
+
this._isDisabled = true;
|
|
3981
|
+
return;
|
|
3982
|
+
}
|
|
3785
3983
|
if (!this.getAttribute("data-cy")) {
|
|
3786
3984
|
this.setAttribute("data-cy", "lib-e2e-cypress-for-dummys");
|
|
3787
3985
|
}
|
|
@@ -3802,6 +4000,7 @@ var LibE2eRecorderElement = class extends HTMLElement {
|
|
|
3802
4000
|
window.addEventListener("keydown", this.keydownHandler);
|
|
3803
4001
|
}
|
|
3804
4002
|
disconnectedCallback() {
|
|
4003
|
+
if (this._isDisabled) return;
|
|
3805
4004
|
window.removeEventListener("keydown", this.keydownHandler);
|
|
3806
4005
|
this.recordingUnsub?.();
|
|
3807
4006
|
this.commandsUnsub?.();
|
|
@@ -4182,7 +4381,7 @@ cypress/ <span style="color:#484f58">${this.translation.translate("RECOR
|
|
|
4182
4381
|
this.toggleModal("isAdvancedEditorDialogOpen", () => {
|
|
4183
4382
|
Swal.fire({
|
|
4184
4383
|
title: this.translation.translate("MAIN_FRAME.SHOW_ADVANCED_EDITOR"),
|
|
4185
|
-
html: '<div id="advanced-editor-modal-content" style="min-height:
|
|
4384
|
+
html: '<div id="advanced-editor-modal-content" style="flex:1;min-height:0;display:flex;flex-direction:column;padding:0"></div>',
|
|
4186
4385
|
showCloseButton: true,
|
|
4187
4386
|
showConfirmButton: false,
|
|
4188
4387
|
allowOutsideClick: false,
|
|
@@ -4191,6 +4390,20 @@ cypress/ <span style="color:#484f58">${this.translation.translate("RECOR
|
|
|
4191
4390
|
didOpen: () => {
|
|
4192
4391
|
makeSwalDraggable();
|
|
4193
4392
|
setSwal2DataCyAttribute();
|
|
4393
|
+
const popup = Swal.getPopup();
|
|
4394
|
+
if (popup) {
|
|
4395
|
+
popup.style.height = "600px";
|
|
4396
|
+
const htmlContainer = popup.querySelector(".swal2-html-container");
|
|
4397
|
+
if (htmlContainer) {
|
|
4398
|
+
htmlContainer.style.flex = "1";
|
|
4399
|
+
htmlContainer.style.minHeight = "0";
|
|
4400
|
+
htmlContainer.style.overflow = "hidden";
|
|
4401
|
+
htmlContainer.style.padding = "0";
|
|
4402
|
+
htmlContainer.style.margin = "0";
|
|
4403
|
+
htmlContainer.style.display = "flex";
|
|
4404
|
+
htmlContainer.style.flexDirection = "column";
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4194
4407
|
const container = document.getElementById("advanced-editor-modal-content");
|
|
4195
4408
|
if (!container) return;
|
|
4196
4409
|
const child = document.createElement("advanced-test-editor");
|
|
@@ -4218,7 +4431,10 @@ cypress/ <span style="color:#484f58">${this.translation.translate("RECOR
|
|
|
4218
4431
|
this.isAdvancedEditorDialogOpen = false;
|
|
4219
4432
|
}
|
|
4220
4433
|
});
|
|
4221
|
-
|
|
4434
|
+
setTimeout(() => {
|
|
4435
|
+
const popup = Swal.getPopup();
|
|
4436
|
+
if (popup) makeModalResizable(popup, { minWidth: 400, minHeight: 0 });
|
|
4437
|
+
}, 0);
|
|
4222
4438
|
});
|
|
4223
4439
|
}
|
|
4224
4440
|
showFileEditorDialog(handle, content, fileName, testId, itBlock = "", interceptorsBlock = "") {
|