Skip to content

Commit ad93345

Browse files
authored
Update dependencies (#33)
* chore: update fuse.js * chore: update jsdom * chore: update node-fetch-cache * chore: update rehype-mdx-code-props
1 parent 868d37b commit ad93345

File tree

6 files changed

+126
-125
lines changed

6 files changed

+126
-125
lines changed

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
"autoprefixer": "^10.4.14",
1919
"axios": "^1.6.0",
2020
"dayjs": "^1.11.9",
21-
"fuse.js": "^6.6.2",
21+
"fuse.js": "^7.0.0",
2222
"highlight.js": "^11.8.0",
23-
"jsdom": "^22.1.0",
23+
"jsdom": "^24.0.0",
2424
"lodash": "^4.17.21",
2525
"mermaid": "^10.2.4",
2626
"playwright": "^1.36.1",
27-
"rehype-mdx-code-props": "^1.0.0",
27+
"rehype-mdx-code-props": "^3.0.0",
2828
"rehype-mermaid": "^2.0.1",
2929
"sass": "^1.63.6",
3030
"tippy.js": "^6.3.7"
@@ -34,7 +34,8 @@
3434
"@types/canvas-confetti": "^1.6.0",
3535
"@types/jsdom": "^21.1.1",
3636
"@types/node": "^20.8.3",
37+
"@types/node-fetch": "^2.6.11",
3738
"@types/node-fetch-cache": "^3.0.0",
38-
"node-fetch-cache": "^3.1.3"
39+
"node-fetch-cache": "^4.1.0"
3940
}
4041
}

src/test/header.spec.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test.describe("Header", () => {
4+
test.beforeEach(async ({ page }) => {
5+
await page.goto("/wiki/");
6+
});
7+
8+
test("Exists", async ({ page }) => {
9+
await expect(page.getByRole("banner")).toBeVisible();
10+
});
11+
12+
test("Home Link", async ({ page, baseURL }) => {
13+
await page.getByRole("link", { name: "house" }).click();
14+
expect(page.url()).toBe(baseURL);
15+
});
16+
17+
test("Wiki Link", async ({ page, baseURL }) => {
18+
await page.getByRole("link", { name: "book" }).click();
19+
await page.waitForURL("/wiki/");
20+
expect(page.url()).toBe(baseURL + "wiki/");
21+
});
22+
23+
test("GitHub Link", async ({ page, context }) => {
24+
const href = await page
25+
.getByRole("link", { name: "github" })
26+
.getAttribute("href");
27+
expect(href).toBe("https://github.com/luals/lua-language-server");
28+
});
29+
});

src/test/index.spec.ts

+4-99
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { test, expect, Locator } from "@playwright/test";
1+
import { test, expect } from "@playwright/test";
22

