feat: try test second window

This commit is contained in:
tiddlygit-test 2021-04-19 02:05:28 +08:00
parent 3cf630d39f
commit 604942379f
2 changed files with 31 additions and 1 deletions

View file

@ -6,3 +6,10 @@ Feature: Open
Scenario: Opening TiddlyGit
Given the app is launched
Then the element "#new-user-tip" is on the page
Then the element "#add-workspace-button" is on the page
Scenario: Opening TiddlyGit
Given the app is launched
Then the element "#add-workspace-button" is on the page
Then click on this element
Then "AddWorkspace" window show up

View file

@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
import { setWorldConstructor, Given, Then, When } from '@cucumber/cucumber';
import { delay } from 'bluebird';
import { expect } from 'chai';
import { TiddlyGitWorld } from '../supports/world';
@ -7,6 +8,8 @@ setWorldConstructor(TiddlyGitWorld);
Given('the app is launched', { timeout: 120 * 1000 }, async function (this: TiddlyGitWorld) {
await this.start();
const windowCount = await this.app?.client?.getWindowCount();
expect(windowCount).equal(1);
});
Then('the element {string} is on the page', { timeout: 120 * 1000 }, async function (this: TiddlyGitWorld, elementSelector: string) {
@ -14,3 +17,23 @@ Then('the element {string} is on the page', { timeout: 120 * 1000 }, async funct
expect(result).to.not.be.undefined;
this.updateContext({ previousElement: result });
});
Then('click on this element', { timeout: 120 * 1000 }, async function (this: TiddlyGitWorld) {
expect(this.context?.previousElement).to.not.be.undefined;
if (this.context?.previousElement !== undefined) {
await this.context.previousElement.click();
}
});
Then('{string} window show up', { timeout: 120 * 1000 }, async function (this: TiddlyGitWorld, windowName: string) {
// await delay(1000);
const windowCount = await this.app?.client?.getWindowCount();
expect(windowCount).equal(2);
const handles = await this.app?.client?.getWindowHandles();
expect(handles).to.not.be.undefined;
if (handles !== undefined) {
// DEBUG: console
console.log(`handles`, handles);
await this.app?.client?.switchToWindow(handles[0]);
await delay(1000);
}
});