Skip to content

Commit

Permalink
Merge pull request #311 from SlateFoundation/develop
Browse files Browse the repository at this point in the history
Release: v2.16.11
  • Loading branch information
themightychris authored Dec 2, 2021
2 parents d3ee578 + e7c1c75 commit 0c6bfe3
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 59 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
GIT_DIR: ${{ github.workspace }}/.git
GIT_WORK_TREE: ${{ github.workspace }}
with:
browser: chrome
env: STUDIO_CONTAINER=,STUDIO_SSH=
working-directory: ${{ github.workspace }}.cypress-workspace

Expand Down
2 changes: 1 addition & 1 deletion .holo/sources/skeleton-v2.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[holosource]
url = "https://github.com/JarvusInnovations/emergence-skeleton-v2"
ref = "refs/tags/v2.8.7"
ref = "refs/tags/v2.8.9"
270 changes: 270 additions & 0 deletions cypress/integration/SlateAdmin/contacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
describe('SlateAdmin: Contacts', () => {

// reset database before tests
before(() => {
cy.resetDatabase();
});

it('Add and edit postal contact point', () => {
// login and open contact panel
cy.loginAs();
cy.visit('/manage#people/lookup/student/contacts');


// set up intercept for contact point save operations
cy.intercept('POST', '/contact-points/save?*').as('saveContactPoint');


// add and save a work address via composite string
cy.get('.contact-postal.slate-grid-phantom')
.scrollIntoView()
.contains('Add new')
.click();

cy.contains('.x-boundlist-item', 'Work Address')
.click();

cy.get('.contact-postal').last()
.should('have.class', 'slate-grid-phantom')
.find('.x-grid-cell:first-child')
.should('have.class', 'x-grid-dirty-cell');

cy.focused()
.type('908 N 3rd St, Suite B, Philadelphia, PA 19123{enter}');

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 1);

cy.get('.contact-postal').should('have.length', 3);

cy.get('.contact-postal').eq(-2)
.should('have.class', 'contact-primary')
.find('.x-grid-cell:first-child')
.should('not.have.class', 'x-grid-dirty-cell');


// edit and save address via form
cy.get('.contact-postal').eq(-2)
.contains('.contact-cell-value', '908 N 3rd St, Suite B, Philadelphia, PA 19123')
.click();

cy.focused()
.closest('.x-form-trigger-wrap')
.find('.x-form-trigger')
.click();

cy.get('.contact-postal-picker-form').within(() => {
cy.get('input[name=name]')
.click()
.type('Localhost');

cy.get('input[name=unit]')
.click()
.type('{selectall}{backspace}Suite A');

cy.contains('.x-btn-button', 'Save')
.click();
});

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 2);


// edit and save address via composite string
cy.get('.contact-postal').eq(-2)
.contains('.contact-cell-value', 'Localhost, 908 N 3rd St, Suite A, Philadelphia, PA 19123')
.click();

cy.focused()
.type('{backspace}'.repeat(22))
.type('Philly{enter}');

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 3);

cy.get('.contact-postal').eq(-2)
.contains('.contact-cell-value', 'Localhost, 908 N 3rd St, Suite A, Philly')
.within(() => {
cy.root()
.should('have.class', 'x-grid-dirty-cell')
.trigger('mouseover')
.should('have.attr', 'data-errorqtip')
.and('match', /Postal code or city\+state is required/i);

cy.root()
.click();

cy.focused()
.type(', PA{enter}');
});

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 4);

cy.get('.contact-postal').eq(-2)
.contains('.contact-cell-value', 'Localhost, 908 N 3rd St, Suite A, Philly, PA')


// add a second address via form
cy.get('.contact-postal.slate-grid-phantom').scrollIntoView()
.contains('Add new')
.click();

cy.contains('.x-boundlist-item', 'Home Address')
.click();

cy.focused()
.closest('.x-form-trigger-wrap')
.find('.x-form-trigger')
.click();

cy.get('.contact-postal-picker-form').within(() => {
cy.get('input[name=name]')
.click()
.type('The White House');

cy.get('input[name=number]')
.click()
.type('1600');

cy.get('input[name=street]')
.click()
.type('Pennsylvania Avenue NW');

cy.get('input[name=city]')
.click()
.type('Washington');

cy.get('input[name=state]')
.click()
.type('DC');

cy.get('input[name=postal]')
.click()
.type('20500');

cy.contains('.x-btn-button', 'Save')
.click();

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 5);
});

cy.get('.contact-postal').should('have.length', 4);


// verify new address and toggle primary
cy.get('.contact-postal').eq(-2)
.within(() => {
cy.root().should('not.have.class', 'slate-grid-phantom');
cy.root().should('not.have.class', 'contact-primary');

cy.get('.x-grid-cell').eq(0)
.should('not.have.class', 'x-grid-dirty-cell');

cy.get('.x-grid-cell').eq(1)
.should('not.have.class', 'x-grid-dirty-cell');

cy.contains('.contact-cell-value', 'The White House, 1600 Pennsylvania Avenue NW, Washington, DC 20500');

cy.intercept('POST', '/people/save?*').as('savePerson');

cy.get('.x-action-col-glyph.glyph-star')
.should('have.class', 'glyph-inactive')
.click();

cy.wait('@savePerson');
cy.get('@savePerson.all').should('have.length', 1);

cy.root().should('have.class', 'contact-primary');
});

