d5-testing-library 2.0.0-alpha.8 → 2.0.0-alpha.9

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  FormEdit
3
- } from "./chunk-XG4PWBWZ.mjs";
3
+ } from "./chunk-ZSUCWPIH.mjs";
4
4
  export {
5
5
  FormEdit as default
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ListForm
3
- } from "./chunk-XG4PWBWZ.mjs";
3
+ } from "./chunk-ZSUCWPIH.mjs";
4
4
  export {
5
5
  ListForm as default
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TreeView
3
- } from "./chunk-XG4PWBWZ.mjs";
3
+ } from "./chunk-ZSUCWPIH.mjs";
4
4
  export {
5
5
  TreeView as default
6
6
  };
@@ -3320,15 +3320,15 @@ async function classDependencyInjector(formType) {
3320
3320
  let SubFormFactoryClass;
3321
3321
  switch (formType) {
3322
3322
  case "1" /* LIST */:
3323
- SubFormFactoryClass = (await import("./ListForm-6TUI3ZIO.mjs")).default;
3323
+ SubFormFactoryClass = (await import("./ListForm-DFVWW3GH.mjs")).default;
3324
3324
  break;
3325
3325
  case "3" /* TREE */:
3326
- SubFormFactoryClass = (await import("./TreeView-YEVTT5PJ.mjs")).default;
3326
+ SubFormFactoryClass = (await import("./TreeView-DQ3DAI2C.mjs")).default;
3327
3327
  break;
3328
3328
  case "2" /* EDIT */:
3329
3329
  case "99" /* FREE_FORM */:
3330
3330
  case "4" /* REPORT */:
3331
- SubFormFactoryClass = (await import("./FormEdit-F4IGBNF3.mjs")).default;
3331
+ SubFormFactoryClass = (await import("./FormEdit-6RENNFXE.mjs")).default;
3332
3332
  break;
3333
3333
  default:
3334
3334
  throw new Error(`Unsupported form type ${formType}`);
@@ -3787,6 +3787,7 @@ var ControlClass = /* @__PURE__ */ ((ControlClass2) => {
3787
3787
  ControlClass2["BooleanSelector"] = "buttons-group";
3788
3788
  ControlClass2["ButtonGroup"] = "button-group-field";
3789
3789
  ControlClass2["HeaderFilterDictionary"] = "header-filter-dictionary";
3790
+ ControlClass2["FileUploader"] = "file-uploader";
3790
3791
  return ControlClass2;
3791
3792
  })(ControlClass || {});
3792
3793
 
@@ -5176,6 +5177,118 @@ var HeaderFilterDictionary = class extends AbstractDXEditorWithInput {
5176
5177
  }
5177
5178
  };
5178
5179
 
5180
+ // src/pageObjects/elements/Editors/FileUploader.ts
5181
+ var FILE_NAME_SELECTOR = ".file-text";
5182
+ var FILE_SIZE_ATTRIBUTE = "data-filesize";
5183
+ var FILE_DATE_ATTRIBUTE = "data-moddate";
5184
+ var FILE_TYPE_ATTRIBUTE = "data-filetype";
5185
+ var SELECT_FILE_BUTTON_SELECTOR = ".select-file-button";
5186
+ var DOWNLOAD_FILE_BUTTON_SELECTOR = ".download-file-button";
5187
+ var METADATA_SELECTOR = ".file-text-file-info-wrapper";
5188
+ var CLEAR_BUTTON_SELECTOR = ".clear-button";
5189
+ var FileUploader = class extends AbstractElementWithParent {
5190
+ constructor(parentCssSelector, elementCssSelector, page) {
5191
+ super(parentCssSelector, elementCssSelector, page);
5192
+ }
5193
+ /**
5194
+ * Returns the metadata container element for the uploaded file.
5195
+ * Returns null when metadata is not rendered or not visible.
5196
+ */
5197
+ async getMedataElement() {
5198
+ const root = this.getFullCssSelector();
5199
+ const locator = this.page.locator(`${root} ${METADATA_SELECTOR}`);
5200
+ if (!await locator.isVisible()) return null;
5201
+ return locator;
5202
+ }
5203
+ /**
5204
+ * Returns the name of the uploaded file, or null if not present.
5205
+ */
5206
+ async getFileName() {
5207
+ const root = this.getFullCssSelector();
5208
+ const locator = this.page.locator(`${root} ${FILE_NAME_SELECTOR}`);
5209
+ if (!await locator.isVisible()) return null;
5210
+ const text = await locator.innerText();
5211
+ return text?.trim() || null;
5212
+ }
5213
+ /**
5214
+ * Returns the size of the uploaded file, or null if not present.
5215
+ */
5216
+ async getFileSize() {
5217
+ const element = await this.getMedataElement();
5218
+ if (!element) return null;
5219
+ const result = (await element.getAttribute(FILE_SIZE_ATTRIBUTE))?.trim();
5220
+ return isNaN(+result) ? null : +result;
5221
+ }
5222
+ /**
5223
+ * Returns the upload/modification date of the file, or null if not present.
5224
+ */
5225
+ async getFileDate() {
5226
+ const element = await this.getMedataElement();
5227
+ if (!element) return null;
5228
+ const fileModDate = (await element.getAttribute(FILE_DATE_ATTRIBUTE))?.trim();
5229
+ return fileModDate ? new Date(fileModDate) : null;
5230
+ }
5231
+ /**
5232
+ * Returns the MIME/content type of the uploaded file from metadata.
5233
+ * Returns null when the type attribute is absent or empty.
5234
+ */
5235
+ async getFileType() {
5236
+ const element = await this.getMedataElement();
5237
+ if (!element) return null;
5238
+ const fileType = (await element.getAttribute(FILE_TYPE_ATTRIBUTE))?.trim();
5239
+ return fileType || null;
5240
+ }
5241
+ /**
5242
+ * Returns current file information: name, size and upload/modification date.
5243
+ * Returns null if no file is uploaded.
5244
+ */
5245
+ async getValue() {
5246
+ const name = await this.getFileName();
5247
+ const size = await this.getFileSize();
5248
+ const date = await this.getFileDate();
5249
+ const type2 = await this.getFileType();
5250
+ if (!name && !size && !date && !type2) return null;
5251
+ return { FileName: name, FileSize: size, FileType: type2, ModDate: date };
5252
+ }
5253
+ /**
5254
+ * Uploads a file by clicking the select-file-button and providing the file path.
5255
+ * @param filePath - Absolute or relative path to the file on disk.
5256
+ */
5257
+ async setValue(filePath) {
5258
+ const root = this.getFullCssSelector();
5259
+ const fileChooserPromise = this.page.waitForEvent("filechooser");
5260
+ await this.page.locator(`${root} ${SELECT_FILE_BUTTON_SELECTOR}`).click();
5261
+ const fileChooser = await fileChooserPromise;
5262
+ await fileChooser.setFiles(filePath);
5263
+ }
5264
+ /**
5265
+ * Downloads the currently uploaded file by clicking the download-file-button.
5266
+ * Returns the suggested file name of the downloaded file.
5267
+ */
5268
+ async download() {
5269
+ const root = this.getFullCssSelector();
5270
+ const buttonLocator = this.page.locator(
5271
+ `${root} ${DOWNLOAD_FILE_BUTTON_SELECTOR}`
5272
+ );
5273
+ if (await buttonLocator.isHidden()) return "";
5274
+ const downloadPromise = this.page.waitForEvent("download");
5275
+ await buttonLocator.click();
5276
+ const download = await downloadPromise;
5277
+ return download.suggestedFilename();
5278
+ }
5279
+ /**
5280
+ * Removes the currently uploaded file by clicking the delete-file-button.
5281
+ * Does nothing if no file is uploaded.
5282
+ */
5283
+ async clear() {
5284
+ if (await this.getValue() === null) return;
5285
+ const root = this.getFullCssSelector();
5286
+ const deleteButton = this.page.locator(`${root} ${CLEAR_BUTTON_SELECTOR}`);
5287
+ if (await deleteButton.isHidden()) return;
5288
+ await deleteButton.click();
5289
+ }
5290
+ };
5291
+
5179
5292
  // src/pageObjects/elements/Editors/editorFactory.ts
5180
5293
  var editorFactory = async (parentCssSelector, elementCssSelector, page) => {
5181
5294
  const elementInstance = new AbstractFormElement(parentCssSelector, elementCssSelector, page);
@@ -5197,6 +5310,8 @@ var editorFactory = async (parentCssSelector, elementCssSelector, page) => {
5197
5310
  return new ButtonGroup(parentCssSelector, elementCssSelector, page);
5198
5311
  if (classString.includes("header-filter-dictionary" /* HeaderFilterDictionary */))
5199
5312
  return new HeaderFilterDictionary(parentCssSelector, elementCssSelector, page);
5313
+ if (classString.includes("file-uploader" /* FileUploader */))
5314
+ return new FileUploader(parentCssSelector, elementCssSelector, page);
5200
5315
  throw new Error("Unknown type of editor. Please write ticket to the support");
5201
5316
  };
5202
5317
 
@@ -5351,6 +5466,19 @@ var AbstractEditor = class extends AbstractElementWithParent {
5351
5466
  page: this.page
5352
5467
  }).getTitle();
5353
5468
  }
5469
+ /**
5470
+ * Вивантажує файл і повертає назву файла. Доступний тільки для поля FileUploader.
5471
+ * @example
5472
+ * const fileName = await formEdit.field('FileField').downloadFile();
5473
+ * expect(filename()).toBe('file.pdf');
5474
+ */
5475
+ async download() {
5476
+ await this.initEditor();
5477
+ if (!this.editor.download) {
5478
+ throw new Error("download is only available for the FileUploader field type.");
5479
+ }
5480
+ return this.editor.download();
5481
+ }
5354
5482
  };
5355
5483
 
5356
5484
  // src/pageObjects/elements/FormField.ts
@@ -406,6 +406,7 @@ var init_types = __esm({
406
406
  ControlClass2["BooleanSelector"] = "buttons-group";
407
407
  ControlClass2["ButtonGroup"] = "button-group-field";
408
408
  ControlClass2["HeaderFilterDictionary"] = "header-filter-dictionary";
409
+ ControlClass2["FileUploader"] = "file-uploader";
409
410
  return ControlClass2;
410
411
  })(ControlClass || {});
411
412
  }
@@ -1266,6 +1267,125 @@ var init_HeaderFilterDictionary = __esm({
1266
1267
  }
1267
1268
  });
1268
1269
 
1270
+ // src/pageObjects/elements/Editors/FileUploader.ts
1271
+ var FILE_NAME_SELECTOR, FILE_SIZE_ATTRIBUTE, FILE_DATE_ATTRIBUTE, FILE_TYPE_ATTRIBUTE, SELECT_FILE_BUTTON_SELECTOR, DOWNLOAD_FILE_BUTTON_SELECTOR, METADATA_SELECTOR, CLEAR_BUTTON_SELECTOR, FileUploader;
1272
+ var init_FileUploader = __esm({
1273
+ "src/pageObjects/elements/Editors/FileUploader.ts"() {
1274
+ "use strict";
1275
+ init_AbstractElementWithParent();
1276
+ FILE_NAME_SELECTOR = ".file-text";
1277
+ FILE_SIZE_ATTRIBUTE = "data-filesize";
1278
+ FILE_DATE_ATTRIBUTE = "data-moddate";
1279
+ FILE_TYPE_ATTRIBUTE = "data-filetype";
1280
+ SELECT_FILE_BUTTON_SELECTOR = ".select-file-button";
1281
+ DOWNLOAD_FILE_BUTTON_SELECTOR = ".download-file-button";
1282
+ METADATA_SELECTOR = ".file-text-file-info-wrapper";
1283
+ CLEAR_BUTTON_SELECTOR = ".clear-button";
1284
+ FileUploader = class extends AbstractElementWithParent {
1285
+ constructor(parentCssSelector, elementCssSelector, page) {
1286
+ super(parentCssSelector, elementCssSelector, page);
1287
+ }
1288
+ /**
1289
+ * Returns the metadata container element for the uploaded file.
1290
+ * Returns null when metadata is not rendered or not visible.
1291
+ */
1292
+ async getMedataElement() {
1293
+ const root = this.getFullCssSelector();
1294
+ const locator = this.page.locator(`${root} ${METADATA_SELECTOR}`);
1295
+ if (!await locator.isVisible()) return null;
1296
+ return locator;
1297
+ }
1298
+ /**
1299
+ * Returns the name of the uploaded file, or null if not present.
1300
+ */
1301
+ async getFileName() {
1302
+ const root = this.getFullCssSelector();
1303
+ const locator = this.page.locator(`${root} ${FILE_NAME_SELECTOR}`);
1304
+ if (!await locator.isVisible()) return null;
1305
+ const text = await locator.innerText();
1306
+ return text?.trim() || null;
1307
+ }
1308
+ /**
1309
+ * Returns the size of the uploaded file, or null if not present.
1310
+ */
1311
+ async getFileSize() {
1312
+ const element = await this.getMedataElement();
1313
+ if (!element) return null;
1314
+ const result = (await element.getAttribute(FILE_SIZE_ATTRIBUTE))?.trim();
1315
+ return isNaN(+result) ? null : +result;
1316
+ }
1317
+ /**
1318
+ * Returns the upload/modification date of the file, or null if not present.
1319
+ */
1320
+ async getFileDate() {
1321
+ const element = await this.getMedataElement();
1322
+ if (!element) return null;
1323
+ const fileModDate = (await element.getAttribute(FILE_DATE_ATTRIBUTE))?.trim();
1324
+ return fileModDate ? new Date(fileModDate) : null;
1325
+ }
1326
+ /**
1327
+ * Returns the MIME/content type of the uploaded file from metadata.
1328
+ * Returns null when the type attribute is absent or empty.
1329
+ */
1330
+ async getFileType() {
1331
+ const element = await this.getMedataElement();
1332
+ if (!element) return null;
1333
+ const fileType = (await element.getAttribute(FILE_TYPE_ATTRIBUTE))?.trim();
1334
+ return fileType || null;
1335
+ }
1336
+ /**
1337
+ * Returns current file information: name, size and upload/modification date.
1338
+ * Returns null if no file is uploaded.
1339
+ */
1340
+ async getValue() {
1341
+ const name = await this.getFileName();
1342
+ const size = await this.getFileSize();
1343
+ const date = await this.getFileDate();
1344
+ const type2 = await this.getFileType();
1345
+ if (!name && !size && !date && !type2) return null;
1346
+ return { FileName: name, FileSize: size, FileType: type2, ModDate: date };
1347
+ }
1348
+ /**
1349
+ * Uploads a file by clicking the select-file-button and providing the file path.
1350
+ * @param filePath - Absolute or relative path to the file on disk.
1351
+ */
1352
+ async setValue(filePath) {
1353
+ const root = this.getFullCssSelector();
1354
+ const fileChooserPromise = this.page.waitForEvent("filechooser");
1355
+ await this.page.locator(`${root} ${SELECT_FILE_BUTTON_SELECTOR}`).click();
1356
+ const fileChooser = await fileChooserPromise;
1357
+ await fileChooser.setFiles(filePath);
1358
+ }
1359
+ /**
1360
+ * Downloads the currently uploaded file by clicking the download-file-button.
1361
+ * Returns the suggested file name of the downloaded file.
1362
+ */
1363
+ async download() {
1364
+ const root = this.getFullCssSelector();
1365
+ const buttonLocator = this.page.locator(
1366
+ `${root} ${DOWNLOAD_FILE_BUTTON_SELECTOR}`
1367
+ );
1368
+ if (await buttonLocator.isHidden()) return "";
1369
+ const downloadPromise = this.page.waitForEvent("download");
1370
+ await buttonLocator.click();
1371
+ const download = await downloadPromise;
1372
+ return download.suggestedFilename();
1373
+ }
1374
+ /**
1375
+ * Removes the currently uploaded file by clicking the delete-file-button.
1376
+ * Does nothing if no file is uploaded.
1377
+ */
1378
+ async clear() {
1379
+ if (await this.getValue() === null) return;
1380
+ const root = this.getFullCssSelector();
1381
+ const deleteButton = this.page.locator(`${root} ${CLEAR_BUTTON_SELECTOR}`);
1382
+ if (await deleteButton.isHidden()) return;
1383
+ await deleteButton.click();
1384
+ }
1385
+ };
1386
+ }
1387
+ });
1388
+
1269
1389
  // src/pageObjects/elements/Editors/editorFactory.ts
