This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start adding tests for payments panel
- Loading branch information
1 parent
d51c09b
commit 980e664
Showing
5 changed files
with
117 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1118,8 +1118,11 @@ const pathSuffix = { development: '-dev', test: '-test' }[process.env.NODE_ENV] | |
|
||
var pathName = (name) => { | ||
var parts = path.parse(name) | ||
var basePath = process.env.NODE_ENV === 'test' | ||
? path.join(process.env.HOME, '.brave-test-ledger') | ||
: app.getPath('userData') | ||
|
||
return path.join(app.getPath('userData'), parts.name + pathSuffix + parts.ext) | ||
return path.join(basePath, parts.name + pathSuffix + parts.ext) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mrose17
via email
Member
|
||
} | ||
|
||
/** | ||
|
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
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,88 @@ | ||
/* global describe, it, beforeEach */ | ||
|
||
const Brave = require('../lib/brave') | ||
const {urlInput, addFundsButton, paymentsStatus, paymentsWelcomePage, paymentsTab, walletSwitch} = require('../lib/selectors') | ||
const assert = require('assert') | ||
|
||
const prefsUrl = 'about:preferences' | ||
|
||
describe('Payments Panel', function () { | ||
function * setup (client) { | ||
yield client | ||
.waitUntilWindowLoaded() | ||
.waitForUrl(Brave.newTabUrl) | ||
.waitForBrowserWindow() | ||
.waitForVisible('#window') | ||
.waitForVisible(urlInput) | ||
} | ||
|
||
describe('can setup payments', function () { | ||
Brave.beforeEach(this) | ||
beforeEach(function * () { | ||
yield setup(this.app.client) | ||
}) | ||
|
||
it('shows welcome page', function * () { | ||
yield this.app.client | ||
.tabByIndex(0) | ||
.loadUrl(prefsUrl) | ||
.waitForVisible(paymentsTab) | ||
.click(paymentsTab) | ||
.waitForVisible(paymentsWelcomePage) | ||
let background = yield this.app.client.getCssProperty(walletSwitch, 'background-color') | ||
assert.equal(background.value, 'rgba(211,211,211,1)') | ||
}) | ||
|
||
it('payments can be enabled', function * () { | ||
yield this.app.client | ||
.tabByIndex(0) | ||
.loadUrl(prefsUrl) | ||
.waitForVisible(paymentsTab) | ||
.click(paymentsTab) | ||
.waitForVisible(paymentsWelcomePage) | ||
.click(walletSwitch) | ||
.windowByUrl(Brave.browserWindowUrl) | ||
.waitUntil(function () { | ||
return this.getAppState().then((val) => { | ||
return val.value.settings['payments.enabled'] === true && | ||
val.value.settings['payments.notifications'] === true | ||
}) | ||
}) | ||
}) | ||
|
||
it('payments can be disabled', function * () { | ||
yield this.app.client | ||
.tabByIndex(0) | ||
.loadUrl(prefsUrl) | ||
.waitForVisible(paymentsTab) | ||
.click(paymentsTab) | ||
.waitForVisible(paymentsWelcomePage) | ||
.click(walletSwitch) | ||
.click(walletSwitch) | ||
.windowByUrl(Brave.browserWindowUrl) | ||
.waitUntil(function () { | ||
return this.getAppState().then((val) => { | ||
return val.value.settings['payments.enabled'] === false && | ||
val.value.settings['payments.notifications'] === false | ||
}) | ||
}) | ||
}) | ||
|
||
it('can create wallet', function * () { | ||
yield this.app.client | ||
.tabByIndex(0) | ||
.loadUrl(prefsUrl) | ||
.waitForVisible(paymentsTab) | ||
.click(paymentsTab) | ||
.waitForVisible(paymentsWelcomePage) | ||
.click(walletSwitch) | ||
.waitUntil(function () { | ||
return this.getText(paymentsStatus).then((val) => val.includes('get started')) | ||
}) | ||
.click(addFundsButton) | ||
.waitUntil(function () { | ||
return this.getText(paymentsStatus).then((val) => val.includes('Creating')) | ||
}) | ||
}) | ||
}) | ||
}) |
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
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
@mrose17 heads up on this change. i don't think tests can know where the the userData directory is, so test state files are in ~/.brave-test-ledger