Skip to content

Commit

Permalink
Refactor typeInEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-grace committed Mar 19, 2024
1 parent 55117e1 commit 2339e62
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/e2e/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,14 @@ export class App {
}

async typeInEditor(text: string): Promise<void> {
const textWithoutLastChar = text.slice(0, text.length - 3);
await this.editorTextArea.fill(textWithoutLastChar);
const numCharTyped = 2;
const textWithoutLastChars = text.slice(0, -numCharTyped);
const lastChars = text.slice(-numCharTyped);
await this.editorTextArea.fill(textWithoutLastChars);
// Last few characters are typed separately to trigger editor suggestions
const [a, b, c] = text.slice(-3);
await this.page.keyboard.press(a, { delay: 500 });
await this.page.keyboard.press(b, { delay: 500 });
await this.page.keyboard.press(c, { delay: 500 });
for (const char of lastChars) {
await this.page.keyboard.press(char, { delay: 500 });
}
}

async switchTab(tabName: "Project" | "API" | "Reference" | "Ideas") {
Expand Down

0 comments on commit 2339e62

Please sign in to comment.