Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements for the integration tests #581

Merged
merged 4 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/cypress/e2e/healthcheck.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("the healthcheck", () => {
// wait until text on the start screen is visible
cy.contains("If you see this text, Neovim is ready!")

cy.typeIntoTerminal(":checkhealth yazi{enter}")
cy.runExCommand({ command: "checkhealth yazi" })

// the version of yazi.nvim itself should be shown
cy.readFile("../.release-please-manifest.json").then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,18 @@ describe("highlighting the buffer with 'hover' events", () => {
)

cy.typeIntoTerminal("q")
cy.typeIntoTerminal(":messages{enter}")

// Hovering a new file should have triggered the integration
//
// the main message from the integration in the
// startupScriptModifications script should be visible. Check the file
// to see the full integration.
cy.contains("Just received a YaziDDSHover event!")

// some event data should be visible. See the lua type YaziHoverEvent for
// the structure
cy.contains(`type = "hover"`)
cy.runExCommand({ command: "messages" }).then((result) => {
// Hovering a new file should have triggered the integration
//
// the main message from the integration in the
// startupScriptModifications script should be visible. Check the file
// to see the full integration.
expect(result.value).to.contain("Just received a YaziDDSHover event!")

// some event data should be visible. See the lua type YaziHoverEvent for
// the structure
expect(result.value).to.contain(`type = "hover"`)
})
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("grug-far integration (search and replace)", () => {
cy.typeIntoTerminal("{esc}")

// close the split on the right so we can get some more space
cy.typeIntoTerminal(":only{enter}")
cy.runExCommand({ command: "only" })

// the selected files should be visible in the view, used as the files to
// whitelist into the search and replace operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ describe("opening directories", () => {
cy.typeIntoTerminal("q")
cy.contains("-- TERMINAL --").should("not.exist")

cy.typeIntoTerminal(":CountBuffers{enter}")
cy.contains("Number of open buffers: 2")
cy.runExCommand({ command: "CountBuffers" }).then((result) => {
expect(result.value).to.equal("Number of open buffers: 2")
})
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { MyTestDirectoryFile } from "MyTestDirectory"
import {
isFileNotSelectedInYazi,
isFileSelectedInYazi,
Expand Down Expand Up @@ -84,7 +85,7 @@ describe("opening files", () => {
// match some text from inside the file
"Hello",
)
cy.typeIntoTerminal(":tabnext{enter}")
cy.runExCommand({ command: "tabnext" })

cy.contains("If you see this text, Neovim is ready!")

Expand Down Expand Up @@ -174,9 +175,9 @@ describe("opening files", () => {
cy.typeIntoTerminal("q")

// the file should now be renamed - ask neovim to confirm this
cy.typeIntoTerminal(":buffers{enter}")

cy.contains("renamed-file.txt")
cy.runExCommand({ command: "buffers" }).then((result) => {
expect(result.value).to.contain("renamed-file.txt")
})
})
})
})
Expand Down Expand Up @@ -260,9 +261,11 @@ describe("opening files", () => {
// the file to verify this.
// NOTE: the test-setup configures the `"` register to be the clipboard
cy.typeIntoTerminal("o{enter}{esc}")
cy.typeIntoTerminal(':normal ""p{enter}')

cy.contains("routes/posts.$postId/adjacent-file.txt")
cy.runLuaCode({ luaCode: `return vim.fn.getreg('"')` }).then((result) => {
expect(result.value).to.contain(
"routes/posts.$postId/adjacent-file.txt" satisfies MyTestDirectoryFile,
)
})
})
})

Expand Down Expand Up @@ -299,12 +302,17 @@ describe("opening files", () => {
// the file to verify this.
// NOTE: the test-setup configures the `"` register to be the clipboard
cy.typeIntoTerminal("o{enter}{esc}")
cy.typeIntoTerminal(':normal ""p{enter}')

// all selected files should now be visible
cy.contains("routes/posts.$postId/adjacent-file.txt")
cy.contains("routes/posts.$postId/route.tsx")
cy.contains("routes/posts.$postId/adjacent-file.txt")
cy.runLuaCode({ luaCode: `return vim.fn.getreg('"')` }).then((result) => {
expect(result.value).to.eql(
(
[
"routes/posts.$postId/adjacent-file.txt",
"routes/posts.$postId/route.tsx",
"routes/posts.$postId/should-be-excluded-file.txt",
] satisfies MyTestDirectoryFile[]
).join("\n"),
)
})
})
})

