@postxl/generator 0.62.3 → 0.62.5

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/dist/generator.js CHANGED
@@ -62,8 +62,8 @@ const repositories_generator_1 = require("./generators/indices/repositories.gene
62
62
  const routes_index_generator_1 = require("./generators/indices/routes-index.generator");
63
63
  const seed_migration_generator_1 = require("./generators/indices/seed-migration.generator");
64
64
  const seed_template_generator_1 = require("./generators/indices/seed-template.generator");
65
- const selectors_generator_1 = require("./generators/indices/selectors.generator");
66
65
  const testdata_service_generator_1 = require("./generators/indices/testdata-service.generator");
66
+ const testids_generator_1 = require("./generators/indices/testids.generator");
67
67
  const types_generator_2 = require("./generators/indices/types.generator");
68
68
  const admin_page_generator_1 = require("./generators/models/admin.page.generator");
69
69
  const businesslogic_update_generator_1 = require("./generators/models/businesslogic-update.generator");
@@ -206,7 +206,7 @@ function generate({ models, enums, config, prismaClientPath, logger, }) {
206
206
  generated.write(`/${meta.data.dataService.location.path}.ts`, (0, dataservice_generator_1.generateDataService)({ models, meta }));
207
207
  generated.write(`/${meta.data.testDataServiceFilePath}.ts`, (0, testdata_service_generator_1.generateTestDataService)({ models, meta }));
208
208
  generated.write(`/${meta.e2e.dataMockerLocation.path}.ts`, (0, datamocker_generator_1.generateDataMocker)({ models, meta }));
209
- generated.write(`/${meta.e2e.selectorsFilePath}.ts`, (0, selectors_generator_1.generateSelectors)());
209
+ generated.write(`/${meta.e2e.testIdsFilePath}.ts`, (0, testids_generator_1.generateTestIds)());
210
210
  generated.write(`/${meta.data.repository.constFilePath}.ts`, (0, repositories_generator_1.generateRepositoriesArray)({ models, meta }));
211
211
  generated.write(`/${meta.data.types.location.path}.ts`, (0, data_types_generator_1.generateDataTypes)({ models, meta }));
212
212
  // Import-Export
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generates list of test ids for E2E tests.
3
+ *
4
+ * Note: This generator does not need the models or meta data passed in.
5
+ * Instead it uses the TestIdCollector singleton that already collected all ids during the generation process of the individual models.
6
+ */
7
+ export declare function generateTestIds(): string;
@@ -1,38 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSelectors = void 0;
4
- const id_collector_1 = require("../../lib/id-collector");
3
+ exports.generateTestIds = void 0;
4
+ const test_id_collector_1 = require("../../lib/test-id-collector");
5
5
  /**
6
- * List of ids that are not generated but hardcoded across the template.
7
- */
8
- const HARDCODED_IDS = [
9
- 'indexPage-buttons-create',
10
- 'confirmationModal-buttons-confirm',
11
- 'confirmationModal-buttons-cancel',
12
- ];
13
- /**
14
- * Generates list of component selectors for E2E tests.
6
+ * Generates list of test ids for E2E tests.
15
7
  *
16
8
  * Note: This generator does not need the models or meta data passed in.
17
- * Instead it uses the SelectorCollector singleton that already collected all ids during the generation process of the individual models.
9
+ * Instead it uses the TestIdCollector singleton that already collected all ids during the generation process of the individual models.
18
10
  */
19
- function generateSelectors() {
20
- // SelectorCollector is a static singleton that collects all ids during the generation process. We flush it here to get all ids.
21
- const collectedIds = id_collector_1.SelectorCollector.flush();
11
+ function generateTestIds() {
12
+ // TestIdCollector is a static singleton that collects all ids during the generation process. We flush it here to get all ids.
13
+ const collectedIds = test_id_collector_1.TestIdCollector.flush();
22
14
  const object = {};
23
- const ids = [...HARDCODED_IDS, ...collectedIds];
15
+ const ids = collectedIds;
24
16
  ids.sort();
25
17
  for (const id of ids) {
26
18
  const keys = id.split('-');
27
- extendObject(object, keys, `[data-test-id=${id}]`);
19
+ extendObject(object, keys, id);
28
20
  }
29
- const selectors = JSON.stringify(object, null, 2);
21
+ const testIds = JSON.stringify(object, null, 2);
30
22
  return /* ts */ `
31
- export const SELECTORS =
32
- ${selectors}
23
+ /**
24
+ * Object with all generated test ids.
25
+ */
26
+ export const MODEL_TEST_IDS =
27
+ ${testIds}
33
28
  `;
34
29
  }
35
- exports.generateSelectors = generateSelectors;
30
+ exports.generateTestIds = generateTestIds;
36
31
  /**
37
32
  * Recursively traverses the keys and adds the value to the object in a nested way.
38
33
  * E.g. `{object, keys: ['post', 'create', 'name'], value}` will extend `object` with `{post: {create: {name: value}}}`.
@@ -21,9 +21,11 @@ import { Headline } from '@components/atoms/Headline'
21
21
  ${imports.generate()}
22
22
 
23
23
  import { Content, Layout } from '@components/shared/Layout'
24
+ import { STATIC_TEST_IDS } from '@lib/static_test_ids'
24
25
  import { t } from '@i18n/translation'
25
26
  import { useState } from 'react'
26
27
 
28
+
27
29
  export default function Admin${meta.internalSingularNameCapitalized}Page() {
28
30
  const [query, setQuery] = useState('')
29
31
  const [isCreateModalOpen, setIsCreateModalOpen] = useState(false)
@@ -44,7 +46,7 @@ export default function Admin${meta.internalSingularNameCapitalized}Page() {
44
46
  <Spacer key="Spacer" />
45
47
 
46
48
  <ActionWrapper key="GlobalFilter">
47
- <Button label={t['Create']} icon="plus" fill="fill" __e2e_selector__="indexPage-buttons-create" onClick={() => setIsCreateModalOpen(true)}/>
49
+ <Button label={t['Create']} icon="plus" fill="fill" __e2e_test_id__={STATIC_TEST_IDS.indexPage.buttons.create} onClick={() => setIsCreateModalOpen(true)}/>
48
50
  </ActionWrapper>
49
51
  </ActionsBarWrapper>
50
52
  </Header>
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateModelLibraryComponents = void 0;
4
- const id_collector_1 = require("../../../lib/id-collector");
5
4
  const imports_1 = require("../../../lib/imports");
5
+ const test_id_collector_1 = require("../../../lib/test-id-collector");
6
6
  /**
7
7
  * Generates components that may be used to list all entries of a given data type.
8
8
  *
9
9
  */
10
10
  function generateModelLibraryComponents({ model, meta }) {
11
11
  const { react: { context, components }, } = meta;
12
- const selectorCollector = id_collector_1.SelectorCollector.from(meta.seed.constantName + '-card');
12
+ const testIdCollector = test_id_collector_1.TestIdCollector.from(meta.seed.constantName + '-card');
13
13
  const titleProp = model.nameField.isRequired
14
14
  ? `title={item.${model.nameField.name}}`
15
15
  : `title={item.${model.nameField.name} ?? item.${model.idField.name}}`;
@@ -61,13 +61,13 @@ function generateModelLibraryComponents({ model, meta }) {
61
61
  label: 'Edit',
62
62
  icon: 'pencil-on-paper',
63
63
  onClick: () => setIsEditModalOpen(true),
64
- __e2e_action_selector__: "${selectorCollector.idFor('edit', { typePrefix: 'actions' })}",
64
+ __e2e_action_test_id__: "${testIdCollector.idFor('edit', { typePrefix: 'actions' })}",
65
65
  },
66
66
  {
67
67
  label: 'Delete',
68
68
  icon: 'trash',
69
69
  onClick: () => setIsDeleteModalOpen(true),
70
- __e2e_action_selector__: "${selectorCollector.idFor('delete', { typePrefix: 'actions' })}",
70
+ __e2e_action_test_id__: "${testIdCollector.idFor('delete', { typePrefix: 'actions' })}",
71
71
  },
72
72
  ]}
73
73
  />
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateModelLookupComponents = void 0;
4
- const id_collector_1 = require("../../../lib/id-collector");
5
4
  const imports_1 = require("../../../lib/imports");
5
+ const test_id_collector_1 = require("../../../lib/test-id-collector");
6
6
  /**
7
- * Returns a selector string that links the component to the global selectors index.
7
+ * Generates a test id that that can be used to identify a component in E2E tests.
8
8
  */
9
- function selector(meta, typePrefix, options) {
9
+ function testId(meta, typePrefix, options) {
10
10
  var _a;
11
- const selectorCollector = id_collector_1.SelectorCollector.from(meta.seed.constantName + '-formComponents');
12
- return selectorCollector.idFor((_a = options === null || options === void 0 ? void 0 : options.element) !== null && _a !== void 0 ? _a : '', { typePrefix });
11
+ const testIdCollector = test_id_collector_1.TestIdCollector.from(meta.seed.constantName + '-formComponents');
12
+ return testIdCollector.idFor((_a = options === null || options === void 0 ? void 0 : options.element) !== null && _a !== void 0 ? _a : '', { typePrefix });
13
13
  }
14
14
  /**
15
15
  * Utility generator that generates lookup components for a given model.
@@ -61,7 +61,7 @@ export const ${components.forms.selectInputName} = ({
61
61
  options={list}
62
62
  ${labelProp}
63
63
  loading={!ready}
64
- __e2e_field_selector__="${selector(meta, 'selectInput')}"
64
+ __e2e_field_test_id__="${testId(meta, 'selectInput')}"
65
65
  {...delegated}
66
66
  />
67
67
  }
@@ -75,7 +75,7 @@ export const ${components.forms.selectFieldName} = ({
75
75
  options={list}
76
76
  ${labelProp}
77
77
  loading={!ready}
78
- __e2e_field_selector__="${selector(meta, 'selectField')}"
78
+ __e2e_field_test_id__="${testId(meta, 'selectField')}"
79
79
  {...delegated}
80
80
  />
81
81
  }
@@ -91,7 +91,7 @@ export const ${components.forms.menuSelectInputName} = ({
91
91
  options={list}
92
92
  ${labelProp}
93
93
  loading={!ready}
94
- __e2e_options_selector__="${selector(meta, 'menuSelectInput')}"
94
+ __e2e_options_test_id__="${testId(meta, 'menuSelectInput')}"
95
95
  {...delegated}
96
96
  />
97
97
  }
@@ -105,7 +105,7 @@ export const ${components.forms.menuSelectFieldName} = ({
105
105
  options={list}
106
106
  ${labelProp}
107
107
  loading={!ready}
108
- __e2e_options_selector__="${selector(meta, 'menuSelectField')}"
108
+ __e2e_options_test_id__="${testId(meta, 'menuSelectField')}"
109
109
  {...delegated}
110
110
  />
111
111
  }
@@ -121,8 +121,8 @@ export const ${components.forms.searchInputName} = ({
121
121
  options={list}
122
122
  ${labelProp}
123
123
  loading={!ready}
124
- __e2e_combobox_selector__="${selector(meta, 'searchInput', { element: 'field' })}"
125
- __e2e_options_selector__="${selector(meta, 'searchInput', { element: 'options' })}"
124
+ __e2e_combobox_test_id__="${testId(meta, 'searchInput', { element: 'field' })}"
125
+ __e2e_options_test_id__="${testId(meta, 'searchInput', { element: 'options' })}"
126
126
  {...delegated}
127
127
  />
128
128
  }
@@ -136,8 +136,8 @@ export const ${components.forms.searchFieldName} = ({
136
136
  options={list}
137
137
  ${labelProp}
138
138
  loading={!ready}
139
- __e2e_combobox_selector__="${selector(meta, 'searchField', { element: 'field' })}"
140
- __e2e_options_selector__="${selector(meta, 'searchField', { element: 'options' })}"
139
+ __e2e_combobox_test_id__="${testId(meta, 'searchField', { element: 'field' })}"
140
+ __e2e_options_test_id__="${testId(meta, 'searchField', { element: 'options' })}"
141
141
  {...delegated}
142
142
  />
143
143
  }
@@ -152,7 +152,7 @@ export const ${components.forms.tableSelectInputName} = ({
152
152
  options={list}
153
153
  ${labelProp}
154
154
  loading={!ready}
155
- __e2e_input_field_selector__="${selector(meta, 'tableSelectInput')}"
155
+ __e2e_input_field_test_id__="${testId(meta, 'tableSelectInput')}"
156
156
  {...delegated}
157
157
  />
158
158
  }
@@ -166,7 +166,7 @@ export const ${components.forms.tableSelectFieldName} = ({
166
166
  options={list}
167
167
  ${labelProp}
168
168
  loading={!ready}
169
- __e2e_input_field_selector__="${selector(meta, 'tableSelectField')}"
169
+ __e2e_input_field_test_id__="${testId(meta, 'tableSelectField')}"
170
170
  {...delegated}
171
171
  />
172
172
  }
@@ -24,11 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.generateDeleteModalModelComponent = exports.generateEditModalModelComponent = exports.generateModelCreateModalComponent = void 0;
27
- const id_collector_1 = require("../../../lib/id-collector");
28
27
  const imports_1 = require("../../../lib/imports");
29
28
  const meta_1 = require("../../../lib/meta");
30
29
  const fields_1 = require("../../../lib/schema/fields");
31
30
  const serializer_1 = require("../../../lib/serializer");
31
+ const test_id_collector_1 = require("../../../lib/test-id-collector");
32
32
  const types_1 = require("../../../lib/types");
33
33
  const StringUtils = __importStar(require("../../../lib/utils/string"));
34
34
  /**
@@ -37,7 +37,7 @@ const StringUtils = __importStar(require("../../../lib/utils/string"));
37
37
  function generateModelCreateModalComponent({ model, meta }) {
38
38
  const { fields } = model;
39
39
  const { react: { components: { modals }, }, trpc, } = meta;
40
- const selectorCollector = id_collector_1.SelectorCollector.from(meta.seed.constantName + '-createModal');
40
+ const testIdCollector = test_id_collector_1.TestIdCollector.from(meta.seed.constantName + '-createModal');
41
41
  const dimensions = getModalComponentDimensions({ model });
42
42
  return `
43
43
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -150,10 +150,10 @@ export const ${modals.createComponentName} = ({
150
150
  fill="fill"
151
151
  onClick={submitForm}
152
152
  loading={isSubmitting}
153
- __e2e_selector__="${selectorCollector.idFor('submit', { typePrefix: 'buttons' })}"
153
+ __e2e_test_id__="${testIdCollector.idFor('submit', { typePrefix: 'buttons' })}"
154
154
  />
155
155
  }>
156
- ${getFormFieldComponents({ model, selectorCollector })}
156
+ ${getFormFieldComponents({ model, testIdCollector: testIdCollector })}
157
157
  </ModalWithActions>
158
158
  )}
159
159
  </Typed.Formik>
@@ -170,7 +170,7 @@ exports.generateModelCreateModalComponent = generateModelCreateModalComponent;
170
170
  function generateEditModalModelComponent({ model, meta }) {
171
171
  const { fields } = model;
172
172
  const { react: { components }, trpc, } = meta;
173
- const selectorCollector = id_collector_1.SelectorCollector.from(meta.seed.constantName + '-editModal');
173
+ const testIdCollector = test_id_collector_1.TestIdCollector.from(meta.seed.constantName + '-editModal');
174
174
  const dimensions = getModalComponentDimensions({ model });
175
175
  return `
176
176
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -286,11 +286,11 @@ export const ${components.modals.editComponentName} = ({
286
286
  color="primary"
287
287
  onClick={submitForm}
288
288
  loading={isSubmitting}
289
- __e2e_selector__="${selectorCollector.idFor('submit', { typePrefix: 'buttons' })}"
289
+ __e2e_test_id__="${testIdCollector.idFor('submit', { typePrefix: 'buttons' })}"
290
290
  />
291
291
  }
292
292
  >
293
- ${getFormFieldComponents({ model, selectorCollector })}
293
+ ${getFormFieldComponents({ model, testIdCollector: testIdCollector })}
294
294
  </ModalWithActions>
295
295
  )}
296
296
  </Typed.Formik>
@@ -559,7 +559,7 @@ function getEditFormikMutationData({ model: { fields } }) {
559
559
  /**
560
560
  * Returns a string containing all the components that should appear in the Formik form for this model.
561
561
  */
562
- function getFormFieldComponents({ model, selectorCollector, }) {
562
+ function getFormFieldComponents({ model, testIdCollector, }) {
563
563
  var _a;
564
564
  const form = new serializer_1.Serializer();
565
565
  for (const field of model.fields.values()) {
@@ -584,7 +584,7 @@ function getFormFieldComponents({ model, selectorCollector, }) {
584
584
  <Typed.TextField
585
585
  name="${formikFieldName}"
586
586
  placeholder="Type..."
587
- __e2e_field_selector__="${selectorCollector.idFor(field.name, { typePrefix: 'fields' })}"
587
+ __e2e_field_test_id__="${testIdCollector.idFor(field.name, { typePrefix: 'fields' })}"
588
588
  />
589
589
  </div>
590
590
  `);
@@ -602,7 +602,7 @@ function getFormFieldComponents({ model, selectorCollector, }) {
602
602
  name="${formikFieldName}"
603
603
  placeholder="2511"
604
604
  decimals={${decimals}}
605
- __e2e_field_selector__="${selectorCollector.idFor(field.name, { typePrefix: 'fields' })}"
605
+ __e2e_field_test_id__="${testIdCollector.idFor(field.name, { typePrefix: 'fields' })}"
606
606
  />
607
607
  </div>
608
608
  `);
@@ -615,7 +615,7 @@ function getFormFieldComponents({ model, selectorCollector, }) {
615
615
  <Typed.CheckBoxField
616
616
  name="${formikFieldName}"
617
617
  label="${label}"
618
- __e2e_field_selector__="${selectorCollector.idFor(field.name, { typePrefix: 'fields' })}"
618
+ __e2e_field_test_id__="${testIdCollector.idFor(field.name, { typePrefix: 'fields' })}"
619
619
  />
620
620
  </div>
621
621
  `);
@@ -640,8 +640,8 @@ function getFormFieldComponents({ model, selectorCollector, }) {
640
640
  <Typed.${refMeta.react.components.forms.searchFieldName}
641
641
  name="${formikFieldName}"
642
642
  placeholder="Search..."
643
- __e2e_options_selector__="${selectorCollector.idFor(field.name, { typePrefix: 'options' })}"
644
- __e2e_combobox_selector__="${selectorCollector.idFor(field.name, { typePrefix: 'fields' })}"
643
+ __e2e_options_test_id__="${testIdCollector.idFor(field.name, { typePrefix: 'options' })}"
644
+ __e2e_combobox_test_id__="${testIdCollector.idFor(field.name, { typePrefix: 'fields' })}"
645
645
  />
646
646
  </div>
647
647
  `);
@@ -655,7 +655,7 @@ function getFormFieldComponents({ model, selectorCollector, }) {
655
655
  <Typed.${enumMeta.react.selectFieldName}
656
656
  name="${formikFieldName}"
657
657
  placeholder="Search..."
658
- __e2e_field_selector__="${selectorCollector.idFor(field.name, { typePrefix: 'fields' })}"
658
+ __e2e_field_test_id__="${testIdCollector.idFor(field.name, { typePrefix: 'fields' })}"
659
659
  />
660
660
  </div>
661
661
  `);
@@ -651,9 +651,9 @@ export type SchemaMetaData = {
651
651
  */
652
652
  dataMockerLocation: Types.ModuleLocation;
653
653
  /**
654
- * Path to the file containing component selectors for e2e tests.
654
+ * Path to the file containing component test ids for e2e tests.
655
655
  */
656
- selectorsFilePath: Types.FilePath;
656
+ testIdsFilePath: Types.FilePath;
657
657
  };
658
658
  /**
659
659
  * Path to the directory containing Prisma migrations.
package/dist/lib/meta.js CHANGED
@@ -153,7 +153,7 @@ function getSchemaMetadata({ config }) {
153
153
  },
154
154
  e2e: {
155
155
  dataMockerLocation: Types.toModuleLocation(`e2e`, `${config.paths.playwrightPath}support/data-mocker.class`),
156
- selectorsFilePath: Types.toPath(`${config.paths.playwrightPath}support/selectors`),
156
+ testIdsFilePath: Types.toPath(`${config.paths.playwrightPath}support/model-test-ids`),
157
157
  },
158
158
  importExport: {
159
159
  moduleLocation: Types.toModuleLocation(`import-export`, `${config.paths.importExportPath}import-export.module`),
@@ -1,17 +1,17 @@
1
- type ElementId = string & {
1
+ export type TestId = string & {
2
2
  __brand: 'ElementId';
3
3
  };
4
4
  /**
5
- * The SelectorCollector is used to generate and track HTML element IDs.
5
+ * The TestIdCollector is used to generate and track HTML element IDs.
6
6
  * The idea is that it is instantiated once and then used to generate IDs throughout the generators.
7
7
  * After the files are generated, all generated IDs can be serialized to a file.
8
8
  *
9
9
  * An ID can for instance be something like `post-create-name, `${model.name}-${componentType}-${fieldName}`.
10
10
  *
11
- * Each code generator can instantiate an SelectorCollector - the constructor will require the current model & component type.
11
+ * Each code generator can instantiate a TestIdCollector - the constructor will require the current model & component type.
12
12
  * All generated Ids will be stored in a global static Set so we can serialize them later.
13
13
  */
14
- export declare class SelectorCollector {
14
+ export declare class TestIdCollector {
15
15
  private _prefix;
16
16
  /**
17
17
  * We store all generated IDs in a global static Set so we can serialize them later.
@@ -19,9 +19,9 @@ export declare class SelectorCollector {
19
19
  private static _ids;
20
20
  constructor(_prefix: string);
21
21
  /**
22
- * Creates a new instance of the SelectorCollector.
22
+ * Creates a new instance of the TestIdCollector.
23
23
  */
24
- static from(prefix: string): SelectorCollector;
24
+ static from(prefix: string): TestIdCollector;
25
25
  /**
26
26
  * Generates a new ID for an element and stores it in the collector
27
27
  */
@@ -34,10 +34,9 @@ export declare class SelectorCollector {
34
34
  * Optional prefix for the type of the element, e.g. `field` or `button`.
35
35
  */
36
36
  typePrefix?: string;
37
- }): string;
37
+ }): TestId;
38
38
  /**
39
39
  * Returns all generated IDs and resets the stored IDs.
40
40
  */
41
- static flush(): ElementId[];
41
+ static flush(): TestId[];
42
42
  }
43
- export {};
@@ -1,25 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SelectorCollector = void 0;
3
+ exports.TestIdCollector = void 0;
4
4
  /**
5
- * The SelectorCollector is used to generate and track HTML element IDs.
5
+ * The TestIdCollector is used to generate and track HTML element IDs.
6
6
  * The idea is that it is instantiated once and then used to generate IDs throughout the generators.
7
7
  * After the files are generated, all generated IDs can be serialized to a file.
8
8
  *
9
9
  * An ID can for instance be something like `post-create-name, `${model.name}-${componentType}-${fieldName}`.
10
10
  *
11
- * Each code generator can instantiate an SelectorCollector - the constructor will require the current model & component type.
11
+ * Each code generator can instantiate a TestIdCollector - the constructor will require the current model & component type.
12
12
  * All generated Ids will be stored in a global static Set so we can serialize them later.
13
13
  */
14
- class SelectorCollector {
14
+ class TestIdCollector {
15
15
  constructor(_prefix) {
16
16
  this._prefix = _prefix;
17
17
  }
18
18
  /**
19
- * Creates a new instance of the SelectorCollector.
19
+ * Creates a new instance of the TestIdCollector.
20
20
  */
21
21
  static from(prefix) {
22
- return new SelectorCollector(prefix);
22
+ return new TestIdCollector(prefix);
23
23
  }
24
24
  /**
25
25
  * Generates a new ID for an element and stores it in the collector
@@ -31,23 +31,23 @@ class SelectorCollector {
31
31
  elementName, options) {
32
32
  const { typePrefix } = options !== null && options !== void 0 ? options : {};
33
33
  const id = [this._prefix, typePrefix, elementName].filter((x) => x !== undefined && x !== '').join('-');
34
- if (SelectorCollector._ids.has(id)) {
34
+ if (TestIdCollector._ids.has(id)) {
35
35
  throw new Error(`ID ${id} already exists.`);
36
36
  }
37
- SelectorCollector._ids.add(id);
37
+ TestIdCollector._ids.add(id);
38
38
  return id;
39
39
  }
40
40
  /**
41
41
  * Returns all generated IDs and resets the stored IDs.
42
42
  */
43
43
  static flush() {
44
- const result = [...SelectorCollector._ids.values()];
45
- SelectorCollector._ids.clear();
44
+ const result = [...TestIdCollector._ids.values()];
45
+ TestIdCollector._ids.clear();
46
46
  return result;
47
47
  }
48
48
  }
49
- exports.SelectorCollector = SelectorCollector;
49
+ exports.TestIdCollector = TestIdCollector;
50
50
  /**
51
51
  * We store all generated IDs in a global static Set so we can serialize them later.
52
52
  */
53
- SelectorCollector._ids = new Set();
53
+ TestIdCollector._ids = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "0.62.3",
3
+ "version": "0.62.5",
4
4
  "main": "./dist/generator.js",
5
5
  "typings": "./dist/generator.d.ts",
6
6
  "bin": {
@@ -1,7 +0,0 @@
1
- /**
2
- * Generates list of component selectors for E2E tests.
3
- *
4
- * Note: This generator does not need the models or meta data passed in.
5
- * Instead it uses the SelectorCollector singleton that already collected all ids during the generation process of the individual models.
6
- */
7
- export declare function generateSelectors(): string;