|
| 1 | +/* global describe, it, before */ |
| 2 | + |
| 3 | +const Brave = require('../lib/brave') |
| 4 | +const {urlInput, autofillAddressPanel, autofillCreditCardPanel} = require('../lib/selectors') |
| 5 | +const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil') |
| 6 | + |
| 7 | +describe('Autofill', function () { |
| 8 | + function * setup (client) { |
| 9 | + yield client |
| 10 | + .waitUntilWindowLoaded() |
| 11 | + .waitForUrl(Brave.newTabUrl) |
| 12 | + .waitForBrowserWindow() |
| 13 | + .waitForVisible('#window') |
| 14 | + .waitForVisible(urlInput) |
| 15 | + } |
| 16 | + |
| 17 | + describe('Data Management', function () { |
| 18 | + Brave.beforeAll(this) |
| 19 | + before(function * () { |
| 20 | + yield setup(this.app.client) |
| 21 | + }) |
| 22 | + const page1Url = 'about:autofill' |
| 23 | + const addAddressButton = '.addAddressButton' |
| 24 | + const saveAddressButton = '.saveAddressButton' |
| 25 | + const name = 'Brave Lion' |
| 26 | + const organization = 'Brave' |
| 27 | + const streetAddress = '1161 Mission Street, #401' |
| 28 | + const city = 'San Francisco' |
| 29 | + const state = 'CA' |
| 30 | + const postalCode = '94103-1550' |
| 31 | + const country = 'US' |
| 32 | + const phone = '0987654321' |
| 33 | + const email = 'press@brave.com' |
| 34 | + it('Adding Address', function * () { |
| 35 | + yield this.app.client |
| 36 | + .tabByIndex(0) |
| 37 | + .loadUrl(page1Url) |
| 38 | + .url(getTargetAboutUrl(page1Url)) |
| 39 | + .waitForVisible(addAddressButton) |
| 40 | + .click(addAddressButton) |
| 41 | + .windowByUrl(Brave.browserWindowUrl) |
| 42 | + .waitForVisible(autofillAddressPanel) |
| 43 | + .click('#nameOnAddress') |
| 44 | + .keys(name) |
| 45 | + .click('#organization') |
| 46 | + .keys(organization) |
| 47 | + .click('#streetAddress') |
| 48 | + .keys(streetAddress) |
| 49 | + .click('#city') |
| 50 | + .keys(city) |
| 51 | + .click('#state') |
| 52 | + .keys(state) |
| 53 | + .click('#postalCode') |
| 54 | + .keys(postalCode) |
| 55 | + .click('#country') |
| 56 | + .keys(country) |
| 57 | + .click('#phone') |
| 58 | + .keys(phone) |
| 59 | + .click('#email') |
| 60 | + .keys(email) |
| 61 | + .click(saveAddressButton) |
| 62 | + .waitUntil(function () { |
| 63 | + return this.getAppState().then((val) => { |
| 64 | + return val.value.autofill.addresses.length === 1 |
| 65 | + }) |
| 66 | + }) |
| 67 | + .tabByUrl(this.page1Url) |
| 68 | + .waitForVisible('.autofillPage') |
| 69 | + .getText('.addressName').should.eventually.be.equal(name) |
| 70 | + .getText('.organization').should.eventually.be.equal(organization) |
| 71 | + .getText('.streetAddress').should.eventually.be.equal(streetAddress) |
| 72 | + .getText('.city').should.eventually.be.equal(city) |
| 73 | + .getText('.state').should.eventually.be.equal(state) |
| 74 | + .getText('.postalCode').should.eventually.be.equal(postalCode) |
| 75 | + .getText('.country').should.eventually.be.equal(country) |
| 76 | + .getText('.phone').should.eventually.be.equal(phone) |
| 77 | + .getText('.email').should.eventually.be.equal(email) |
| 78 | + }) |
| 79 | + it('Address form test', function * () { |
| 80 | + const page1Url = 'https://www.roboform.com/filling-test-all-fields' |
| 81 | + yield this.app.client |
| 82 | + .tabByIndex(0) |
| 83 | + .loadUrl(page1Url) |
| 84 | + .url(getTargetAboutUrl(page1Url)) |
| 85 | + .waitForVisible('<form>') |
| 86 | + .click('[name="04fullname"]') |
| 87 | + .click('[name="04fullname"]') |
| 88 | + .windowByUrl(Brave.browserWindowUrl) |
| 89 | + .ipcSendRenderer('autofill-selection-clicked', 2, name, 1, 0) |
| 90 | + .setContextMenuDetail() |
| 91 | + .tabByUrl(this.page1Url) |
| 92 | + .getValue('[name="04fullname"]').should.eventually.be.equal(name) |
| 93 | + }) |
| 94 | + it('Editing Address', function * () { |
| 95 | + yield this.app.client |
| 96 | + .tabByIndex(0) |
| 97 | + .loadUrl(page1Url) |
| 98 | + .url(getTargetAboutUrl(page1Url)) |
| 99 | + .waitForVisible('[title="Edit address"]') |
| 100 | + .click('[title="Edit address"]') |
| 101 | + .windowByUrl(Brave.browserWindowUrl) |
| 102 | + .waitForVisible(autofillAddressPanel) |
| 103 | + .click('#phone') |
| 104 | + .keys('123') |
| 105 | + .click('#email') |
| 106 | + .keys('mm') |
| 107 | + .click(saveAddressButton) |
| 108 | + .waitUntil(function () { |
| 109 | + return this.getAppState().then((val) => { |
| 110 | + return val.value.autofill.addresses.length === 1 |
| 111 | + }) |
| 112 | + }) |
| 113 | + .tabByUrl(this.page1Url) |
| 114 | + .waitForVisible('.autofillPage') |
| 115 | + .getText('.addressName').should.eventually.be.equal(name) |
| 116 | + .getText('.organization').should.eventually.be.equal(organization) |
| 117 | + .getText('.streetAddress').should.eventually.be.equal(streetAddress) |
| 118 | + .getText('.city').should.eventually.be.equal(city) |
| 119 | + .getText('.state').should.eventually.be.equal(state) |
| 120 | + .getText('.postalCode').should.eventually.be.equal(postalCode) |
| 121 | + .getText('.country').should.eventually.be.equal(country) |
| 122 | + .getText('.phone').should.eventually.be.equal(phone + '123') |
| 123 | + .getText('.email').should.eventually.be.equal(email + 'mm') |
| 124 | + }) |
| 125 | + it('Edited Address form test', function * () { |
| 126 | + const page1Url = 'https://www.roboform.com/filling-test-all-fields' |
| 127 | + yield this.app.client |
| 128 | + .tabByIndex(0) |
| 129 | + .loadUrl(page1Url) |
| 130 | + .url(getTargetAboutUrl(page1Url)) |
| 131 | + .waitForVisible('<form>') |
| 132 | + .click('[name="04fullname"]') |
| 133 | + .click('[name="04fullname"]') |
| 134 | + .windowByUrl(Brave.browserWindowUrl) |
| 135 | + .ipcSendRenderer('autofill-selection-clicked', 2, name, 1, 0) |
| 136 | + .setContextMenuDetail() |
| 137 | + .tabByUrl(this.page1Url) |
| 138 | + .getValue('[name="04fullname"]').should.eventually.be.equal(name) |
| 139 | + .getValue('[name="23cellphon"]').should.eventually.be.equal(phone + '123') |
| 140 | + .getValue('[name="24emailadr"]').should.eventually.be.equal(email + 'mm') |
| 141 | + }) |
| 142 | + it('Deleting Address', function * () { |
| 143 | + yield this.app.client |
| 144 | + .tabByIndex(0) |
| 145 | + .loadUrl(page1Url) |
| 146 | + .url(getTargetAboutUrl(page1Url)) |
| 147 | + .waitForVisible('[title="Delete address"]') |
| 148 | + .click('[title="Delete address"]') |
| 149 | + .waitForVisible('[data-l10n-id=noAddressesSaved]') |
| 150 | + }) |
| 151 | + const addCreditCardButton = '.addCreditCardButton' |
| 152 | + const saveCreditCardButton = '.saveCreditCardButton' |
| 153 | + const cardName = 'Test Card' |
| 154 | + const cardNumber = '1234567890' |
| 155 | + const expMonth = 10 |
| 156 | + const expYear = new Date().getFullYear() + 2 |
| 157 | + it('Adding Credit Card', function * () { |
| 158 | + yield this.app.client |
| 159 | + .tabByIndex(0) |
| 160 | + .loadUrl(page1Url) |
| 161 | + .url(getTargetAboutUrl(page1Url)) |
| 162 | + .waitForVisible(addCreditCardButton) |
| 163 | + .click(addCreditCardButton) |
| 164 | + .windowByUrl(Brave.browserWindowUrl) |
| 165 | + .waitForVisible(autofillCreditCardPanel) |
| 166 | + .click('#nameOnCard') |
| 167 | + .keys(cardName) |
| 168 | + .click('#creditCardNumber') |
| 169 | + .keys(cardNumber) |
| 170 | + .selectByValue('.expMonthSelect', expMonth.toString()) |
| 171 | + .selectByValue('.expYearSelect', expYear.toString()) |
| 172 | + .click(saveCreditCardButton) |
| 173 | + .waitUntil(function () { |
| 174 | + return this.getAppState().then((val) => { |
| 175 | + return val.value.autofill.creditCards.length === 1 |
| 176 | + }) |
| 177 | + }) |
| 178 | + .tabByUrl(this.page1Url) |
| 179 | + .waitForVisible('.autofillPage') |
| 180 | + .getText('.creditCardName').should.eventually.be.equal(cardName) |
| 181 | + .getText('.creditCardNumber').should.eventually.be.equal('***' + cardNumber.slice(-4)) |
| 182 | + .getText('.creditCardPExpirationDate').should.eventually.be.equal(expMonth.toString() + '/' + expYear.toString()) |
| 183 | + }) |
| 184 | + it('Credit Card form test', function * () { |
| 185 | + const page1Url = 'https://www.roboform.com/filling-test-all-fields' |
| 186 | + yield this.app.client |
| 187 | + .tabByIndex(0) |
| 188 | + .loadUrl(page1Url) |
| 189 | + .url(getTargetAboutUrl(page1Url)) |
| 190 | + .waitForVisible('<form>') |
| 191 | + .click('[name="41ccnumber"]') |
| 192 | + .click('[name="41ccnumber"]') |
| 193 | + .windowByUrl(Brave.browserWindowUrl) |
| 194 | + .ipcSendRenderer('autofill-selection-clicked', 2, cardNumber, 65536, 0) |
| 195 | + .setContextMenuDetail() |
| 196 | + .tabByUrl(this.page1Url) |
| 197 | + .getValue('[name="41ccnumber"]').should.eventually.be.equal(cardNumber) |
| 198 | + .getValue('[name="42ccexp_mm"]').should.eventually.be.equal(expMonth.toString()) |
| 199 | + .getValue('[name="43ccexp_yy"]').should.eventually.be.equal(expYear.toString()) |
| 200 | + }) |
| 201 | + it('Editing Credit Card', function * () { |
| 202 | + yield this.app.client |
| 203 | + .tabByIndex(0) |
| 204 | + .loadUrl(page1Url) |
| 205 | + .url(getTargetAboutUrl(page1Url)) |
| 206 | + .waitForVisible('[title="Edit creditCard"]') |
| 207 | + .click('[title="Edit creditCard"]') |
| 208 | + .windowByUrl(Brave.browserWindowUrl) |
| 209 | + .waitForVisible(autofillCreditCardPanel) |
| 210 | + .click('#nameOnCard') |
| 211 | + .keys('123') |
| 212 | + .click('#creditCardNumber') |
| 213 | + .keys('123') |
| 214 | + .selectByValue('.expMonthSelect', (expMonth + 1).toString()) |
| 215 | + .selectByValue('.expYearSelect', (expYear + 1).toString()) |
| 216 | + .click(saveCreditCardButton) |
| 217 | + .waitUntil(function () { |
| 218 | + return this.getAppState().then((val) => { |
| 219 | + return val.value.autofill.creditCards.length === 1 |
| 220 | + }) |
| 221 | + }) |
| 222 | + .tabByUrl(this.page1Url) |
| 223 | + .waitForVisible('.autofillPage') |
| 224 | + .getText('.creditCardName').should.eventually.be.equal(cardName + 123) |
| 225 | + .getText('.creditCardNumber').should.eventually.be.equal('***' + (cardNumber + 123).slice(-4)) |
| 226 | + .getText('.creditCardPExpirationDate').should.eventually.be.equal( |
| 227 | + (expMonth + 1).toString() + '/' + (expYear + 1).toString()) |
| 228 | + }) |
| 229 | + it('Edited Credit Card form test', function * () { |
| 230 | + const page1Url = 'https://www.roboform.com/filling-test-all-fields' |
| 231 | + yield this.app.client |
| 232 | + .tabByIndex(0) |
| 233 | + .loadUrl(page1Url) |
| 234 | + .url(getTargetAboutUrl(page1Url)) |
| 235 | + .waitForVisible('<form>') |
| 236 | + .click('[name="41ccnumber"]') |
| 237 | + .click('[name="41ccnumber"]') |
| 238 | + .windowByUrl(Brave.browserWindowUrl) |
| 239 | + .ipcSendRenderer('autofill-selection-clicked', 2, cardNumber, 65536, 0) |
| 240 | + .setContextMenuDetail() |
| 241 | + .tabByUrl(this.page1Url) |
| 242 | + .getValue('[name="41ccnumber"]').should.eventually.be.equal(cardNumber + '123') |
| 243 | + .getValue('[name="42ccexp_mm"]').should.eventually.be.equal((expMonth + 1).toString()) |
| 244 | + .getValue('[name="43ccexp_yy"]').should.eventually.be.equal((expYear + 1).toString()) |
| 245 | + }) |
| 246 | + it('Deleting Credit Card', function * () { |
| 247 | + yield this.app.client |
| 248 | + .tabByIndex(0) |
| 249 | + .loadUrl(page1Url) |
| 250 | + .url(getTargetAboutUrl(page1Url)) |
| 251 | + .waitForVisible('[title="Delete creditCard"]') |
| 252 | + .click('[title="Delete creditCard"]') |
| 253 | + .waitForVisible('[data-l10n-id=noCreditCardsSaved]') |
| 254 | + }) |
| 255 | + }) |
| 256 | +}) |
0 commit comments