From 70fb6dcbc73b02d85236710b99b69b8821191eea Mon Sep 17 00:00:00 2001 From: Kylart Date: Tue, 14 Apr 2020 23:37:57 +0200 Subject: [PATCH] Fix tests --- src/renderer/components/info/modal.vue | 4 ++-- test/app/search.spec.js | 12 +++++++----- test/container/window.spec.js | 2 +- test/index.spec.js | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/renderer/components/info/modal.vue b/src/renderer/components/info/modal.vue index 5f3e9ff..16e9555 100644 --- a/src/renderer/components/info/modal.vue +++ b/src/renderer/components/info/modal.vue @@ -16,7 +16,7 @@ v-container(grid-list-md) v-layout(row, wrap, justify-center) v-flex(xs6) - v-text-field( + v-text-field#info-search-input( ref='input', v-model='term', label='Search', @@ -141,7 +141,7 @@ export default { }) }, search: debounce(function () { - if (this.term.length < 3) return + if (this.term && this.term.length < 3) return this.loading = true diff --git a/test/app/search.spec.js b/test/app/search.spec.js index b73effe..6c379d1 100644 --- a/test/app/search.spec.js +++ b/test/app/search.spec.js @@ -6,6 +6,8 @@ const BEST_ANIME = { id: 20047 } +const SEARCH_INPUT = 'input#info-search-input' + module.exports = function () { describe('Search modal', function () { before(function (done) { @@ -95,13 +97,13 @@ module.exports = function () { return this.app.client .$('.toolbar > div > *:nth-child(5)').click() .pause(500) - .$('input').hasFocus().should.eventually.be.true + .$(SEARCH_INPUT).hasFocus().should.eventually.be.true .saveScreenshot('test/screenshots/search_modal.png') }) it('should make a research', function () { return this.app.client - .$('input').addValue(BEST_ANIME.name) + .$(SEARCH_INPUT).addValue(BEST_ANIME.name) .pause(500) .waitUntilTextExists('.v-dialog .container > div:last-child > div:nth-child(1)', BEST_ANIME.name, 7500) .saveScreenshot('test/screenshots/search_modal_results.png') @@ -109,7 +111,7 @@ module.exports = function () { it('should open the result into the modal and set it fullscreen', function () { return this.app.client - .$('.v-dialog .container > div:last-child > div:nth-child(1)').click() + .$('.v-dialog .container > div:last-child > div:nth-child(1) > .entry').click() .waitUntil(async () => this.app.client.$('.info-container').isExisting(), 10000) .pause(1000) .saveScreenshot('test/screenshots/search_modal_info.png') @@ -120,7 +122,7 @@ module.exports = function () { .waitUntilTextExists('.info-container', this.sakuraTrick.title.native) .getText('.score').should.eventually.equal(`${this.sakuraTrick.averageScore} / 100`) .getText('.users').should.eventually.equal(this.sakuraTrick.stats.scoreDistribution.reduce((acc, { amount }) => (acc + amount), 0) + ' votes') - .$('.v-image > div:nth-child(2)').getAttribute('style') + .$('.info-container .v-image > div:nth-child(2)').getAttribute('style') .should.eventually.include(this.sakuraTrick.coverImage.extraLarge || this.sakuraTrick.coverImage.large) .$$('.characters-container > *').should.eventually.have.length(this.sakuraTrick.characters.edges.length + 1) .$$('.staff-container > *').should.eventually.have.length(this.sakuraTrick.staff.edges.length) @@ -145,7 +147,7 @@ module.exports = function () { it('should exit on escape key press', function () { return this.app.client - .$('input').hasFocus().should.eventually.be.true + .$(SEARCH_INPUT).hasFocus().should.eventually.be.true .keys([ 'Escape' ]).pause(750) .$('.v-dialog').isVisible().should.eventually.be.false }) diff --git a/test/container/window.spec.js b/test/container/window.spec.js index 7b7234b..c184f5b 100644 --- a/test/container/window.spec.js +++ b/test/container/window.spec.js @@ -1,6 +1,6 @@ module.exports = function () { describe('General window behaviour', function () { - it('should be visible', async function () { + it('should be visible', function () { return this.app.client .getWindowCount() .should.eventually.have.at.least(1) diff --git a/test/index.spec.js b/test/index.spec.js index e7b46c9..15559d7 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -18,6 +18,6 @@ describe('KawAnime main test routine', function () { require('./hooks')() - require('./container') require('./app') + require('./container') })