mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
feat: test second window open
This commit is contained in:
parent
604942379f
commit
268e02cff6
3 changed files with 13 additions and 8 deletions
|
|
@ -12,4 +12,4 @@ Feature: Open
|
||||||
Given the app is launched
|
Given the app is launched
|
||||||
Then the element "#add-workspace-button" is on the page
|
Then the element "#add-workspace-button" is on the page
|
||||||
Then click on this element
|
Then click on this element
|
||||||
Then "AddWorkspace" window show up
|
Then "Add Workspace" window show up
|
||||||
|
|
@ -31,9 +31,9 @@ Then('{string} window show up', { timeout: 120 * 1000 }, async function (this: T
|
||||||
const handles = await this.app?.client?.getWindowHandles();
|
const handles = await this.app?.client?.getWindowHandles();
|
||||||
expect(handles).to.not.be.undefined;
|
expect(handles).to.not.be.undefined;
|
||||||
if (handles !== undefined) {
|
if (handles !== undefined) {
|
||||||
// DEBUG: console
|
await this.app?.client?.switchToWindow(handles[1]);
|
||||||
console.log(`handles`, handles);
|
await this.waitReactReady();
|
||||||
await this.app?.client?.switchToWindow(handles[0]);
|
const currentTitle = await this.app?.client?.getTitle();
|
||||||
await delay(1000);
|
expect(currentTitle).to.be.equal(windowName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,7 @@ export class TiddlyGitWorld extends World {
|
||||||
port: 9156,
|
port: 9156,
|
||||||
});
|
});
|
||||||
await this.app.start();
|
await this.app.start();
|
||||||
while (undefined === (await this.getElement('#test'))) {
|
await this.waitReactReady();
|
||||||
await delay(500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getElement(selector: string): Promise<WebdriverIO.Element | undefined> {
|
public async getElement(selector: string): Promise<WebdriverIO.Element | undefined> {
|
||||||
|
|
@ -60,6 +58,13 @@ export class TiddlyGitWorld extends World {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We add `<div id="test" />` to each page in react render, so we can wait until it exists
|
||||||
|
*/
|
||||||
|
public async waitReactReady(): Promise<void> {
|
||||||
|
await this?.app?.client?.waitUntil(async () => undefined !== (await this.getElement('#test')));
|
||||||
|
}
|
||||||
|
|
||||||
public updateContext(context: Partial<IContext>): void {
|
public updateContext(context: Partial<IContext>): void {
|
||||||
this.context = this.context === undefined ? context : { ...this.context, ...context };
|
this.context = this.context === undefined ? context : { ...this.context, ...context };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue