diff --git a/integration-tests/cypress/e2e/healthcheck.cy.ts b/integration-tests/cypress/e2e/healthcheck.cy.ts index aff19334..111a45e2 100644 --- a/integration-tests/cypress/e2e/healthcheck.cy.ts +++ b/integration-tests/cypress/e2e/healthcheck.cy.ts @@ -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( diff --git a/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts b/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts index 184e13ba..7f11150f 100644 --- a/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts +++ b/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts @@ -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"`) + }) }) }) diff --git a/integration-tests/cypress/e2e/using-ya-to-read-events/integrations.cy.ts b/integration-tests/cypress/e2e/using-ya-to-read-events/integrations.cy.ts index 0f962301..79f739a9 100644 --- a/integration-tests/cypress/e2e/using-ya-to-read-events/integrations.cy.ts +++ b/integration-tests/cypress/e2e/using-ya-to-read-events/integrations.cy.ts @@ -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 diff --git a/integration-tests/cypress/e2e/using-ya-to-read-events/opening-directories.cy.ts b/integration-tests/cypress/e2e/using-ya-to-read-events/opening-directories.cy.ts index 8b85faff..849448c5 100644 --- a/integration-tests/cypress/e2e/using-ya-to-read-events/opening-directories.cy.ts +++ b/integration-tests/cypress/e2e/using-ya-to-read-events/opening-directories.cy.ts @@ -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") + }) }) }) diff --git a/integration-tests/cypress/e2e/using-ya-to-read-events/opening-files.cy.ts b/integration-tests/cypress/e2e/using-ya-to-read-events/opening-files.cy.ts index d09cb409..dab64247 100644 --- a/integration-tests/cypress/e2e/using-ya-to-read-events/opening-files.cy.ts +++ b/integration-tests/cypress/e2e/using-ya-to-read-events/opening-files.cy.ts @@ -1,3 +1,4 @@ +import type { MyTestDirectoryFile } from "MyTestDirectory" import { isFileNotSelectedInYazi, isFileSelectedInYazi, @@ -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!") @@ -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") + }) }) }) }) @@ -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, + ) + }) }) }) @@ -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"), + ) + }) }) }) @@ -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), + ) + }) }) }) diff --git a/integration-tests/package.json b/integration-tests/package.json index 19f2f94f..834c4746 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -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": {