1270
1390
  var editorFactory;
1271
1391
  var init_editorFactory = __esm({
@@ -1283,6 +1403,7 @@ var init_editorFactory = __esm({
1283
1403
  init_ButtonGroup();
1284
1404
  init_DateEditor();
1285
1405
  init_HeaderFilterDictionary();
1406
+ init_FileUploader();
1286
1407
  editorFactory = async (parentCssSelector, elementCssSelector, page) => {
1287
1408
  const elementInstance = new AbstractFormElement(parentCssSelector, elementCssSelector, page);
1288
1409
  const classString = await elementInstance.getClasses();
@@ -1303,6 +1424,8 @@ var init_editorFactory = __esm({
1303
1424
  return new ButtonGroup(parentCssSelector, elementCssSelector, page);
1304
1425
  if (classString.includes("header-filter-dictionary" /* HeaderFilterDictionary */))
1305
1426
  return new HeaderFilterDictionary(parentCssSelector, elementCssSelector, page);
1427
+ if (classString.includes("file-uploader" /* FileUploader */))
1428
+ return new FileUploader(parentCssSelector, elementCssSelector, page);
1306
1429
  throw new Error("Unknown type of editor. Please write ticket to the support");
1307
1430
  };
1308
1431
  }
@@ -2378,6 +2501,19 @@ var init_AbstractEditor2 = __esm({
2378
2501
  page: this.page
2379
2502
  }).getTitle();
2380
2503
  }
2504
+ /**
2505
+ * Вивантажує файл і повертає назву файла. Доступний тільки для поля FileUploader.
2506
+ * @example
2507
+ * const fileName = await formEdit.field('FileField').downloadFile();
2508
+ * expect(filename()).toBe('file.pdf');
2509
+ */
2510
+ async download() {
2511
+ await this.initEditor();
2512
+ if (!this.editor.download) {
2513
+ throw new Error("download is only available for the FileUploader field type.");
2514
+ }
2515
+ return this.editor.download();
2516
+ }
2381
2517
  };
2382
2518
  }
2383
2519
  });
