import { Rule, SchematicContext, Tree, chain, schematic } from '@angular-devkit/schematics'; import { FrontendSchematics } from '../frontend-schematics'; import { dasherize } from '@angular-devkit/core/src/utils/strings'; import { Model } from '@vmfvmf/ywtc-lib'; import { ClassRelationEnum, UcType } from '@vmfvmf/ywtc-lib/dist/model.enums'; export function gen(model: Model): Rule { return (tree: Tree, _context: SchematicContext) => { let schematics: Rule[] = []; schematics.push(schematic(FrontendSchematics.E2E_DUMMY_DATA_FACTORY, model)); if ([UcType.STD, UcType.STDUBD].includes(model.ucType)) { schematics.push(schematic(FrontendSchematics.E2E_SEARCH_PAGE, model)); schematics.push(schematic(FrontendSchematics.E2E_UC_TEST_SUIT, model)); } if (model.ucType == UcType.STD) { schematics.push(schematic(FrontendSchematics.E2E_UPDATE_PAGE, model)); } else if (model.ucType == UcType.STDUBD) { schematics.push(schematic(FrontendSchematics.E2E_UPDATE_DIALOG, model)); } model.relations .filter(rel => rel.relation == ClassRelationEnum.OneToMany) .forEach(rel => schematics.push(schematic(FrontendSchematics.E2E_CHILD_UPDATE_DIALOG, rel))) const rule = chain(schematics); return rule(tree, _context); }; } export function getFormFieldE2EImport(e2e: string) { return `import { ${e2e} } from 'cypress/support/test-structure/form-field/${dasherize(e2e)}';`; }