mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-19 06:07:21 +02:00
Merge pull request #863 from tdurieux/fix/editor-mode-fallback
fix: fall back to plain text for unsupported editor modes
This commit is contained in:
5 files changed
+38
-19
No files matched your search
@@ -28,6 +28,8 @@ async function browser(route = "/", overrides = {}, storage = {}) {
|
||||
url: "http://localhost" + route, runScripts: "dangerously", pretendToBeVisual: true, virtualConsole,
|
||||
});
|
||||
const window = dom.window;
|
||||
// Exercise the production bundle on browsers without this ES2022 builtin.
|
||||
window.Object.hasOwn = undefined;
|
||||
window.matchMedia = () => ({ matches: false });
|
||||
window.HTMLCanvasElement.prototype.getContext = () => null;
|
||||
window.fetch = async (url, options = {}) => {
|
||||
@@ -380,6 +382,20 @@ describe("Vue 3 UI", function () {
|
||||
expect(ui.window.document.activeElement.id).to.equal("commit");
|
||||
});
|
||||
|
||||
for (const [file, mode] of [["data.csv", "text"], ["LICENSE", "text"], ["model.idp", "text"], ["hello.js", "javascript"], ...["csp", "applescript", "logtalk", "redshift", "sparql", "turtle"].map(mode => ["file." + mode, mode])]) {
|
||||
it("uses an available editor mode for " + file, async function () {
|
||||
ui = await browser("/r/test/" + file, {
|
||||
"/api/repo/test/files/": [{ name: file, path: "", sha: "1", size: 5 }],
|
||||
});
|
||||
await delay(80);
|
||||
const host = ui.window.document.querySelector(".ace_editor");
|
||||
expect(host).not.to.equal(null);
|
||||
expect(ui.window.ace.edit(host).session.getMode().$id).to.equal("ace/mode/" + mode);
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
expect(ui.assets.some(url => /mode-(csv|license|idp)\.js/.test(url))).to.equal(false);
|
||||
});
|
||||
}
|
||||
|
||||
it("loads document libraries on demand and reuses them across navigation", async function () {
|
||||
ui = await browser("/dashboard");
|
||||
expect(ui.assets.filter(url => url.endsWith(".js"))).to.deep.equal([]);
|
||||
|
||||
Reference in new issue
Block a user