@@ -96,6 +96,7 @@ interface Editor {
96
96
  clear?(): Promise<void>;
97
97
  isReadonly?(): Promise<boolean>;
98
98
  isDisabled?(): Promise<boolean>;
99
+ download?(): Promise<string>;
99
100
  }
100
101
  declare enum ControlClass {
101
102
  Text = "text-control",
@@ -109,7 +110,8 @@ declare enum ControlClass {
109
110
  SingleDateRange = "single-date-range-control",
110
111
  BooleanSelector = "buttons-group",
111
112
  ButtonGroup = "button-group-field",
112
- HeaderFilterDictionary = "header-filter-dictionary"
113
+ HeaderFilterDictionary = "header-filter-dictionary",
114
+ FileUploader = "file-uploader"
113
115
  }
114
116
 
115
117
  interface ClearStrategy {
@@ -418,6 +420,13 @@ declare class AbstractEditor extends AbstractElementWithParent implements Editor
418
420
  * expect(await formEdit.field('TextFld').title()).toBe('Title2`);
419
421
  */
420
422
  title(): Promise<string>;
423
+ /**
424
+ * Вивантажує файл і повертає назву файла. Доступний тільки для поля FileUploader.
425
+ * @example
426
+ * const fileName = await formEdit.field('FileField').downloadFile();
427
+ * expect(filename()).toBe('file.pdf');
428
+ */
429
+ download(): Promise<string>;
421
430
  }
422
431
 
423
432
  declare class FormField extends AbstractEditor {
@@ -96,6 +96,7 @@ interface Editor {
96
96
  clear?(): Promise<void>;
97
97
  isReadonly?(): Promise<boolean>;
98
98
  isDisabled?(): Promise<boolean>;
99
+ download?(): Promise<string>;
99
100
  }
100
101
  declare enum ControlClass {
101
102
  Text = "text-control",
@@ -109,7 +110,8 @@ declare enum ControlClass {
109
110
  SingleDateRange = "single-date-range-control",
110
111
  BooleanSelector = "buttons-group",
111
112
  ButtonGroup = "button-group-field",
112
- HeaderFilterDictionary = "header-filter-dictionary"
113
+ HeaderFilterDictionary = "header-filter-dictionary",
114
+ FileUploader = "file-uploader"
113
115
  }
114
116
 
115
117
  interface ClearStrategy {
@@ -418,6 +420,13 @@ declare class AbstractEditor extends AbstractElementWithParent implements Editor
418
420
  * expect(await formEdit.field('TextFld').title()).toBe('Title2`);
419
421
  */
420
422
  title(): Promise<string>;
423
+ /**
424
+ * Вивантажує файл і повертає назву файла. Доступний тільки для поля FileUploader.
425
+ * @example
426
+ * const fileName = await formEdit.field('FileField').downloadFile();
427
+ * expect(filename()).toBe('file.pdf');
428
+ */
429
+ download(): Promise<string>;
421
430
  }
422
431
 
423
432
  declare class FormField extends AbstractEditor {
@@ -23,7 +23,7 @@ import {
23
23
  readonlyLocator,
24
24
  wait,
25
25
  waitElementIsVisible_default
26
- } from "./chunk-XG4PWBWZ.mjs";
26
+ } from "./chunk-ZSUCWPIH.mjs";
27
27
  export {
28
28
  AbstractPage,
29
29
  ApiRequest,
@@ -23,7 +23,7 @@ import {
23
23
  readonlyLocator,
24
24
  wait,
25
25
  waitElementIsVisible_default
26
- } from "./chunk-XG4PWBWZ.mjs";
26
+ } from "./chunk-ZSUCWPIH.mjs";
27
27
  export {
28
28
  AbstractPage,
29
29
  ApiRequest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d5-testing-library",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "e2e testing D5 projects",
5
5
  "main": "dist/cjs/d5-testing-library.cjs",
6
6
  "module": "dist/d5-testing-library.legacy-esm.js",