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

[cypress] Improve url patterns. #14599

Merged
merged 1 commit into from
Apr 7, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const skipCreateTest = (requiredRelationships.length > 0 || !entityFakeData) ? '
_%>

describe('<%= entityClass %> e2e test', () => {
const <%= entityInstance %>PageUrl = '/<%= entityUrl %>';
const <%= entityInstance %>PageUrlPattern = new RegExp('/<%= entityUrl %>(\\?.*)?$');

<%_ if (authenticationType === 'oauth2') { _%>
beforeEach(() => {
cy.getOauth2Data();
Expand Down Expand Up @@ -52,7 +55,7 @@ describe('<%= entityClass %> e2e test', () => {
<%_ } _%>

beforeEach(() => {
cy.intercept('GET', '/<%= baseApi + entityApiUrl %>').as('entitiesRequest');
cy.intercept('GET', '/<%= baseApi + entityApiUrl %>+(?*|)').as('entitiesRequest');
cy.intercept('POST', '/<%= baseApi + entityApiUrl %>').as('postEntityRequest');
cy.intercept('DELETE', '/<%= baseApi + entityApiUrl %>/*').as('deleteEntityRequest');
});
Expand All @@ -68,11 +71,11 @@ describe('<%= entityClass %> e2e test', () => {
}
});;
cy.getEntityHeading('<%= entityClass %>').should('exist');
cy.url().should('match', /\/<%= entityUrl %>(\?.*)?$/);
cy.url().should('match', <%= entityInstance %>PageUrlPattern);
});

it('should load details <%= entityClass %> page', function() {
cy.visit('/<%= entityUrl %>');
cy.visit(<%= entityInstance %>PageUrl);
cy.wait('@entitiesRequest').then(({ response }) => {
if (response.body.length === 0) {
this.skip();
Expand All @@ -84,12 +87,12 @@ describe('<%= entityClass %> e2e test', () => {
cy.wait('@entitiesRequest').then(({ response }) => {
expect(response.statusCode).to.equal(200);
});
cy.url().should('match', /\/<%= entityUrl %>(\?.*)?$/);
cy.url().should('match', <%= entityInstance %>PageUrlPattern);
});

<%_ if (!readOnly) { _%>
it('should load create <%= entityClass %> page', () => {
cy.visit('/<%= entityUrl %>');
cy.visit(<%= entityInstance %>PageUrl);
cy.wait('@entitiesRequest');
cy.get(entityCreateButtonSelector).click({force: true});
cy.getEntityCreateUpdateHeading('<%= entityClass %>');
Expand All @@ -98,11 +101,11 @@ describe('<%= entityClass %> e2e test', () => {
cy.wait('@entitiesRequest').then(({ response }) => {
expect(response.statusCode).to.equal(200);
});
cy.url().should('match', /\/<%= entityUrl %>(\?.*)?$/);
cy.url().should('match', <%= entityInstance %>PageUrlPattern);
});

it('should load edit <%= entityClass %> page', function() {
cy.visit('/<%= entityUrl %>');
cy.visit(<%= entityInstance %>PageUrl);
cy.wait('@entitiesRequest').then(({ response }) => {
if (response.body.length === 0) {
this.skip();
Expand All @@ -115,11 +118,11 @@ describe('<%= entityClass %> e2e test', () => {
cy.wait('@entitiesRequest').then(({ response }) => {
expect(response.statusCode).to.equal(200);
});
cy.url().should('match', /\/<%= entityUrl %>(\?.*)?$/);
cy.url().should('match', <%= entityInstance %>PageUrlPattern);
});

it<%= skipCreateTest %>('should create an instance of <%= entityClass %>', () => {
cy.visit('/<%= entityUrl %>');
cy.visit(<%= entityInstance %>PageUrl);
cy.get(entityCreateButtonSelector).click({force: true});
cy.getEntityCreateUpdateHeading('<%= entityClass %>');
<%_ fields.filter(field => (!field.id || !field.autoGenerate) && !field.hidden).forEach((field) => {
Expand Down Expand Up @@ -189,14 +192,14 @@ describe('<%= entityClass %> e2e test', () => {
cy.wait('@entitiesRequest').then(({ response }) => {
expect(response.statusCode).to.equal(200);
});
cy.url().should('match', /\/<%= entityUrl %>(\?.*)?$/);
cy.url().should('match', <%= entityInstance %>PageUrlPattern);
});

it<%= skipCreateTest %>('should delete last instance of <%= entityClass %>', function() {
<%_ if (clientFramework === 'react') { _%>
cy.intercept('GET', '/<%= baseApi + entityApiUrl %>/*').as('dialogDeleteRequest');
<%_ } _%>
cy.visit('/<%= entityUrl %>');
cy.visit(<%= entityInstance %>PageUrl);
cy.wait('@entitiesRequest').then(({ response }) => {
if (response.body.length > 0) {
cy.get(entityTableSelector).should('have.lengthOf', response.body.length);
Expand All @@ -212,7 +215,7 @@ describe('<%= entityClass %> e2e test', () => {
cy.wait('@entitiesRequest').then(({ response }) => {
expect(response.statusCode).to.equal(200);
});
cy.url().should('match', /\/<%= entityUrl %>(\?.*)?$/);
cy.url().should('match', <%= entityInstance %>PageUrlPattern);
} else {
this.skip();
}
Expand Down