mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-16 03:06:27 +00:00
@@ -2,7 +2,16 @@ import test from 'ava'
|
|||||||
import {Application} from 'spectron'
|
import {Application} from 'spectron'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
test.beforeEach(async t => {
|
const sleep = time => new Promise(resolve => setTimeout(resolve, time))
|
||||||
|
let app = null
|
||||||
|
|
||||||
|
const modalOpenButton = '.TopBar__control-newPostButton___browser-main-TopBar-'
|
||||||
|
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-'
|
||||||
|
|
||||||
|
test.before(async t => {
|
||||||
const boostnotePath = ((platform) => {
|
const boostnotePath = ((platform) => {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@@ -11,19 +20,18 @@ test.beforeEach(async t => {
|
|||||||
return path.join('..', '..', 'dist', 'Boostnote-linux-x64', 'Boostnote')
|
return path.join('..', '..', 'dist', 'Boostnote-linux-x64', 'Boostnote')
|
||||||
}
|
}
|
||||||
})(process.platform)
|
})(process.platform)
|
||||||
t.context.app = new Application({
|
app = new Application({
|
||||||
path: boostnotePath
|
path: boostnotePath
|
||||||
})
|
})
|
||||||
|
|
||||||
await t.context.app.start()
|
await app.start()
|
||||||
})
|
})
|
||||||
|
|
||||||
test.afterEach.always(async t => {
|
test.after.always(async t => {
|
||||||
await t.context.app.stop()
|
await app.stop()
|
||||||
})
|
})
|
||||||
|
|
||||||
test(async t => {
|
test.serial('Measure BrowserWindow status with await', async t => {
|
||||||
const app = t.context.app
|
|
||||||
await app.client.waitUntilWindowLoaded()
|
await app.client.waitUntilWindowLoaded()
|
||||||
|
|
||||||
const win = app.browserWindow
|
const win = app.browserWindow
|
||||||
@@ -37,3 +45,27 @@ test(async t => {
|
|||||||
t.true(width > 0)
|
t.true(width > 0)
|
||||||
t.true(height > 0)
|
t.true(height > 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
const editorValue = await app.client.click(noteDetail)
|
||||||
|
.webContents.selectAll()
|
||||||
|
.webContents.copy()
|
||||||
|
.electron.clipboard.readText()
|
||||||
|
t.is(editorValue, input)
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user