Skip to content

Commit

Permalink
Merge pull request #902 from ORCID/cy-check-for-disabled-sf-id-field
Browse files Browse the repository at this point in the history
Cy check for disabled sf id field
  • Loading branch information
bobcaprice authored Jan 31, 2023
2 parents 3adca83 + af3decc commit d975d3e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 71 deletions.
145 changes: 78 additions & 67 deletions gateway/cypress/integration/retention/add-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,84 @@ const { salesforceId, clientName, clientId } = data.member;
describe('Test "Add member" functionality', () => {
it('Add member', function() {
cy.programmaticSignin(credentials.adminEmail, credentials.adminPassword);
cy.visit('/member/new');
// Check required field flags
cy.get('#field_salesforceId').should('have.class', 'ng-invalid');
cy.get('#field_clientName').should('have.class', 'ng-invalid');
// Save button should be disabled
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
// Check salesforce id warning message when field is clear
cy.get('#field_salesforceId')
.type(salesforceId)
.clear();
cy.get('small').should('exist');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
// Enter existing salesforce id to generate an error
cy.get('#field_salesforceId').type(salesforceId);
cy.get('#field_parentSalesforceId')
.type(clientName);
// Enter invalid client name to generate an error
cy.get('#field_clientName')
.type(data.invalidString)
.clear();
cy.get('small').should('exist');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_clientName').type(data.populatedMember.clientName);
cy.get('#save-entity').click();
// Two error messages should appear for existing salesforce id and member name
cy.get('.validation-errors')
cy.visit('/member');
cy.get('tbody')
.children()
.should('have.length', 2);
// Enter invalid client id to generate an error
cy.get('#field_clientId').type(data.invalidString);
cy.get('small').should('exist');
// Check for flag on client id input field
cy.get('#field_clientId').should('have.class', 'ng-invalid');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
// Check the enable assertions checkbox
cy.get('#field_assertionServiceEnabled').check();
cy.get('#field_clientId')
.clear()
.type(clientId);
cy.get('#field_clientName')
.clear()
.type(clientName);
// Checkbox should be unchecked after clearing client id field
cy.get('#field_assertionServiceEnabled')
.should('not.be.checked')
.check();
// Parent salesforce id for consortium lead members must match salesforce id or be blank
cy.get('#field_isConsortiumLead')
.should('not.be.checked')
.check();
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_parentSalesforceId')
.clear()
.type(salesforceId);
// Save button should be clickable
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('not.exist');
// Fetch existing salesforce id
.first().children().first().then(existingSfId => {
// Check required field flags
cy.visit('/member/new')
cy.get('#field_salesforceId').should('have.class', 'ng-invalid');
cy.get('#field_clientName').should('have.class', 'ng-invalid');
// Save button should be disabled
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
// Check salesforce id warning message when field is clear
cy.get('#field_salesforceId')
.type(salesforceId)
.clear();
cy.get('small').should('exist');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
// Enter existing salesforce id to generate an error
cy.get('#field_salesforceId').type(existingSfId.text());
cy.get('#field_parentSalesforceId').type(clientName);
// Enter invalid client name to generate an error
cy.get('#field_clientName')
.type(data.invalidString)
.clear();
cy.get('small').should('exist');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_clientName').type(data.populatedMember.clientName);
cy.get('#save-entity').click();
// Two error messages should appear for existing salesforce id and member name
cy.get('.validation-errors')
.children()
.should('have.length', 2);
// Enter invalid client id to generate an error
cy.get('#field_clientId').type(data.invalidString);
cy.get('small').should('exist');
// Check for flag on client id input field
cy.get('#field_clientId').should('have.class', 'ng-invalid');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
// Check the enable assertions checkbox
cy.get('#field_assertionServiceEnabled').check();
cy.get('#field_clientId')
.clear()
.type(clientId);
cy.get('#field_clientName')
.clear()
.type(clientName);
// Checkbox should be unchecked after clearing client id field
cy.get('#field_assertionServiceEnabled')
.should('not.be.checked')
.check();
// Parent salesforce id for consortium lead members must match salesforce id or be blank
cy.get('#field_isConsortiumLead')
.should('not.be.checked')
.check();
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_parentSalesforceId')
.clear()
.type(salesforceId);
// Save button should still be disabled due to invalid parent SF id
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_parentSalesforceId')
.clear()
.type(existingSfId.text());
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('not.exist');
});
});
});
17 changes: 14 additions & 3 deletions gateway/cypress/integration/retention/edit-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ describe('Manage members menu', () => {
cy.get('#field_isConsortiumLead')
.should('be.checked')
.uncheck();
// cy.get('#field_salesforceId').invoke('attr', 'disabled')
// .should('exist');
cy.get('#field_salesforceId')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_parentSalesforceId')
.clear()
.type(clientName);
Expand Down Expand Up @@ -54,6 +55,16 @@ describe('Manage members menu', () => {
cy.get('#field_parentSalesforceId')
.clear()
.type(salesforceId);
cy.get('#save-entity').click();
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_salesforceId')
.invoke('val')
.then(id => {
cy.get('#field_parentSalesforceId')
.clear()
.type(id);
cy.get('#save-entity').click();
});
});
});
2 changes: 1 addition & 1 deletion gateway/cypress/integration/retention/ui-homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Test homepage', () => {
cy.get('.side-bar').contains("Public details")
cy.get('.side-bar').contains("Website")
cy.get('.side-bar').contains("Email")
cy.get('.side-bar').contains("https://www.testtest.com")
cy.get('.side-bar').contains("http://testtest.com")
cy.get('.side-bar').contains("No email added")
cy.get('.main-section').contains("Consortium lead")
cy.get('.main-section').contains("Mambo No 5")
Expand Down

0 comments on commit d975d3e

Please sign in to comment.