-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87518e8
commit 12c7a06
Showing
22 changed files
with
575 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** The arguments given from the tests to send to the server */ | ||
export type StartNeovimArguments = { | ||
filename?: TestDirectoryFile | "." | ||
startupScriptModifications?: StartupScriptModification[] | ||
} | ||
|
||
/** The arguments given to the server */ | ||
export type StartNeovimServerArguments = { | ||
directory: string | ||
} & StartNeovimArguments | ||
|
||
export type StartupScriptModification = | ||
"modify_yazi_config_to_use_ya_as_event_reader.lua" | ||
|
||
declare global { | ||
interface Window { | ||
startNeovim( | ||
directory: string, | ||
startArguments?: StartNeovimArguments, | ||
): Promise<void> | ||
} | ||
} | ||
|
||
export type FileEntry = { | ||
/** The name of the file and its extension. | ||
* @example "file.txt" | ||
*/ | ||
name: string | ||
|
||
/** The name of the file without its extension. | ||
* @example "file" | ||
*/ | ||
stem: string | ||
|
||
/** The extension of the file. | ||
* @example ".txt" | ||
*/ | ||
extension: string | ||
} | ||
|
||
/** Describes the contents test directory, which is a blueprint for files and | ||
* directories. Tests can create a unique, safe environment for interacting | ||
* with the contents of such a directory. | ||
* | ||
* Having strong typing for the test directory contents ensures that tests can | ||
* be written with confidence that the files and directories they expect are | ||
* actually found. Otherwise the tests are brittle and can break easily. | ||
*/ | ||
export type TestDirectory = { | ||
/** The path to the unique test directory itself (the root). */ | ||
rootPath: string | ||
|
||
contents: { | ||
["initial-file.txt"]: FileEntry | ||
["test.lua"]: FileEntry | ||
["file.txt"]: FileEntry | ||
["subdirectory/sub.txt"]: FileEntry | ||
["routes/posts.$postId/route.tsx"]: FileEntry | ||
["routes/posts.$postId/adjacent-file.tsx"]: FileEntry | ||
} | ||
} | ||
|
||
type TestDirectoryFile = keyof TestDirectory["contents"] | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
93 changes: 93 additions & 0 deletions
93
integration-tests/cypress/e2e/using-shell-redirection-to-read-events/opening-files.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
describe("opening files", () => { | ||
beforeEach(() => { | ||
cy.visit("http://localhost:5173") | ||
}) | ||
|
||
it("can display yazi in a floating terminal", () => { | ||
cy.startNeovim().then((dir) => { | ||
// wait until text on the start screen is visible | ||
cy.contains("If you see this text, Neovim is ready!") | ||
cy.typeIntoTerminal("{upArrow}") | ||
|
||
// yazi should now be visible, showing the names of adjacent files | ||
cy.contains(dir.contents["test.lua"].name) // an adjacent file | ||
}) | ||
}) | ||
|
||
it("can open a file that was selected in yazi", () => { | ||
cy.startNeovim().then((dir) => { | ||
cy.typeIntoTerminal("{upArrow}") | ||
cy.contains(dir.contents["file.txt"].name) | ||
|
||
// search for the file in yazi. This focuses the file in yazi | ||
cy.typeIntoTerminal("gg/file.txt{enter}") | ||
cy.typeIntoTerminal("{enter}") | ||
|
||
// the file content should now be visible | ||
cy.contains("Hello 👋") | ||
}) | ||
}) | ||
|
||
it("can open a file in a vertical split", () => { | ||
cy.startNeovim().then((dir) => { | ||
cy.typeIntoTerminal("{upArrow}") | ||
cy.typeIntoTerminal("j{control+v}") | ||
|
||
// the file path must be visible at the bottom | ||
cy.contains(dir.contents["test.lua"].name) | ||
cy.contains(dir.contents["initial-file.txt"].name) | ||
}) | ||
}) | ||
|
||
it("can open a file in a horizontal split", () => { | ||
cy.startNeovim().then((dir) => { | ||
cy.typeIntoTerminal("{upArrow}") | ||
cy.typeIntoTerminal("j{control+x}") | ||
|
||
// the file path must be visible at the bottom | ||
cy.contains(dir.contents["test.lua"].name) | ||
cy.contains(dir.contents["initial-file.txt"].name) | ||
}) | ||
}) | ||
|
||
it("can send file names to the quickfix list", () => { | ||
cy.startNeovim().then((dir) => { | ||
cy.typeIntoTerminal("{upArrow}") | ||
cy.typeIntoTerminal("{control+a}{enter}") | ||
|
||
// items in the quickfix list should now be visible | ||
cy.contains(`${dir.contents["file.txt"].name}||`) | ||
cy.contains(`${dir.contents["initial-file.txt"].name}||`) | ||
}) | ||
}) | ||
|
||
it("can open files with complex characters in their name", () => { | ||
cy.startNeovim().then((dir) => { | ||
cy.typeIntoTerminal("{upArrow}") | ||
|
||
// enter the routes/ directory | ||
cy.typeIntoTerminal("/routes{enter}") | ||
cy.typeIntoTerminal("{rightArrow}") | ||
cy.contains(dir.contents["routes/posts.$postId/route.tsx"].name) // file in the directory | ||
|
||
// enter routes/posts.$postId/ | ||
cy.typeIntoTerminal("{rightArrow}") | ||
|
||
// select route.tsx | ||
cy.typeIntoTerminal( | ||
`/${dir.contents["routes/posts.$postId/route.tsx"].name}{enter}`, | ||
) | ||
|
||
// open the file | ||
cy.typeIntoTerminal("{enter}") | ||
|
||
// close yazi just to be sure the file preview is not found instead | ||
cy.get( | ||
dir.contents["routes/posts.$postId/adjacent-file.tsx"].name, | ||
).should("not.exist") | ||
|
||
// the file contents should now be visible | ||
cy.contains("02c67730-6b74-4b7c-af61-fe5844fdc3d7") | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
integration-tests/cypress/e2e/using-ya-to-read-events/opening-directories.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { startNeovimWithYa } from "./startNeovimWithYa" | ||
|
||
describe("opening directories", () => { | ||
it("can open a directory when starting with `neovim .`", () => { | ||
cy.visit("http://localhost:5173") | ||
startNeovimWithYa({ | ||
// `neovim .` specifies to open the current directory when neovim is | ||
// starting | ||
filename: ".", | ||
}).then((dir) => { | ||
// yazi should now be visible, showing the names of adjacent files | ||
cy.contains(dir.contents["file.txt"].name) | ||
cy.contains(dir.contents["initial-file.txt"].name) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.