This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13335 from KevinGrandon/bug_924274_contact_tests
Bug 924274 - [Contacts] Add initial marionette tests
- Loading branch information
Showing
9 changed files
with
543 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
apps/communications/contacts/test/marionette/activities_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
var Contacts = require('./lib/contacts'); | ||
var Dialer = require('./lib/dialer'); | ||
var Sms = require('./lib/sms'); | ||
var assert = require('assert'); | ||
|
||
marionette('Contacts > Activities', function() { | ||
var client = marionette.client(Contacts.config); | ||
|
||
var dialerSubject; | ||
|
||
var smsSubject; | ||
var smsSelectors; | ||
|
||
var subject; | ||
var selectors; | ||
|
||
setup(function() { | ||
subject = new Contacts(client); | ||
selectors = Contacts.Selectors; | ||
|
||
dialerSubject = new Dialer(client); | ||
|
||
smsSubject = new Sms(client); | ||
smsSelectors = Sms.Selectors; | ||
}); | ||
|
||
suite('webcontacts/contact activity', function() { | ||
test('a contact with duplicate number shows merge page', function() { | ||
|
||
subject.launch(); | ||
|
||
subject.addContact({ | ||
givenName: 'From Contacts App', | ||
tel: 1111 | ||
}); | ||
|
||
client.apps.close(Contacts.URL, 'contacts'); | ||
|
||
dialerSubject.launch(); | ||
|
||
// Dialer keys don't work in b2g desktop for some reason yet, | ||
// So just manually fire off the activity | ||
client.executeScript(function() { | ||
var activity = new MozActivity({ | ||
name: 'new', | ||
data: { | ||
type: 'webcontacts/contact', | ||
params: { | ||
'tel': 1111 | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
client.switchToFrame(); | ||
client.apps.switchToApp(Contacts.URL, 'contacts'); | ||
|
||
subject.enterContactDetails({ | ||
givenName: 'From Dialer Activity' | ||
}, true); | ||
|
||
client.switchToFrame(client.findElement(selectors.duplicateFrame)); | ||
|
||
var duplicateHeader = client.helper. | ||
waitForElement(selectors.duplicateHeader); | ||
var expectedResult = subject.l10n( | ||
'/contacts/locales/matcher/matcher.en-US.properties', | ||
'duplicatesFoundTitle'); | ||
|
||
assert.equal(duplicateHeader.text(), expectedResult); | ||
}); | ||
}); | ||
|
||
suite('webcontacts/tel activity', function() { | ||
test('Error message when no contacts', function() { | ||
|
||
smsSubject.launch(); | ||
|
||
// Launch the activity directly as mozSms has problems | ||
// in b2g desktop. | ||
client.executeScript(function() { | ||
var activity = new MozActivity({ | ||
name: 'pick', | ||
data: { | ||
type: 'webcontacts/tel' | ||
} | ||
}); | ||
}); | ||
|
||
client.switchToFrame(); | ||
client.apps.switchToApp(Contacts.URL, 'contacts'); | ||
|
||
var confirmMsg = client.findElement(selectors.confirmBody); | ||
var expectedResult = subject.l10n( | ||
'/contacts/locales/contacts.en-US.properties', | ||
'noContactsActivity'); | ||
assert.equal(confirmMsg.text(), expectedResult); | ||
}); | ||
|
||
test('Error message selected contact has no number', function() { | ||
|
||
subject.launch(); | ||
|
||
subject.addContact({ | ||
givenName: 'No Phone Number' | ||
}); | ||
|
||
client.apps.close(Contacts.URL, 'contacts'); | ||
|
||
smsSubject.launch(); | ||
|
||
client.executeScript(function() { | ||
var activity = new MozActivity({ | ||
name: 'pick', | ||
data: { | ||
type: 'webcontacts/tel' | ||
} | ||
}); | ||
}); | ||
|
||
client.switchToFrame(); | ||
client.apps.switchToApp(Contacts.URL, 'contacts'); | ||
client.helper.waitForElement(selectors.bodyReady); | ||
|
||
client.helper.waitForElement(selectors.listContactFirst) | ||
.click(); | ||
|
||
var confirmText = client.helper.waitForElement(selectors.confirmBody) | ||
.text(); | ||
|
||
var expectedResult = subject.l10n( | ||
'/contacts/locales/contacts.en-US.properties', | ||
'no_contact_phones'); | ||
assert.equal(confirmText, expectedResult); | ||
}); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
apps/communications/contacts/test/marionette/details_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var Contacts = require('./lib/contacts'); | ||
var assert = require('assert'); | ||
|
||
marionette('Contacts > Details', function() { | ||
var client = marionette.client(Contacts.config); | ||
var subject; | ||
var selectors; | ||
|
||
setup(function() { | ||
subject = new Contacts(client); | ||
subject.launch(); | ||
|
||
selectors = Contacts.Selectors; | ||
}); | ||
|
||
suite('Click phone number', function() { | ||
test('Shows error /w no sim', function() { | ||
var tel = 1231231234; | ||
|
||
subject.addContact({ | ||
givenName: 'Hello', | ||
tel: 1231231234 | ||
}); | ||
|
||
client.helper.waitForElement(selectors.listContactFirstText) | ||
.click(); | ||
|
||
client.helper.waitForElement(selectors.details); | ||
|
||
client.helper.waitForElement(selectors.detailsTelButtonFirst) | ||
.click(); | ||
|
||
var header = client.helper.waitForElement(selectors.confirmHeader); | ||
|
||
var expectedHeaderText = subject.l10n( | ||
'/dialer/locales/shared.en-US.properties', | ||
'emergencyDialogTitle'); | ||
|
||
assert.equal(header.text(), expectedHeaderText); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
var Contacts = require('./lib/contacts'); | ||
var assert = require('assert'); | ||
|
||
marionette('Contacts > Form', function() { | ||
var client = marionette.client(Contacts.config); | ||
var subject; | ||
var selectors; | ||
|
||
setup(function() { | ||
subject = new Contacts(client); | ||
subject.launch(); | ||
|
||
selectors = Contacts.Selectors; | ||
}); | ||
|
||
suite('Click phone number', function() { | ||
test('Add a simple contact', function() { | ||
|
||
var givenName = 'Hello'; | ||
var familyName = 'World'; | ||
|
||
subject.addContact({ | ||
givenName: givenName, | ||
familyName: familyName | ||
}); | ||
|
||
var listView = client.helper.waitForElement(selectors.list); | ||
assert.ok(listView.displayed(), 'List view is shown.'); | ||
|
||
var listElementText = client.helper | ||
.waitForElement(selectors.listContactFirst) | ||
.text(); | ||
|
||
assert.notEqual(listElementText.indexOf(givenName), -1); | ||
assert.notEqual(listElementText.indexOf(familyName), -1); | ||
}); | ||
|
||
test('Can create custom label', function() { | ||
subject.addContact({ | ||
givenName: 'Custom Label Test', | ||
tel: 1231231234 | ||
}); | ||
|
||
client.helper.waitForElement(selectors.listContactFirstText) | ||
.click(); | ||
|
||
client.helper.waitForElement(selectors.details); | ||
client.helper.waitForElement(selectors.detailsEditContact) | ||
.click(); | ||
|
||
subject.waitForFormShown(); | ||
|
||
client.helper.waitForElement(selectors.formTelLabelFirst) | ||
.click(); | ||
|
||
client.helper.waitForElement(selectors.formCustomTag) | ||
.sendKeys('BFF'); | ||
|
||
client.helper.waitForElement(selectors.formCustomTagDone) | ||
.click(); | ||
|
||
// Wait for the custom tag page to disappear | ||
client.waitFor(function waiting() { | ||
var tagPage = client.findElement(selectors.formCustomTagPage); | ||
var className = tagPage.getAttribute('className'); | ||
return className.indexOf('app-go-left-in') === -1; | ||
}); | ||
|
||
client.findElement(selectors.formSave) | ||
.click(); | ||
|
||
client.helper.waitForElement(selectors.detailsTelLabelFirst); | ||
client.waitFor(function waiting() { | ||
var label = client.findElement(selectors.detailsTelLabelFirst).text(); | ||
return label === 'BFF'; | ||
}); | ||
assert.ok(true, 'custom label is updated.'); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.