mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
@@ -2,7 +2,16 @@ import test from 'ava'
|
||||
import {Application} from 'spectron'
|
||||
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) => {
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
@@ -11,19 +20,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(async t => {
|
||||
const app = t.context.app
|
||||
test.serial('Measure BrowserWindow status with await', async t => {
|
||||
await app.client.waitUntilWindowLoaded()
|
||||
|
||||
const win = app.browserWindow
|
||||
@@ -37,3 +45,27 @@ test(async t => {
|
||||
t.true(width > 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