import test from 'ava';
import {Application} from 'spectron';
import electronPath from 'electron';
import path from 'path';


test.beforeEach(async t => {
    t.context.app = new Application({
        path: electronPath,
        args: [path.join(__dirname, '../..')],
        env: {SPECTRON: '1'},
        requireName: 'electronRequire'
    });

    await t.context.app.start();
});

test.afterEach.always(async t => {
    await t.context.app.stop();
});

test('shows window', async t => {
    const app = t.context.app;
    await app.client.waitUntilWindowLoaded();

    const win = app.browserWindow;
    t.is(await app.client.getWindowCount(), 1);
    t.false(await win.isMinimized());
    t.false(await win.isDevToolsOpened());
    t.true(await win.isVisible());

    const {width, height} = await win.getBounds();
    t.true(width > 0);
    t.true(height > 0);

    var text = await app.client.getText("#welcome");
    t.is(text.substr(0,12), "Your JBrowse");
    await app.client.click("#newOpen");
    await app.client.click("#openFile");
    await app.client.click("#dijit_form_Button_1");
    await app.restart()
    await app.client.waitUntilWindowLoaded()
    text = await app.client.getText("#previousSessionsTable");
    t.true(text != null);
});


@@ -1249,13 +1249,67 @@
  null);%0A
+    await app.client.click(%22#previousSessionsTable%22);%0A
 %7D);%0A%0A

Rename node