Skip to content

Commit

Permalink
Merge pull request #16617 from mshima/skip_ci-cypress_entities
Browse files Browse the repository at this point in the history
Fixes some errors with cypress relationships support.
  • Loading branch information
DanielFran authored Oct 9, 2021
2 parents c53c3e0 + e494706 commit 2b031aa
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
5 changes: 2 additions & 3 deletions generators/entity-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const { entityClientI18nFiles } = require('../entity-i18n/files');
const utils = require('../utils');
const BaseBlueprintGenerator = require('../generator-base-blueprint');
const {
SUPPORTED_CLIENT_FRAMEWORKS: { ANGULAR, REACT },
SUPPORTED_CLIENT_FRAMEWORKS: { ANGULAR, REACT, VUE },
} = require('../generator-constants');
const { GENERATOR_ENTITY_CLIENT } = require('../generator-list');
const { SQL } = require('../../jdl/jhipster/database-types');
Expand Down Expand Up @@ -74,8 +74,7 @@ module.exports = class extends BaseBlueprintGenerator {
const entity = this.entity;
this.cypressBootstrapEntities =
(!entity.reactive || entity.databaseType !== SQL) &&
!(this.jhipsterConfig.clientFramework === ANGULAR && entity.paginationInfiniteScroll) &&
!entity.relationships.some(rel => rel.relationshipRequired && rel.collection);
(this.clientFramework !== VUE || !entity.relationships.some(rel => rel.relationshipRequired && rel.collection));
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('<%= entityAngularName %> Management Component', () => {
comp = fixture.componentInstance;
service = TestBed.inject(<%= entityAngularName %>Service);

const headers = new HttpHeaders().append('link', 'link;link');
const headers = new HttpHeaders();
jest.spyOn(service, 'query').mockReturnValue(
of(
new HttpResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ _%>

<%_ } else if (paginationInfiniteScroll) { _%>
protected paginate<%= entityClassPlural %>(data: I<%= entityAngularName %>[] | null, headers: HttpHeaders): void {
this.links = this.parseLinks.parse(headers.get('link') ?? '');
const linkHeader = headers.get('link');
if (linkHeader) {
this.links = this.parseLinks.parse(linkHeader);
} else {
this.links = {
last: 0,
};
}
if (data) {
for (const d of data) {
this.<%= entityInstancePlural %>.push(d);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ describe('<%= entityClass %> e2e test', () => {
const ownerSide = relationship.ownerSide;
const relationshipName = relationship.relationshipName;
_%>
cy.get(`[data-cy="<%= relationship.relationshipFieldName %>"]`).select(1);
cy.get(`[data-cy="<%= relationship.relationshipFieldName %>"]`).select(<%= relationship.collection ? '[0]' : '1' %>);
<%_ } _%>

<%_ if (fieldsContainBlobOrImage) { _%>
Expand Down
7 changes: 0 additions & 7 deletions test-integration/samples/.jhipster/JpaFilteringOtherSide.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
"relationshipName": "oneToOneOtherSide",
"ownerSide": false
},
{
"relationshipType": "many-to-one",
"otherEntityName": "jpaFilteringRelationship",
"otherEntityRelationshipName": "requiredOneToMany",
"relationshipName": "requiredOneToManyOtherSide",
"otherEntityField": "id"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "jpaFilteringRelationship",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@
"otherEntityField": "id",
"ownerSide": true
},
{
"relationshipType": "one-to-many",
"otherEntityName": "jpaFilteringOtherSide",
"otherEntityRelationshipName": "requiredOneToManyOtherSide",
"relationshipValidateRules": "required",
"relationshipName": "requiredOneToMany"
},
{
"relationshipType": "one-to-many",
"otherEntityName": "jpaFilteringOtherSide",
Expand Down

0 comments on commit 2b031aa

Please sign in to comment.