33
test.describe("Home Page", () => {
44
test.beforeEach(async ({ page }) => {
5-
await page.route(
5+
page.route(
66
"https://api.github.com/repos/LuaLS/lua-language-server",
77
async (route) => {
88
const json = { stargazers_count: 2000 };
99
return route.fulfill({ json });
1010
}
1111
);
1212

13-
await page.route(
13+
page.route(
1414
"https://corsproxy.io/?https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery",
1515
async (route) => {
1616
const json = {
@@ -28,108 +28,13 @@ test.describe("Home Page", () => {
2828
}
2929
);
3030

31-
await page.goto("/");
31+
await page.goto("/", { waitUntil: "load", timeout: 3000 });
3232
});
3333

3434
test("Metadata", async ({ page }) => {
3535
await expect(page).toHaveTitle("Lua Language Server | Home");
3636
});
3737

38-
test.describe("Header", () => {
39-
test("Exists", async ({ page }) => {
40-
await expect(page.getByRole("banner")).toBeVisible();
41-
});
42-
43-
test("Home Link", async ({ page, baseURL }) => {
44-
await page.getByRole("link", { name: "house" }).click();
45-
expect(page.url()).toBe(baseURL);
46-
});
47-
48-
test("Wiki Link", async ({ page, baseURL }) => {
49-
await page.getByRole("link", { name: "book" }).click();
50-
await page.waitForURL("/wiki/");
51-
expect(page.url()).toBe(baseURL + "wiki/");
52-
});
53-
54-
test.describe("Search", async () => {
55-
let searchInput: Locator;
56-
57-
test.beforeEach(async ({ page }) => {
58-
searchInput = page.getByPlaceholder("Search...");
59-
});
60-
61-
const isOpen = async () => {
62-
await expect(searchInput).toBeVisible();
63-
await expect(searchInput).toBeFocused();
64-
};
65-
66-
const isClosed = async () => {
67-
await expect(searchInput).not.toBeVisible();
68-
};
69-
70-
test("Open Search With Button", async ({ page }) => {
71-
await page.getByRole("button", { name: "search" }).click();
72-
await isOpen();
73-
});
74-
75-
test("Open Search With Keypress", async ({ page }) => {
76-
await page.getByRole("document").press("/");
77-
await isOpen();
78-
});
79-
80-
test("Close Search With Escape", async ({ page }) => {
81-
await page.getByRole("document").press("/");
82-
await isOpen();
83-
await searchInput.press("Escape");
84-
await isClosed();
85-
});
86-
87-
test("Close Search By Clicking Background", async ({ page }) => {
88-
await page.getByRole("document").press("/");
89-
await isOpen();
90-
await page.locator("#site-search").click();
91-
await isClosed();
92-
});
93-
94-
test("Search Finds Privacy Page", async ({ page, baseURL }) => {
95-
await page.getByRole("document").press("/");
96-
await searchInput.fill("priva");
97-
const link = page.getByRole("link", { name: "Privacy /privacy" });
98-
99-
await expect(link).toBeVisible();
100-
await searchInput.press("Enter");
101-
await page.waitForURL("/privacy/");
102-
expect(page.url()).toBe(`${baseURL}privacy/`);
103-
await expect(page).toHaveTitle("Lua Language Server | Privacy");
104-
});
105-
106-
test("Search Finds GitHub Repository", async ({ page, context }) => {
107-
await page.getByRole("document").press("/");
108-
await searchInput.fill("reposit");
109-
const link = page.getByRole("link", {
110-
name: "GitHub Repository https://github.com/LuaLS/LuaLS.github.io",
111-
});
112-
113-
await expect(link).toBeVisible();
114-
115-
const pagePromise = context.waitForEvent("page");
116-
await searchInput.press("Enter");
117-
const newPage = await pagePromise;
118-
expect(newPage.url()).toBe("https://github.com/LuaLS/LuaLS.github.io");
119-
});
120-
});
121-
122-
test("GitHub Link", async ({ page, context }) => {
123-
const pagePromise = context.waitForEvent("page");
124-
await page.getByRole("link", { name: "github" }).click();
125-
const newPage = await pagePromise;
126-
await newPage.waitForLoadState();
127-
expect(newPage.url()).toBe(
128-
"https://github.com/luals/lua-language-server"
129-
);
130-
});
131-
});
132-
13338
test.describe("Install Instructions Visible", () => {
13439
test("VS Code", async ({ page, baseURL }) => {
13540
await page.getByRole("button", { name: "Visual Studio Code" }).click();

src/test/search.spec.ts

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { test, expect, type Locator } from "@playwright/test";
2+
3+
test.describe("Search", async () => {
4+
let searchInput: Locator;
5+
6+
test.beforeEach(async ({ page }) => {
7+
await page.goto("/wiki/");
8+
9+
searchInput = page.getByPlaceholder("Search...");
10+
});
11+
12+
const isOpen = async () => {
13+
await expect(searchInput).toBeVisible();
14+
await expect(searchInput).toBeFocused();
15+
};
16+
17+
const isClosed = async () => {
18+
await expect(searchInput).not.toBeVisible();
19+
};
20+
21+
test("Open Search With Button", async ({ page }) => {
22+
await page.getByRole("button", { name: "search" }).click();
23+
await isOpen();
24+
});
25+
26+
test("Open Search With Keypress", async ({ page }) => {
27+
await page.getByRole("document").press("/");
28+
await isOpen();
29+
});
30+
31+
test("Close Search With Escape", async ({ page }) => {
32+
await page.getByRole("document").press("/");
33+
await isOpen();
34+
await searchInput.press("Escape");
35+
await isClosed();
36+
});
37+
38+
test("Close Search By Clicking Background", async ({ page }) => {
39+
await page.getByRole("document").press("/");
40+
await isOpen();
41+
await page.locator("#site-search").click();
42+
await isClosed();
43+
});
44+
45+
test("Search Finds Privacy Page", async ({ page, baseURL }) => {
46+
await page.getByRole("document").press("/");
47+
await searchInput.fill("priva");
48+
const link = page.getByRole("link", { name: "Privacy /privacy" });
49+
50+
await expect(link).toBeVisible();
51+
await searchInput.press("Enter");
52+
expect(page.url()).toBe(`${baseURL}privacy/`);
53+
});
54+
55+
test("Search Finds GitHub Repository", async ({ page, context }) => {
56+
await page.getByRole("document").press("/");
57+
await searchInput.fill("reposit");
58+
const link = page.getByRole("link", {
59+
name: "GitHub Repository https://github.com/LuaLS/LuaLS.github.io",
60+
});
61+
62+
await expect(link).toBeVisible();
63+
64+
const href = await link.getAttribute("href");
65+
expect(href).toBe("https://github.com/LuaLS/LuaLS.github.io");
66+
});
67+
});

src/test/wiki_article.spec.ts

+12-17
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test.describe("Wiki Article", async () => {
2222
).toBeVisible();
2323
});
2424

25-
test("Article Sidebar", async ({ page, baseURL }) => {
25+
test("Article Sidebar", async ({ page }) => {
2626
const sidebar = page.locator("#article-browser");
2727

2828
await page.getByRole("button", { name: "newspaper" }).click();
@@ -32,13 +32,12 @@ test.describe("Wiki Article", async () => {
3232
expect(await sidebar.getAttribute("open")).toBe(null);
3333

3434
await page.getByRole("button", { name: "newspaper" }).click();
35-
await page.getByRole("link", { name: "Usage" }).click();
36-
await page.waitForURL(`${baseURL}wiki/usage/`);
37-
expect(page.url()).toBe(`${baseURL}wiki/usage/`);
38-
await expect(page.getByRole("heading", { name: "Usage" })).toBeVisible();
35+
const link = page.getByRole("link", { name: "Usage" });
36+
const href = await link.getAttribute("href");
37+
expect(href).toBe(`/wiki/usage/`);
3938
});
4039

41-
test("Outline Sidebar", async ({ page, baseURL }) => {
40+
test("Outline Sidebar", async ({ page }) => {
4241
const sidebar = page.locator("#outline");
4342

4443
await page.getByRole("button", { name: "list" }).click();
@@ -48,22 +47,18 @@ test.describe("Wiki Article", async () => {
4847
expect(await sidebar.getAttribute("open")).toBe(null);
4948

5049
await page.getByRole("button", { name: "list" }).click();
51-
await sidebar.getByRole("link", { name: "Build" }).click();
52-
await page.waitForURL(`${baseURL}wiki/build/#build`);
53-
expect(page.url()).toBe(`${baseURL}wiki/build/#build`);
54-
await expect(page.getByRole("heading", { name: "Build" })).toBeVisible();
50+
const link = sidebar.getByRole("link", { name: "Build" });
51+
const href = await link.getAttribute("href");
52+
expect(href).toBe(`#build`);
5553
});
5654

57-
test("Edit Page Button", async ({ page, context }) => {
55+
test("Edit Page Button", async ({ page }) => {
5856
const link = page.getByRole("link", { name: "pencil Edit this page" });
5957
await expect(link).toBeVisible();
6058

61-
const pagePromise = context.waitForEvent("page");
62-
await link.click();
63-
const newPage = await pagePromise;
64-
await newPage.waitForLoadState();
65-
expect(newPage.url()).toBe(
66-
"https://github.com/LuaLS/LuaLS.github.io/blob/main/src/content/wiki/build.mdx"
59+
const href = await link.getAttribute("href");
60+
expect(href).toBe(
61+
"https://github.com/LuaLS/LuaLS.github.io/tree/main/src/content/wiki/build.mdx"
6762
);
6863
});
6964

src/util/fetch.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
import {fetchBuilder, FileSystemCache } from "node-fetch-cache";
1+
import NodeFetchCache, { FileSystemCache } from "node-fetch-cache";
22
import type { default as nodeFetch } from "node-fetch";
33
import os from "os";
44

55
/* Cache location:
66
Windows: C:\Users\USER\AppData\Local\Temp\LuaLS_website_cache
7+
Linux: /tmp/LuaLS_website_cache
78
*/
89

910
const cacheDir = os.tmpdir() + "/LuaLS_website_cache/";
1011
const cacheDuration = 1800000; // 30 minutes;
11-
const cacheFetch = fetchBuilder.withCache(
12-
new FileSystemCache({ cacheDirectory: cacheDir, ttl: cacheDuration })
13-
);
12+
const cacheFetch = NodeFetchCache.create({
13+
cache: new FileSystemCache({ cacheDirectory: cacheDir, ttl: cacheDuration }),
14+
});
1415

1516
/** If in development mode, caches requests to prevent vite from DDOSing api endpoints */
1617
export default async (request: RequestInfo, init?: RequestInit) => {
1718
if (import.meta.env.PROD) {
1819
return await fetch(request, init);
1920
} else {
20-
return await cacheFetch(request as Parameters<typeof nodeFetch>[0], init as Parameters<typeof nodeFetch>[1]).then(async (response) => {
21+
return await cacheFetch(
22+
request as Parameters<typeof nodeFetch>[0],
23+
init as Parameters<typeof nodeFetch>[1]
24+
).then(async (response) => {
2125
if (!response.ok) {
2226
await response.ejectFromCache();
2327
throw new Error(`${response.status}: ${response.statusText}`);

0 commit comments

Comments
 (0)