Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fakerjs 8 deprecated method #22948

Merged
merged 4 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions generators/base-application/support/prepare-field.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ const { BYTES, BYTE_BUFFER } = RelationalOnlyDBTypes;
const fakeStringTemplateForFieldName = columnName => {
let fakeTemplate;
if (columnName === 'first_name') {
fakeTemplate = 'name.firstName';
fakeTemplate = 'person.firstName';
} else if (columnName === 'last_name') {
fakeTemplate = 'name.lastName';
fakeTemplate = 'person.lastName';
} else if (columnName === 'job_title') {
fakeTemplate = 'name.jobTitle';
fakeTemplate = 'person.jobTitle';
} else if (columnName === 'telephone' || columnName === 'phone') {
fakeTemplate = 'phone.number';
} else if (columnName === 'zip_code' || columnName === 'post_code') {
Expand Down Expand Up @@ -89,7 +89,7 @@ const fakeStringTemplateForFieldName = columnName => {
} else if (columnName === 'url') {
fakeTemplate = 'internet.url';
} else {
fakeTemplate = 'random.words';
fakeTemplate = 'word.words';
}
return `{{${fakeTemplate}}}`;
};
Expand Down
4 changes: 2 additions & 2 deletions generators/base/support/faker.mts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Faker, base } from '@faker-js/faker';
import { Faker, base, en } from '@faker-js/faker';
import Randexp from 'randexp';

import { languageToJavaLanguage } from '../../languages/support/index.mjs';
Expand Down Expand Up @@ -67,7 +67,7 @@ export async function createFaker(nativeLanguage = 'en') {
}

const faker = new FakerWithRandexp({
locale: [locale, base],
locale: [locale, base, en],
});
faker.createRandexp = (pattern, m) => new RandexpWithFaker(pattern, m, faker);
return faker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,11 @@ describe('<%= entityClass %> e2e test', () => {
<%_ fields.filter(field => (!field.id || !field.autoGenerate) && !field.hidden && !field.readonly).forEach((field) => {
const fieldName = field.fieldName;
const fieldIsEnum = field.fieldIsEnum;
const fieldValue = !entityFakeData ? field.generateFakeData('cypress') : entityFakeData[field.fieldName];
let fieldValue = !entityFakeData ? field.generateFakeData('cypress') : entityFakeData[field.fieldName];
if (fieldValue === undefined) {
return;
}
fieldValue = typeof fieldValue === 'string' ? fieldValue.replaceAll("'", "\\'") : fieldValue;
_%>

<%_ if (field.fieldTypeBoolean) { _%>
Expand All @@ -321,15 +322,15 @@ describe('<%= entityClass %> e2e test', () => {
cy.setFieldImageAsBytesOfEntity('<%= fieldName %>', 'integration-test.png', 'image/png');

<%_ } else if (fieldIsEnum) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).select('<%= fieldValue %>');
cy.get(`[data-cy="<%= fieldName %>"]`).select('<%- fieldValue %>');

<%_ } else if (field.fieldTypeString || field.fieldTypeNumeric || field.fieldTypeLocalDate || field.fieldTypeTimed || field.fieldTypeDuration) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%= fieldValue %>');
<% if (field.fieldTypeLocalDate || field.fieldTypeTimed || field.fieldTypeDuration) { %>cy.get(`[data-cy="<%= fieldName %>"]`).blur();<% } %> cy.get(`[data-cy="<%= fieldName %>"]`).should('have.value', '<%= fieldValue %>');
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%- fieldValue %>');
<% if (field.fieldTypeLocalDate || field.fieldTypeTimed || field.fieldTypeDuration) { %>cy.get(`[data-cy="<%= fieldName %>"]`).blur();<% } %> cy.get(`[data-cy="<%= fieldName %>"]`).should('have.value', '<%- fieldValue %>');

<%_ } else { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%= fieldValue %>');
cy.get(`[data-cy="<%= fieldName %>"]`).invoke('val').should('match', new RegExp('<%= fieldValue %>'));
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%- fieldValue %>');
cy.get(`[data-cy="<%= fieldName %>"]`).invoke('val').should('match', new RegExp('<%- fieldValue %>'));

<%_ } _%>
<%_ }); _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ ROLE_USER
},
"src/main/resources/config/liquibase/fake-data/20200102000100_entity_customer.csv": {
"contents": "id;foo
1;ubiquitous
2;Awesome Hydrogen fluid
3;New AI
4;Bicycle
5;Chicken Views Mobility
6;similique elaborate
7;Officer
8;Planner Gasoline
9;sexy
10;redefine
1;yuck
2;for atop
3;uncurl
4;elaborate through weep
5;hopelessly
6;easily almost obvious
7;unionize joyously gah
8;half ink
9;psst majestically swiftly
10;ragged
",
"stateCleared": "modified",
},
Expand Down Expand Up @@ -263,16 +263,16 @@ ROLE_USER
},
"src/main/resources/config/liquibase/fake-data/20200102000100_entity_customer.csv": {
"contents": "id;foo
1;ubiquitous
2;Awesome Hydrogen fluid
3;New AI
4;Bicycle
5;Chicken Views Mobility
6;similique elaborate
7;Officer
8;Planner Gasoline
9;sexy
10;redefine
1;yuck
2;for atop
3;uncurl
4;elaborate through weep
5;hopelessly
6;easily almost obvious
7;unionize joyously gah
8;half ink
9;psst majestically swiftly
10;ragged
",
"stateCleared": "modified",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ entity Customer {
entity: jdlApplicationEntitieWithByteTypes,
bytesFields: true,
testContent:
'1;geez;1369;../fake-data/blob/hipster.txt;../fake-data/blob/hipster.png;image/png;../fake-data/blob/hipster.png;image/png;Laptop;5650',
'1;so;27690;../fake-data/blob/hipster.txt;../fake-data/blob/hipster.png;image/png;../fake-data/blob/hipster.png;image/png;Desktop;28870',
contentRequired: true,
},
{
Expand Down