cy.get('.contact-postal').eq(1)
.should('not.have.class', 'contact-primary');


// type in text field and then finish edit with form
cy.get('.contact-postal').eq(-2)
.find('.contact-cell-value')
.click();

cy.focused()
.clear()
.type('Hello world')
.closest('.x-form-trigger-wrap')
.find('.x-form-trigger')
.click();

cy.get('.contact-postal-picker-form').within(() => {
cy.get('input[name=unit]')
.click()
.type('{selectall}{backspace}Suite 123');

cy.contains('.x-btn-button', 'Save')
.click();
});

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 6);

cy.get('.contact-postal').eq(-2)
.contains('.contact-cell-value', 'The White House, 1600 Pennsylvania Avenue NW, Suite 123, Washington, DC 20500');


// save invalid via text field and then overwrite with form
cy.get('.contact-postal').eq(-3)
.find('.contact-cell-value')
.click();

cy.focused()
.clear()
.type('Hello world{enter}');

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 7);

cy.get('.contact-postal').eq(-3)
.contains('.contact-cell-value', 'Hello world')
.within(() => {
cy.root()
.should('have.class', 'x-grid-dirty-cell')
.trigger('mouseover')
.should('have.attr', 'data-errorqtip')
.and('match', /Street number is required/i)
.and('match', /Street name is required/i)
.and('match', /Postal code or city\+state is required/i);

cy.root()
.click();

cy.focused()
.closest('.x-form-trigger-wrap')
.find('.x-form-trigger')
.click();
});

cy.get('.contact-postal-picker-form').within(() => {
cy.get('input[name=city]')
.click()
.type('{selectall}{backspace}Philadelphia');

cy.get('input[name=postal]')
.click()
.type('19123');

cy.contains('.x-btn-button', 'Save')
.click();
});

cy.wait('@saveContactPoint');
cy.get('@saveContactPoint.all').should('have.length', 8);

cy.get('.contact-postal').eq(-3)
.contains('.contact-cell-value', 'Localhost, 908 N 3rd St, Suite A, Philadelphia, PA 19123')
.should('not.have.class', 'x-grid-dirty-cell')
.trigger('mouseover')
.should('have.attr', 'data-errorqtip', '');

});

});
2 changes: 1 addition & 1 deletion script/test
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ echo "==> test: setting up node_modules…"

echo
echo "==> test: executing \`cypress run\`"
(cd "${temp_path}" && npx cypress run)
(cd "${temp_path}" && npx cypress run --browser chrome)
32 changes: 19 additions & 13 deletions sencha-workspace/SlateAdmin/app/controller/people/Contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ Ext.define('SlateAdmin.controller.people.Contacts', {
],


statics: {
contactClassPrimaryFieldMap: {
'Emergence\\People\\ContactPoint\\Email': 'PrimaryEmailID',
'Emergence\\People\\ContactPoint\\Phone': 'PrimaryPhoneID',
'Emergence\\People\\ContactPoint\\Postal': 'PrimaryPostalID'
}
},


// controller config
views: [
'people.details.Contacts'
Expand Down Expand Up @@ -413,7 +422,8 @@ Ext.define('SlateAdmin.controller.people.Contacts', {
var me = this,
editedRecord = context.record,
gridView = context.view,
store = gridView.getStore();
loadedPerson = me.getContactsPanel().getLoadedPerson(),
primaryFieldName;

if (context.field == 'Label' && !editedRecord.get('String')) {
// auto advance to value column if the editor isn't already active after a short delay
Expand All @@ -436,6 +446,11 @@ Ext.define('SlateAdmin.controller.people.Contacts', {
gridView.markCellInvalid(editedRecord, 'value', result.validationErrors);
});

primaryFieldName = me.self.contactClassPrimaryFieldMap[editedRecord.get('Class')];
if (primaryFieldName && editedRecord.get('Primary')) {
loadedPerson.set(primaryFieldName, editedRecord.getId(), { dirty: false });
}

// ensure each class has a phantom row
me.injectBlankContactRecords();
}
Expand Down Expand Up @@ -468,18 +483,9 @@ Ext.define('SlateAdmin.controller.people.Contacts', {
loadedPerson = me.getContactsPanel().getLoadedPerson(),
primaryFieldName, originalValue, newValue, originalRecord;

switch (record.get('Class')) {
case 'Emergence\\People\\ContactPoint\\Email':
primaryFieldName = 'PrimaryEmailID';
break;
case 'Emergence\\People\\ContactPoint\\Phone':
primaryFieldName = 'PrimaryPhoneID';
break;
case 'Emergence\\People\\ContactPoint\\Postal':
primaryFieldName = 'PrimaryPostalID';
break;
default:
return false;
primaryFieldName = me.self.contactClassPrimaryFieldMap[record.get('Class')];
if (!primaryFieldName) {
return false;
}

originalValue = loadedPerson.get(primaryFieldName);
Expand Down
Loading

0 comments on commit 0c6bfe3

Please sign in to comment.