1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2025-01-20 06:18:45 +00:00
This commit is contained in:
Asher 2022-02-18 17:03:19 +00:00
parent e28914a338
commit 2dad878fcc
2 changed files with 24 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import * as path from "path"
import { promises as fs } from "fs" import { promises as fs } from "fs"
import * as path from "path"
import { describe, test, expect } from "./baseFixture" import { describe, test, expect } from "./baseFixture"
describe("CodeServer", true, [], () => { describe("CodeServer", true, [], () => {

View File

@ -205,7 +205,7 @@ export class CodeServerPage {
/** /**
* Navigate to a code-server endpoint. By default go to the root. * Navigate to a code-server endpoint. By default go to the root.
*/ */
async navigate(path: string = "/") { async navigate(path = "/") {
const to = new URL(path, await this.codeServer.address()) const to = new URL(path, await this.codeServer.address())
await this.page.goto(to.toString(), { waitUntil: "networkidle" }) await this.page.goto(to.toString(), { waitUntil: "networkidle" })
} }
@ -360,10 +360,12 @@ export class CodeServerPage {
* try again. * try again.
*/ */
const navigate = async (ctx: Context) => { const navigate = async (ctx: Context) => {
const steps: Array<{fn: () => Promise<unknown>, name: string}> = [{ const steps: Array<{ fn: () => Promise<unknown>; name: string }> = [
{
fn: () => this.page.waitForSelector(`${selector}:focus-within`), fn: () => this.page.waitForSelector(`${selector}:focus-within`),
name: "focus", name: "focus",
}] },
]
for (const item of items) { for (const item of items) {
// Normally these will wait for the item to be visible and then execute // Normally these will wait for the item to be visible and then execute
@ -373,10 +375,22 @@ export class CodeServerPage {
// if the old promise clicks logout before the new one can). By // if the old promise clicks logout before the new one can). By
// splitting them into two steps each we can cancel before running the // splitting them into two steps each we can cancel before running the
// action. // action.
steps.push({fn: () => this.page.hover(`${selector} :text("${item}")`, { trial: true }), name: `${item}:hover:trial`}) steps.push({
steps.push({fn: () => this.page.hover(`${selector} :text("${item}")`, { force: true }), name: `${item}:hover:force`}) fn: () => this.page.hover(`${selector} :text("${item}")`, { trial: true }),
steps.push({fn: () => this.page.click(`${selector} :text("${item}")`, { trial: true }), name: `${item}:click:trial`}) name: `${item}:hover:trial`,
steps.push({fn: () => this.page.click(`${selector} :text("${item}")`, { force: true }), name: `${item}:click:force`}) })
steps.push({
fn: () => this.page.hover(`${selector} :text("${item}")`, { force: true }),
name: `${item}:hover:force`,
})
steps.push({
fn: () => this.page.click(`${selector} :text("${item}")`, { trial: true }),
name: `${item}:click:trial`,
})
steps.push({
fn: () => this.page.click(`${selector} :text("${item}")`, { force: true }),
name: `${item}:click:force`,
})
} }
for (const step of steps) { for (const step of steps) {