From a9e3572f4fe689ec9fc931c07f7eef8daf9fbcaf Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Wed, 31 May 2017 15:38:55 +0900 Subject: [PATCH 1/5] Add a e2e-test for Modal --- tests/e2e/spectron.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/e2e/spectron.js b/tests/e2e/spectron.js index 20de606f..1845900b 100644 --- a/tests/e2e/spectron.js +++ b/tests/e2e/spectron.js @@ -22,7 +22,7 @@ test.afterEach.always(async t => { await t.context.app.stop() }) -test(async t => { +test('Measure BrowserWindow status with await', async t => { const app = t.context.app await app.client.waitUntilWindowLoaded() @@ -37,3 +37,9 @@ test(async t => { t.true(width > 0) t.true(height > 0) }) + +test('', async t => { + const app = t.context.app + await app.client.click('.TopBar__control-newPostButton___browser-main-TopBar-') + await app.client.click('.NewNoteModal__close-mark___browser-main-modals-') +}) From 823599192f03913ea385c5da90fd17f163faf8be Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Thu, 1 Jun 2017 15:53:58 +0900 Subject: [PATCH 2/5] Fix e2e tests --- tests/e2e/spectron.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/e2e/spectron.js b/tests/e2e/spectron.js index 1845900b..c27bef1e 100644 --- a/tests/e2e/spectron.js +++ b/tests/e2e/spectron.js @@ -2,7 +2,9 @@ import test from 'ava' import {Application} from 'spectron' import path from 'path' -test.beforeEach(async t => { +let app = null + +test.before(async t => { const boostnotePath = ((platform) => { switch (platform) { case 'darwin': @@ -11,19 +13,18 @@ test.beforeEach(async t => { return path.join('..', '..', 'dist', 'Boostnote-linux-x64', 'Boostnote') } })(process.platform) - t.context.app = new Application({ + app = new Application({ path: boostnotePath }) - await t.context.app.start() + await app.start() }) -test.afterEach.always(async t => { - await t.context.app.stop() +test.after.always(async t => { + await app.stop() }) test('Measure BrowserWindow status with await', async t => { - const app = t.context.app await app.client.waitUntilWindowLoaded() const win = app.browserWindow @@ -38,8 +39,7 @@ test('Measure BrowserWindow status with await', async t => { t.true(height > 0) }) -test('', async t => { - const app = t.context.app +test('Modal can be opened and closed', async t => { await app.client.click('.TopBar__control-newPostButton___browser-main-TopBar-') await app.client.click('.NewNoteModal__close-mark___browser-main-modals-') }) From 0ade6d9eced7c73e86bf235e4702262e2d8ef4b4 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Thu, 1 Jun 2017 17:26:28 +0900 Subject: [PATCH 3/5] Add e2e tests for modal click and input texts --- tests/e2e/spectron.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/e2e/spectron.js b/tests/e2e/spectron.js index c27bef1e..384d1550 100644 --- a/tests/e2e/spectron.js +++ b/tests/e2e/spectron.js @@ -4,6 +4,12 @@ import path from 'path' let app = null +const modalOpenButton = '.TopBar__control-newPostButton___browser-main-TopBar-' +const modalCloseButton = '.NewNoteModal__close-mark___browser-main-modals-' +const noteCreateButton = '.NewNoteModal__control-button___browser-main-modals-' +const currentNoteItem = '.NoteItem__item--active___browser-components-' +const noteDetail = '.MarkdownNoteDetail__body___browser-main-Detail-' + test.before(async t => { const boostnotePath = ((platform) => { switch (platform) { @@ -39,7 +45,21 @@ test('Measure BrowserWindow status with await', async t => { t.true(height > 0) }) -test('Modal can be opened and closed', async t => { - await app.client.click('.TopBar__control-newPostButton___browser-main-TopBar-') - await app.client.click('.NewNoteModal__close-mark___browser-main-modals-') +test.serial('Modal can be opened and closed', async t => { + await app.client.click(modalOpenButton) + await app.client.click(modalCloseButton) +}) + +test.serial('Modal can be opened and a note can be created', async t => { + await app.client.click(modalOpenButton) + await app.client.click(noteCreateButton) +}) + +test.serial('NoteList can be clicked', async t => { + await app.client.click(currentNoteItem) +}) + +test.serial('A sentence can be inputted', async t => { + const input = 'this is a text' + await app.client.click(noteDetail).webContents.insertText(input) }) From b28d5c8b259aef80e6eb65c530078927de952ebb Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Thu, 1 Jun 2017 18:15:52 +0900 Subject: [PATCH 4/5] Fix the class name of modalClose button --- tests/e2e/spectron.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/spectron.js b/tests/e2e/spectron.js index 384d1550..4ba5b309 100644 --- a/tests/e2e/spectron.js +++ b/tests/e2e/spectron.js @@ -5,7 +5,7 @@ import path from 'path' let app = null const modalOpenButton = '.TopBar__control-newPostButton___browser-main-TopBar-' -const modalCloseButton = '.NewNoteModal__close-mark___browser-main-modals-' +const modalCloseButton = '.ModalEscButton__esc-mark___browser-components-' const noteCreateButton = '.NewNoteModal__control-button___browser-main-modals-' const currentNoteItem = '.NoteItem__item--active___browser-components-' const noteDetail = '.MarkdownNoteDetail__body___browser-main-Detail-' @@ -30,7 +30,7 @@ test.after.always(async t => { await app.stop() }) -test('Measure BrowserWindow status with await', async t => { +test.serial('Measure BrowserWindow status with await', async t => { await app.client.waitUntilWindowLoaded() const win = app.browserWindow From 4b75d501f556fca90b24cca9f17a262bf2b4750f Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Thu, 1 Jun 2017 23:36:32 +0900 Subject: [PATCH 5/5] Edit a e2e test for editting note --- tests/e2e/spectron.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/e2e/spectron.js b/tests/e2e/spectron.js index 4ba5b309..e2f10c5c 100644 --- a/tests/e2e/spectron.js +++ b/tests/e2e/spectron.js @@ -2,6 +2,7 @@ import test from 'ava' import {Application} from 'spectron' import path from 'path' +const sleep = time => new Promise(resolve => setTimeout(resolve, time)) let app = null const modalOpenButton = '.TopBar__control-newPostButton___browser-main-TopBar-' @@ -62,4 +63,9 @@ test.serial('NoteList can be clicked', async t => { test.serial('A sentence can be inputted', async t => { const input = 'this is a text' await app.client.click(noteDetail).webContents.insertText(input) + const editorValue = await app.client.click(noteDetail) + .webContents.selectAll() + .webContents.copy() + .electron.clipboard.readText() + t.is(editorValue, input) })