Expand All @@ -319,11 +327,14 @@ describe("opening files", () => {
cy.typeIntoTerminal("{control+a}")
cy.typeIntoTerminal("{enter}")

cy.typeIntoTerminal(":buffers{enter}")

// all files should now be visible
cy.contains("dir with spaces/file1.txt")
cy.contains("dir with spaces/file2.txt")
cy.runExCommand({ command: "buffers" }).then((result) => {
expect(result.value).to.match(
new RegExp("dir with spaces/file1.txt" satisfies MyTestDirectoryFile),
)
expect(result.value).to.match(
new RegExp("dir with spaces/file2.txt" satisfies MyTestDirectoryFile),
)
})
})
})

Expand Down
26 changes: 25 additions & 1 deletion integration-tests/cypress/support/tui-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
//
// This file is autogenerated by tui-sandbox. Do not edit it directly.
//
import type { BlockingCommandClientInput } from "@tui-sandbox/library/dist/src/server/server"
import type {
BlockingCommandClientInput,
ExCommandClientInput,
LuaCodeClientInput,
} from "@tui-sandbox/library/dist/src/server/server"
import type {
BlockingShellCommandOutput,
RunExCommandOutput,
RunLuaCodeOutput,
StartNeovimGenericArguments,
} from "@tui-sandbox/library/dist/src/server/types"
import type { OverrideProperties } from "type-fest"
Expand All @@ -26,6 +32,8 @@ declare global {
runBlockingShellCommand(
input: BlockingCommandClientInput,
): Promise<BlockingShellCommandOutput>
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>
runExCommand(input: ExCommandClientInput): Promise<RunExCommandOutput>
}
}

Expand Down Expand Up @@ -69,6 +77,18 @@ Cypress.Commands.add(
},
)

Cypress.Commands.add("runLuaCode", (input: LuaCodeClientInput) => {
cy.window().then(async (win) => {
return await win.runLuaCode(input)
})
})

Cypress.Commands.add("runExCommand", (input: ExCommandClientInput) => {
cy.window().then(async (win) => {
return await win.runExCommand(input)
})
})

before(function () {
// disable Cypress's default behavior of logging all XMLHttpRequests and
// fetches to the Command Log
Expand All @@ -93,6 +113,10 @@ declare global {
runBlockingShellCommand(
input: BlockingCommandClientInput,
): Chainable<BlockingShellCommandOutput>

runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>

runExCommand(input: ExCommandClientInput): Chainable<RunExCommandOutput>
}
}
}
1 change: 1 addition & 0 deletions integration-tests/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default [
"**/test-environment/",
"eslint.config.mjs",
"dist/",
"cypress/support/tui-sandbox.ts",
],
},
...compat.extends(
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"cy:run": "concurrently --success command-cypress --kill-others --names 'app,cypress' --prefix-colors 'blue,yellow' 'pnpm tui start' 'wait-on --timeout 60000 http://127.0.0.1:3000 && npx cypress run'",
"dev": "concurrently --kill-others --names 'app,cypress' --prefix-colors 'blue,yellow' 'pnpm tui start' 'pnpm cypress open --e2e'",
"dev": "concurrently --kill-others --names 'app,cypress' --prefix-colors 'blue,yellow' 'pnpm tui start' 'pnpm cypress open --e2e --browser=electron'",
"eslint": "eslint --max-warnings=0 ."
},
"dependencies": {
Expand All @@ -15,7 +15,7 @@
"zod": "3.23.8"
},
"devDependencies": {
"@tui-sandbox/library": "6.1.0",
"@tui-sandbox/library": "7.2.0",
"@types/node": "22.9.1",
"@types/tinycolor2": "1.4.6",
"@typescript-eslint/eslint-plugin": "8.15.0",
Expand All @@ -27,6 +27,6 @@
"prettier-plugin-organize-imports": "4.1.0",
"tinycolor2": "1.6.0",
"type-fest": "4.27.0",
"typescript": "5.6.3"
"typescript": "5.7.2"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@umbrelladocs/linkspector": "0.3.13",
"markdownlint-cli2": "0.15.0",
"prettier": "3.3.3",
"prettier-plugin-packagejson": "2.5.3"
"prettier-plugin-packagejson": "2.5.5"
},
"packageManager": "[email protected]"
}
Loading
Loading