Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 983777 - [B2G][Contacts] Tapping the Favorite button on an imported facebook contact will break the Edit Contact button #17288

Merged
merged 1 commit into from Mar 19, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions apps/communications/contacts/js/contacts.js
Expand Up @@ -766,10 +766,8 @@ var Contacts = (function() {
contactsList.getContactById(event.contactID,
function success(contact, enrichedContact) {
currentContact = contact;
var mergedContact = enrichedContact || contact;
contactsDetails.setContact(mergedContact);
contactsDetails.render(mergedContact, null, enrichedContact);
contactsList.refresh(mergedContact, checkPendingChanges,
contactsDetails.render(currentContact, null, enrichedContact);
contactsList.refresh(currentContact, checkPendingChanges,
event.reason);
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/communications/contacts/js/views/details.js
Expand Up @@ -241,7 +241,7 @@ contacts.Details = (function() {
}
var pos = contact.category.indexOf('favorite');
if (pos > -1) {
delete contact.category[pos];
contact.category.splice(pos, 1);
}
}

Expand Down
55 changes: 55 additions & 0 deletions apps/communications/contacts/test/marionette/details_test.js
Expand Up @@ -2,6 +2,7 @@

var Contacts = require('./lib/contacts');
var assert = require('assert');
var fs = require('fs');

marionette('Contacts > Details', function() {
var client = marionette.client(Contacts.config);
Expand Down Expand Up @@ -93,4 +94,58 @@ marionette('Contacts > Details', function() {
assert.equal(formContactName.getAttribute('value'), clickedContactName);
});

test('Favorite FB contact and edit it', function() {
client.importScript(fs.readFileSync(__dirname +
'/data/facebook_contact_data.js',
'utf8'));
var saveFBContact = function() {
var fb = window.wrappedJSObject.fb,
data = window.wrappedJSObject.data;

var fbContact = new fb.Contact();
fbContact.setData(data.fbContactData);

var savingFBContact = fbContact.save();

savingFBContact.onsuccess = function() {
marionetteScriptFinished(data.fbContactData);
};

savingFBContact.onerror = function() {
marionetteScriptFinished();
};
};

var fbContactData;
client.executeAsyncScript(saveFBContact, function(err, val) {
fbContactData = val;
});

client.waitFor(function() {
return fbContactData;
});

client.helper.waitForElement(selectors.listContactFirstText)
.click();

subject.waitSlideLeft('details');

// Check we loaded the FB contact
var telNode = client.helper.waitForElement(selectors.detailsTelButtonFirst);
assert.equal(telNode.text(), '+34666666666');

// It's not a favorite
var nameNode = client.helper.waitForElement(selectors.detailsContactName);
assert.equal(nameNode.getAttribute('class').indexOf('favorite'), -1);

// Click on favorite
client.helper.waitForElement(selectors.detailsFavoriteButton).click();
nameNode = client.helper.waitForElement(selectors.detailsContactName);
assert.notEqual(nameNode.getAttribute('class').indexOf('favorite'), -1);

// Click on edit and go to the edit form
client.helper.waitForElement(selectors.detailsEditContact).click();
subject.waitForFormShown();
});

});
2 changes: 2 additions & 0 deletions apps/communications/contacts/test/marionette/lib/contacts.js
Expand Up @@ -34,6 +34,8 @@ Contacts.Selectors = {
detailsTelLabelFirst: '#phone-details-template-0 h2',
detailsTelButtonFirst: 'button.icon-call[data-tel]',
detailsFindDuplicate: '#contact-detail-inner #find-merge-button',
detailsFavoriteButton: '#toggle-favorite',
detailsContactName: '#contact-name-title',

duplicateFrame: 'iframe[src*="matching_contacts.html"]',
duplicateHeader: '#title',
Expand Down