2019-07-01 22:58:07 +00:00
|
|
|
const { Application } = require('spectron')
|
|
|
|
const electron = require('electron')
|
|
|
|
const chai = require('chai')
|
|
|
|
const chaiAsPromised = require('chai-as-promised')
|
2019-07-01 22:39:23 +00:00
|
|
|
|
2019-07-01 22:58:07 +00:00
|
|
|
chai.should()
|
|
|
|
chai.use(chaiAsPromised)
|
2019-07-01 22:39:23 +00:00
|
|
|
|
|
|
|
describe('Launch app', function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.app = new Application({
|
|
|
|
path: electron,
|
|
|
|
args: ['dist/bundled/background.js']
|
|
|
|
})
|
|
|
|
|
2019-07-02 12:21:50 +00:00
|
|
|
await this.app.start()
|
2019-07-01 22:39:23 +00:00
|
|
|
})
|
|
|
|
|
2019-07-01 22:58:07 +00:00
|
|
|
beforeEach(function () {
|
|
|
|
chaiAsPromised.transferPromiseness = this.app.transferPromiseness
|
|
|
|
})
|
|
|
|
|
2019-07-01 22:39:23 +00:00
|
|
|
after(async function () {
|
2019-07-01 23:21:43 +00:00
|
|
|
return this.app.stop()
|
2019-07-01 22:39:23 +00:00
|
|
|
})
|
|
|
|
|
2019-07-02 12:21:50 +00:00
|
|
|
it('should open the download modal', async function () {
|
|
|
|
return this.app.client
|
|
|
|
.$('#downloader-btn').click()
|
2019-07-02 23:33:39 +00:00
|
|
|
.pause(500)
|
|
|
|
.getText('.button-container .button').should.eventually.equal('DOWNLOAD')
|
|
|
|
.isExisting('.input-container').should.eventually.be.true
|
2019-07-03 15:34:13 +00:00
|
|
|
.isExisting('.quality-container').should.eventually.be.true
|
2019-07-02 23:33:39 +00:00
|
|
|
.isExisting('.left').should.eventually.be.true
|
|
|
|
.isExisting('.right').should.eventually.be.true
|
2019-07-03 15:34:13 +00:00
|
|
|
.$('.input-container:nth-child(1) input').addValue('Sakura Trick')
|
|
|
|
.keys([ 'Tab' ])
|
|
|
|
.$('.input-container:nth-child(2) input').hasFocus().should.eventually.be.true
|
|
|
|
.$('.input-container:nth-child(2) input').addValue('4')
|
|
|
|
.keys([ 'Tab' ])
|
|
|
|
.$('.input-container:nth-child(3) input').hasFocus().should.eventually.be.true
|
|
|
|
.$('.input-container:nth-child(3) input').addValue('8')
|
|
|
|
.keys([ 'Tab', 'ArrowRight', 'ArrowLeft', 'ArrowLeft', 'ArrowRight', 'ArrowRight' ]) // Should select 1080p quality
|
|
|
|
.$('.quality-container div[role="radiogroup"] div:nth-child(4) input').hasFocus().should.eventually.be.true
|
|
|
|
.keys([ 'Tab', 'Enter' ])
|
|
|
|
.waitUntil(() => this.app.client.$('#magnet-modal').isVisible())
|
2019-07-02 12:21:50 +00:00
|
|
|
})
|
|
|
|
|
2019-07-01 22:39:23 +00:00
|
|
|
it('should be visible', async function () {
|
2019-07-01 22:58:07 +00:00
|
|
|
return this.app.client
|
|
|
|
.getWindowCount()
|
|
|
|
.should.eventually.have.at.least(1)
|
|
|
|
.browserWindow.isMinimized()
|
|
|
|
.should.eventually.be.false.browserWindow.isVisible()
|
|
|
|
.should.eventually.be.true.browserWindow.getBounds()
|
|
|
|
.should.eventually.have.property('width')
|
|
|
|
.and.be.above(0)
|
|
|
|
.browserWindow.getBounds()
|
|
|
|
.should.eventually.have.property('height')
|
|
|
|
.and.be.above(0)
|
2019-07-01 22:39:23 +00:00
|
|
|
})
|
|
|
|
})
|