diff --git a/generators/angular/generator.ts b/generators/angular/generator.ts index e7af986539f7..d607ce732e59 100644 --- a/generators/angular/generator.ts +++ b/generators/angular/generator.ts @@ -41,6 +41,7 @@ import { addItemToAdminMenu, addRoute, addToEntitiesMenu, + buildAngularFormPath as angularFormPath, isTranslatedAngularFile, translateAngularFilesTransform, } from './support/index.js'; @@ -195,7 +196,7 @@ export default class AngularGenerator extends BaseApplicationGenerator< return angularFormPath(reference, prefix); }; - entity.generateTestEntityId = (primaryKey, index = 0, wrapped = true) => { + entity.generateTestEntityId = (primaryKey, index: 0 | 1 | 'random' = 0, wrapped = true) => { return getTestEntityId(primaryKey, index, wrapped); }; }, diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.spec.ts.ejs index 3664f3b6b482..993881549954 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.spec.ts.ejs @@ -136,11 +136,7 @@ describe('<%= entityAngularName %> Management Component', () => { describe('track<%= primaryKey.nameCapitalized %>', () => { it('Should forward to <%= entityInstance %>Service', () => { -<<<<<<< HEAD const entity = <%- tsPrimaryKeySamples[0] %>; -======= - const entity = <%- generateTestEntityPrimaryKey(primaryKey, 0) %>; ->>>>>>> 6a2ff33b25 (generator-specific entity) jest.spyOn(service, 'get<%= entityAngularName %>Identifier'); const <%= primaryKey.name %> = comp.track<%= primaryKey.nameCapitalized %>(entity); expect(service.get<%= entityAngularName %>Identifier).toHaveBeenCalledWith(entity); diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/service/_entityFile_.service.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/service/_entityFile_.service.spec.ts.ejs index b55b1ac8359a..d90d0d3bbe49 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/service/_entityFile_.service.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/service/_entityFile_.service.spec.ts.ejs @@ -219,11 +219,7 @@ describe('<%= entityAngularName %> Service', () => { }); it('Should return false if one entity is null', () => { -<<<<<<< HEAD const entity1 = <%- tsPrimaryKeySamples[0] %>; -======= - const entity1 = <%- generateTestEntityPrimaryKey(primaryKey, 0) %>; ->>>>>>> 6a2ff33b25 (generator-specific entity) const entity2 = null; const compareResult1 = service.compare<%= entityAngularName %>(entity1, entity2); @@ -234,13 +230,8 @@ describe('<%= entityAngularName %> Service', () => { }); it('Should return false if primaryKey differs', () => { -<<<<<<< HEAD const entity1 = <%- tsPrimaryKeySamples[0] %>; const entity2 = <%- tsPrimaryKeySamples[1] %>; -======= - const entity1 = <%- generateTestEntityPrimaryKey(primaryKey, 0) %>; - const entity2 = <%- generateTestEntityPrimaryKey(primaryKey, 1) %>; ->>>>>>> 6a2ff33b25 (generator-specific entity) const compareResult1 = service.compare<%= entityAngularName %>(entity1, entity2); const compareResult2 = service.compare<%= entityAngularName %>(entity2, entity1); @@ -250,13 +241,8 @@ describe('<%= entityAngularName %> Service', () => { }); it('Should return false if primaryKey matches', () => { -<<<<<<< HEAD const entity1 = <%- tsPrimaryKeySamples[0] %>; const entity2 = <%- tsPrimaryKeySamples[0] %>; -======= - const entity1 = <%- generateTestEntityPrimaryKey(primaryKey, 0) %>; - const entity2 = <%- generateTestEntityPrimaryKey(primaryKey, 0) %>; ->>>>>>> 6a2ff33b25 (generator-specific entity) const compareResult1 = service.compare<%= entityAngularName %>(entity1, entity2); const compareResult2 = service.compare<%= entityAngularName %>(entity2, entity1); diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs index 0f643e8b9c44..71e772cf744e 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs @@ -175,11 +175,7 @@ _%> } <%_ } else { _%> -<<<<<<< HEAD @if (editForm.get(['<%- relationship.propertyName %>'])!.value == null) { -======= - @if (editForm.get([<%- buildAngularFormPath(relationship.reference) %>])!.value == null) { ->>>>>>> 6a2ff33b25 (generator-specific entity) } <%_ } _%> diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.spec.ts.ejs index d2716a865679..188148b876db 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.spec.ts.ejs @@ -17,22 +17,13 @@ limitations under the License. -%> <%_ -<<<<<<< HEAD const tsKeyId = primaryKey.tsSampleValues[0]; -======= -const tsKeyId = generateTestEntityId(primaryKey.type); ->>>>>>> 6a2ff33b25 (generator-specific entity) const allRelationshipsByEntityNeedingOptions = Object .values(relationshipsByOtherEntity) .map(relationships => relationships.filter(rel => rel.persistableRelationship && !rel.otherEntity.embedded)) .filter(relationships => relationships.length > 0); -<<<<<<< HEAD const testEntityPrimaryKey0 = tsPrimaryKeySamples[0]; const testEntityPrimaryKey1 = tsPrimaryKeySamples[1]; -======= -const testEntityPrimaryKey0 = generateTestEntityPrimaryKey(primaryKey, 0); -const testEntityPrimaryKey1 = generateTestEntityPrimaryKey(primaryKey, 1); ->>>>>>> 6a2ff33b25 (generator-specific entity) _%> import { ComponentFixture, TestBed } from '@angular/core/testing'; import { provideHttpClient, HttpResponse } from '@angular/common/http'; @@ -104,24 +95,14 @@ describe('<%= entityAngularName %> Management Update Component', () => { <%_ for (const relationship of relationshipsWithCustomSharedOptions) { _%> <%_ const reference = relationship.reference _%> <%_ if (relationship.collection) { _%> -<<<<<<< HEAD const <%= reference.name %> : I<%= otherEntity.entityAngularName %>[] = [<%- otherEntity.tsPrimaryKeySamples[0] %>]; <%_ } else { _%> const <%= reference.name %> : I<%= otherEntity.entityAngularName %> = <%- otherEntity.tsPrimaryKeySamples[0] %>; -======= - const <%= reference.name %> : I<%= otherEntity.entityAngularName %>[] = [<%- generateTestEntityPrimaryKey(otherEntity.primaryKey) %>]; - <%_ } else { _%> - const <%= reference.name %> : I<%= otherEntity.entityAngularName %> = <%- generateTestEntityPrimaryKey(otherEntity.primaryKey) %>; ->>>>>>> 6a2ff33b25 (generator-specific entity) <%_ } _%> <%= entityInstance %>.<%= reference.name %> = <%= reference.name %>; <%_ } _%> -<<<<<<< HEAD const <%= otherEntity.entityInstance %>Collection: I<%= otherEntity.entityAngularName %>[] = [<%- otherEntity.tsPrimaryKeySamples[0] %>]; -======= - const <%= otherEntity.entityInstance %>Collection: I<%= otherEntity.entityAngularName %>[] = [<%- generateTestEntityPrimaryKey(otherEntity.primaryKey) %>]; ->>>>>>> 6a2ff33b25 (generator-specific entity) jest.spyOn(<%= otherEntity.entityInstance %>Service, 'query').mockReturnValue(of(new HttpResponse({ body: <%= otherEntity.entityInstance %>Collection }))); const additional<%= otherEntity.entityAngularNamePlural %> = [ <%_ for (const relationship of relationshipsWithCustomSharedOptions) { _%> @@ -149,17 +130,10 @@ describe('<%= entityAngularName %> Management Update Component', () => { <%_ const reference = relationship.reference _%> it('Should call <%= reference.name %> query and add missing value', () => { const <%= entityInstance %> : I<%= entityAngularName %> = <%- testEntityPrimaryKey1 %>; -<<<<<<< HEAD const <%= reference.name %> : I<%= otherEntity.entityAngularName %> = <%- otherEntity.tsPrimaryKeySamples[0] %>; <%= entityInstance %>.<%= reference.name %> = <%= reference.name %>; const <%= reference.name %>Collection: I<%= otherEntity.entityAngularName %>[] = [<%- otherEntity.tsPrimaryKeySamples[0] %>]; -======= - const <%= reference.name %> : I<%= otherEntity.entityAngularName %> = <%- generateTestEntityPrimaryKey(otherEntity.primaryKey) %>; - <%= entityInstance %>.<%= reference.name %> = <%= reference.name %>; - - const <%= reference.name %>Collection: I<%= otherEntity.entityAngularName %>[] = [<%- generateTestEntityPrimaryKey(otherEntity.primaryKey) %>]; ->>>>>>> 6a2ff33b25 (generator-specific entity) jest.spyOn(<%= otherEntity.entityInstance %>Service, 'query').mockReturnValue(of(new HttpResponse({ body: <%= reference.name %>Collection }))); const expectedCollection: I<%= otherEntity.entityAngularName %>[] = [<%= reference.name %>, ...<%= reference.name %>Collection]; jest.spyOn(<%= otherEntity.entityInstance %>Service, 'add<%= otherEntity.entityAngularName %>ToCollectionIfMissing').mockReturnValue(expectedCollection); @@ -179,11 +153,7 @@ describe('<%= entityAngularName %> Management Update Component', () => { <%_ for (const relationshipsByEntityNeedingOptions of allRelationshipsByEntityNeedingOptions) { _%> <%_ for (const relationship of relationshipsByEntityNeedingOptions) { _%> <%_ const otherEntity = relationship.otherEntity _%> -<<<<<<< HEAD const <%= relationship.relationshipName %>: I<%= otherEntity.entityAngularName %> = <%- otherEntity.tsPrimaryKeySamples[0] %>; -======= - const <%= relationship.relationshipName %>: I<%= otherEntity.entityAngularName %> = <%- generateTestEntityPrimaryKey(otherEntity.primaryKey) %>; ->>>>>>> 6a2ff33b25 (generator-specific entity) <%= entityInstance %>.<%= relationship.reference.name %> = <%= relationship.collection ? `[${relationship.relationshipName}]` : relationship.relationshipName %>; <%_ } _%> <%_ } _%> @@ -284,13 +254,8 @@ _%> _%> describe('compare<%= otherEntity.entityAngularName %>', () => { it('Should forward to <%= otherEntity.entityInstance %>Service', () => { -<<<<<<< HEAD const entity = <%- otherEntity.tsPrimaryKeySamples[0] %>; const entity2 = <%- otherEntity.tsPrimaryKeySamples[1] %>; -======= - const entity = <%- generateTestEntityPrimaryKey(otherEntity.primaryKey, 0) %>; - const entity2 = <%- generateTestEntityPrimaryKey(otherEntity.primaryKey, 1) %>; ->>>>>>> 6a2ff33b25 (generator-specific entity) jest.spyOn(<%= otherEntity.entityInstance %>Service, 'compare<%= otherEntity.entityAngularName %>'); comp.compare<%= otherEntity.entityAngularName %>(entity, entity2); expect(<%= otherEntity.entityInstance %>Service.compare<%= otherEntity.entityAngularName %>).toHaveBeenCalledWith(entity, entity2); diff --git a/generators/angular/types-deprecated.d.ts b/generators/angular/types-partial.d.ts similarity index 91% rename from generators/angular/types-deprecated.d.ts rename to generators/angular/types-partial.d.ts index 8b87e0995352..d644bbf8de16 100644 --- a/generators/angular/types-deprecated.d.ts +++ b/generators/angular/types-partial.d.ts @@ -17,7 +17,7 @@ * limitations under the License. */ /** - * Will be deprecated and merged into AngularApplication + * @deprecated Will be deprecated and merged into types.d/AngularApplication */ export type PartialAngularApplication = { angularLocaleId: string; diff --git a/generators/angular/types.d.ts b/generators/angular/types.d.ts index 16072576f5b1..003bc6264e4a 100644 --- a/generators/angular/types.d.ts +++ b/generators/angular/types.d.ts @@ -27,7 +27,7 @@ export interface AngularEntity extends Entity { * @param wrapped if the value should be within quotes * @returns {string|number|string} */ - generateTestEntityId: (primaryKey: any, index?: number, wrapped?: boolean) => any; + generateTestEntityId: (primaryKey: any, index?: 0 | 1 | 'random', wrapped?: boolean) => any; /** * @private * Create a angular form path getter method of reference. diff --git a/generators/client/types.d.ts b/generators/client/types.d.ts index 71745d8453b0..e11e8c659ac0 100644 --- a/generators/client/types.d.ts +++ b/generators/client/types.d.ts @@ -3,7 +3,7 @@ import type { ExportApplicationPropertiesFromCommand } from '../../lib/command/i import type { CypressApplication } from '../cypress/types.js'; import type { JavaScriptApplication, JavaScriptSourceType } from '../javascript/types.js'; import type { PostWritingEntitiesTaskParam } from '../../lib/types/application/tasks.js'; -import type { PartialAngularApplication } from '../angular/types-deprecated.js'; +import type { PartialAngularApplication } from '../angular/types-partial.js'; import type Command from './command.ts'; type ApplicationClientProperties = ExportApplicationPropertiesFromCommand;