|
2 | 2 |
|
3 | 3 | const Brave = require('../lib/brave')
|
4 | 4 | const messages = require('../../js/constants/messages')
|
5 |
| -const {urlInput, autofillAddressPanel, autofillCreditCardPanel} = require('../lib/selectors') |
| 5 | +const {urlInput, autofillAddressPanel, autofillCreditCardPanel, clearBrowsingDataButton, securityTab} = require('../lib/selectors') |
6 | 6 | const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil')
|
7 | 7 |
|
8 | 8 | const addAddressButton = '.addAddressButton'
|
@@ -302,6 +302,151 @@ describe('Autofill', function () {
|
302 | 302 | })
|
303 | 303 | })
|
304 | 304 |
|
| 305 | + describe('clear autofill data', function () { |
| 306 | + Brave.beforeAll(this) |
| 307 | + before(function * () { |
| 308 | + yield setup(this.app.client) |
| 309 | + this.autofillPreferences = 'about:autofill' |
| 310 | + this.formfill = Brave.server.url('formfill.html') |
| 311 | + |
| 312 | + yield this.app.client |
| 313 | + .tabByIndex(0) |
| 314 | + .loadUrl(this.autofillPreferences) |
| 315 | + .waitForVisible(addAddressButton) |
| 316 | + .click(addAddressButton) |
| 317 | + .windowByUrl(Brave.browserWindowUrl) |
| 318 | + .waitForVisible(autofillAddressPanel) |
| 319 | + .click('#nameOnAddress') |
| 320 | + .keys(name) |
| 321 | + .click('#organization') |
| 322 | + .keys(organization) |
| 323 | + .click('#streetAddress') |
| 324 | + .keys(streetAddress) |
| 325 | + .click('#city') |
| 326 | + .keys(city) |
| 327 | + .click('#state') |
| 328 | + .keys(state) |
| 329 | + .click('#postalCode') |
| 330 | + .keys(postalCode) |
| 331 | + .click('#country') |
| 332 | + .keys(country) |
| 333 | + .click('#phone') |
| 334 | + .keys(phone) |
| 335 | + .click('#email') |
| 336 | + .keys(email) |
| 337 | + .click(saveAddressButton) |
| 338 | + .waitUntil(function () { |
| 339 | + return this.getAppState().then((val) => { |
| 340 | + return val.value.autofill.addresses.guid.length === 1 |
| 341 | + }) |
| 342 | + }) |
| 343 | + .tabByIndex(0) |
| 344 | + .loadUrl(this.autofillPreferences) |
| 345 | + .waitForVisible(addCreditCardButton) |
| 346 | + .click(addCreditCardButton) |
| 347 | + .windowByUrl(Brave.browserWindowUrl) |
| 348 | + .waitForVisible(autofillCreditCardPanel) |
| 349 | + .click('#nameOnCard') |
| 350 | + .keys(cardName) |
| 351 | + .click('#creditCardNumber') |
| 352 | + .keys(cardNumber) |
| 353 | + .selectByValue('.expMonthSelect', expMonth < 10 ? '0' + expMonth.toString() : expMonth.toString()) |
| 354 | + .selectByValue('.expYearSelect', expYear.toString()) |
| 355 | + .click(saveCreditCardButton) |
| 356 | + .waitUntil(function () { |
| 357 | + return this.getAppState().then((val) => { |
| 358 | + return val.value.autofill.creditCards.guid.length === 1 |
| 359 | + }) |
| 360 | + }) |
| 361 | + .tabByIndex(0) |
| 362 | + .loadUrl(this.autofillPreferences) |
| 363 | + }) |
| 364 | + it('adds an autofill address', function * () { |
| 365 | + yield this.app.client |
| 366 | + .waitForVisible('.autofillPage') |
| 367 | + .getText('.addressName').should.eventually.be.equal(name) |
| 368 | + .getText('.organization').should.eventually.be.equal(organization) |
| 369 | + .getText('.streetAddress').should.eventually.be.equal(streetAddress) |
| 370 | + .getText('.city').should.eventually.be.equal(city) |
| 371 | + .getText('.state').should.eventually.be.equal(state) |
| 372 | + .getText('.postalCode').should.eventually.be.equal(postalCode) |
| 373 | + .getText('.country').should.eventually.be.equal(country) |
| 374 | + .getText('.phone').should.eventually.be.equal(phone) |
| 375 | + .getText('.email').should.eventually.be.equal(email) |
| 376 | + }) |
| 377 | + it('adds an autofill credit card', function * () { |
| 378 | + yield this.app.client |
| 379 | + .waitForVisible('.autofillPage') |
| 380 | + .getText('.creditCardName').should.eventually.be.equal(cardName) |
| 381 | + .getText('.creditCardNumber').should.eventually.be.equal('***' + cardNumber.slice(-4)) |
| 382 | + .getText('.creditCardPExpirationDate').should.eventually.be.equal( |
| 383 | + (expMonth < 10 ? '0' + expMonth.toString() : expMonth.toString()) + '/' + expYear.toString()) |
| 384 | + }) |
| 385 | + it('autofills the address', function * () { |
| 386 | + yield this.app.client |
| 387 | + .tabByIndex(0) |
| 388 | + .loadUrl(this.formfill) |
| 389 | + .waitForVisible('<form>') |
| 390 | + .click('[name="04fullname"]') |
| 391 | + .click('[name="04fullname"]') |
| 392 | + .windowByUrl(Brave.browserWindowUrl) |
| 393 | + .waitForVisible('.contextMenuItemText') |
| 394 | + .click('.contextMenuItemText') |
| 395 | + .tabByUrl(this.formfill) |
| 396 | + .getValue('[name="04fullname"]').should.eventually.be.equal(name) |
| 397 | + .getValue('[name="23cellphon"]').should.eventually.be.equal(phone) |
| 398 | + .getValue('[name="24emailadr"]').should.eventually.be.equal(email) |
| 399 | + // TODO(bridiver) - this needs to check all fields |
| 400 | + }) |
| 401 | + it('autofills the credit card', function * () { |
| 402 | + yield this.app.client |
| 403 | + .tabByIndex(0) |
| 404 | + .loadUrl(this.formfill) |
| 405 | + .waitForVisible('<form>') |
| 406 | + .click('[name="41ccnumber"]') |
| 407 | + .click('[name="41ccnumber"]') |
| 408 | + .windowByUrl(Brave.browserWindowUrl) |
| 409 | + .waitForVisible('.contextMenuItemText') |
| 410 | + .click('.contextMenuItemText') |
| 411 | + .tabByUrl(this.formfill) |
| 412 | + .getValue('[name="41ccnumber"]').should.eventually.be.equal(cardNumber) |
| 413 | + .getValue('[name="42ccexp_mm"]').should.eventually.be.equal(expMonth.toString()) |
| 414 | + .getValue('[name="43ccexp_yy"]').should.eventually.be.equal(expYear.toString()) |
| 415 | + }) |
| 416 | + it('clear data now', function * () { |
| 417 | + yield this.app.client |
| 418 | + .tabByIndex(0) |
| 419 | + .loadUrl(getTargetAboutUrl('about:preferences')) |
| 420 | + .waitForVisible(securityTab) |
| 421 | + .click(securityTab) |
| 422 | + .waitForVisible(clearBrowsingDataButton) |
| 423 | + .click(clearBrowsingDataButton) |
| 424 | + .waitForBrowserWindow() |
| 425 | + .waitForVisible('.autofillDataSwitch') |
| 426 | + .click('.autofillDataSwitch .switchMiddle') |
| 427 | + .waitForVisible('.clearDataButton') |
| 428 | + .click('.clearDataButton') |
| 429 | + }) |
| 430 | + it('does not autofill in regular tab', function * () { |
| 431 | + yield this.app.client |
| 432 | + .windowByUrl(Brave.browserWindowUrl) |
| 433 | + .ipcSend(messages.SHORTCUT_NEW_FRAME, this.formfill) |
| 434 | + .waitForUrl(this.formfill) |
| 435 | + .waitForVisible('<form>') |
| 436 | + .click('[name="04fullname"]') |
| 437 | + .click('[name="04fullname"]') |
| 438 | + .windowByUrl(Brave.browserWindowUrl) |
| 439 | + .waitForExist('contextMenuItemText', 500, true) |
| 440 | + .tabByIndex(0) |
| 441 | + .getValue('[name="04fullname"]').should.eventually.be.equal('') |
| 442 | + .click('[name="41ccnumber"]') |
| 443 | + .click('[name="41ccnumber"]') |
| 444 | + .waitForExist('contextMenuItemText', 500, true) |
| 445 | + .tabByIndex(0) |
| 446 | + .getValue('[name="41ccnumber"]').should.eventually.be.equal('') |
| 447 | + }) |
| 448 | + }) |
| 449 | + |
305 | 450 | describe('ad-hoc autofill', function () {
|
306 | 451 | describe('regular tab', function () {
|
307 | 452 | Brave.beforeAll(this)
|
@@ -419,5 +564,57 @@ describe('Autofill', function () {
|
419 | 564 | .getValue('[name="04fullname"]').should.eventually.be.equal('')
|
420 | 565 | })
|
421 | 566 | })
|
| 567 | + describe('clear autocomplete data', function () { |
| 568 | + Brave.beforeAll(this) |
| 569 | + before(function * () { |
| 570 | + yield setup(this.app.client) |
| 571 | + this.formfill = Brave.server.url('formfill.html') |
| 572 | + yield this.app.client |
| 573 | + .tabByIndex(0) |
| 574 | + .loadUrl(this.formfill) |
| 575 | + .waitForVisible('<form>') |
| 576 | + .setValue('[name="04fullname"]', 'test') |
| 577 | + .click('#submit') |
| 578 | + }) |
| 579 | + it('autofills in regular tab', function * () { |
| 580 | + yield this.app.client |
| 581 | + .tabByIndex(0) |
| 582 | + .waitForVisible('<form>') |
| 583 | + .click('[name="04fullname"]') |
| 584 | + .click('[name="04fullname"]') |
| 585 | + .windowByUrl(Brave.browserWindowUrl) |
| 586 | + .waitForVisible('.contextMenuItemText') |
| 587 | + .click('.contextMenuItemText') |
| 588 | + .tabByIndex(0) |
| 589 | + .getValue('[name="04fullname"]').should.eventually.be.equal('test') |
| 590 | + }) |
| 591 | + it('clear data now', function * () { |
| 592 | + yield this.app.client |
| 593 | + .tabByIndex(0) |
| 594 | + .loadUrl(getTargetAboutUrl('about:preferences')) |
| 595 | + .waitForVisible(securityTab) |
| 596 | + .click(securityTab) |
| 597 | + .waitForVisible(clearBrowsingDataButton) |
| 598 | + .click(clearBrowsingDataButton) |
| 599 | + .waitForBrowserWindow() |
| 600 | + .waitForVisible('.autocompleteDataSwitch') |
| 601 | + .click('.autocompleteDataSwitch .switchMiddle') |
| 602 | + .waitForVisible('.clearDataButton') |
| 603 | + .click('.clearDataButton') |
| 604 | + }) |
| 605 | + it('does not autofill in regular tab', function * () { |
| 606 | + yield this.app.client |
| 607 | + .windowByUrl(Brave.browserWindowUrl) |
| 608 | + .ipcSend(messages.SHORTCUT_NEW_FRAME, this.formfill) |
| 609 | + .waitForUrl(this.formfill) |
| 610 | + .waitForVisible('<form>') |
| 611 | + .click('[name="04fullname"]') |
| 612 | + .click('[name="04fullname"]') |
| 613 | + .windowByUrl(Brave.browserWindowUrl) |
| 614 | + .waitForExist('contextMenuItemText', 500, true) |
| 615 | + .tabByIndex(0) |
| 616 | + .getValue('[name="04fullname"]').should.eventually.be.equal('') |
| 617 | + }) |
| 618 | + }) |
422 | 619 | })
|
423 | 620 | })
|
0 commit comments