lightnet 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +11 -1
- package/__e2e__/admin.spec.ts +0 -20
- package/__e2e__/basics-fixture.ts +0 -23
- package/__e2e__/fixtures/basics/astro.config.mjs +0 -35
- package/__e2e__/fixtures/basics/node_modules/.bin/astro +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tailwind +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tailwindcss +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tsc +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tsserver +0 -21
- package/__e2e__/fixtures/basics/package.json +0 -22
- package/__e2e__/fixtures/basics/public/favicon.svg +0 -1
- package/__e2e__/fixtures/basics/public/files/example.pdf +0 -0
- package/__e2e__/fixtures/basics/src/assets/logo.png +0 -0
- package/__e2e__/fixtures/basics/src/content/categories/christian-living.json +0 -6
- package/__e2e__/fixtures/basics/src/content/categories/teens.json +0 -6
- package/__e2e__/fixtures/basics/src/content/categories/theology.json +0 -6
- package/__e2e__/fixtures/basics/src/content/media/faithful-freestyle--en.json +0 -17
- package/__e2e__/fixtures/basics/src/content/media/how-to-kickflip--de.json +0 -17
- package/__e2e__/fixtures/basics/src/content/media/images/cover.jpg +0 -0
- package/__e2e__/fixtures/basics/src/content/media/images/how-to-kickflip--en.webp +0 -0
- package/__e2e__/fixtures/basics/src/content/media/skate-sounds--en.json +0 -21
- package/__e2e__/fixtures/basics/src/content/media-collections/how-to-articles.json +0 -7
- package/__e2e__/fixtures/basics/src/content/media-types/audio.json +0 -10
- package/__e2e__/fixtures/basics/src/content/media-types/book.json +0 -15
- package/__e2e__/fixtures/basics/src/content/media-types/video.json +0 -10
- package/__e2e__/fixtures/basics/src/content.config.ts +0 -3
- package/__e2e__/fixtures/basics/src/pages/[locale]/index.astro +0 -15
- package/__e2e__/fixtures/basics/src/translations/de.yml +0 -1
- package/__e2e__/fixtures/basics/src/translations/en.yml +0 -1
- package/__e2e__/fixtures/basics/tailwind.config.mjs +0 -8
- package/__e2e__/global.teardown.ts +0 -5
- package/__e2e__/homepage.spec.ts +0 -123
- package/__e2e__/search.spec.ts +0 -14
- package/__tests__/astro-integration/config.spec.ts +0 -364
- package/__tests__/astro-integration/integration.spec.ts +0 -125
- package/__tests__/astro-integration/tailwind.spec.ts +0 -36
- package/__tests__/content/content-schema.spec.ts +0 -109
- package/__tests__/content/get-media-collections.spec.ts +0 -72
- package/__tests__/content/query-media-items.spec.ts +0 -213
- package/__tests__/i18n/resolve-current-locale.spec.ts +0 -65
- package/__tests__/i18n/translate-map.spec.ts +0 -19
- package/__tests__/i18n/translate.spec.ts +0 -91
- package/__tests__/pages/details-page/create-content-metadata.spec.ts +0 -153
- package/__tests__/pages/details-page/get-translations.spec.ts +0 -56
- package/__tests__/utils/markdown.spec.ts +0 -74
- package/__tests__/utils/paths.spec.ts +0 -116
- package/__tests__/utils/urls.spec.ts +0 -32
- package/playwright.config.ts +0 -31
- package/vitest.config.js +0 -36
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { afterEach, expect, test, vi } from "vitest"
|
|
2
|
-
|
|
3
|
-
afterEach(() => {
|
|
4
|
-
vi.unstubAllEnvs()
|
|
5
|
-
vi.resetModules()
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test("Should build localized paths at root base", async () => {
|
|
9
|
-
vi.stubEnv("BASE_URL", "/")
|
|
10
|
-
|
|
11
|
-
const { detailsPagePath, localizePath, searchPagePath } =
|
|
12
|
-
await import("../../src/utils/paths")
|
|
13
|
-
|
|
14
|
-
expect(detailsPagePath("en", { id: "my-book" })).toBe("/en/media/my-book")
|
|
15
|
-
expect(searchPagePath("en", { category: "comics" })).toBe(
|
|
16
|
-
"/en/media?category=comics",
|
|
17
|
-
)
|
|
18
|
-
expect(localizePath("en", "/about")).toBe("/en/about")
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test("Should keep internal paths unchanged at root base", async () => {
|
|
22
|
-
vi.stubEnv("BASE_URL", "/")
|
|
23
|
-
|
|
24
|
-
const { pathWithBase } = await import("../../src/utils/paths")
|
|
25
|
-
|
|
26
|
-
expect(pathWithBase("/en/about")).toBe("/en/about")
|
|
27
|
-
expect(pathWithBase("/en/media?category=comics#results")).toBe(
|
|
28
|
-
"/en/media?category=comics#results",
|
|
29
|
-
)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test("Should prefix localized paths with Astro base", async () => {
|
|
33
|
-
vi.stubEnv("BASE_URL", "/docs/")
|
|
34
|
-
|
|
35
|
-
const { detailsPagePath, localizePath, searchPagePath } =
|
|
36
|
-
await import("../../src/utils/paths")
|
|
37
|
-
|
|
38
|
-
expect(detailsPagePath("en", { id: "my-book" })).toBe(
|
|
39
|
-
"/docs/en/media/my-book",
|
|
40
|
-
)
|
|
41
|
-
expect(searchPagePath("en", { category: "comics" })).toBe(
|
|
42
|
-
"/docs/en/media?category=comics",
|
|
43
|
-
)
|
|
44
|
-
expect(localizePath("en", "/about")).toBe("/docs/en/about")
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test("Should prefix internal API paths with Astro base", async () => {
|
|
48
|
-
vi.stubEnv("BASE_URL", "/docs/")
|
|
49
|
-
|
|
50
|
-
const { pathWithBase } = await import("../../src/utils/paths")
|
|
51
|
-
|
|
52
|
-
expect(pathWithBase("/api/internal/search.json")).toBe(
|
|
53
|
-
"/docs/api/internal/search.json",
|
|
54
|
-
)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test("Should strip Astro base from pathname", async () => {
|
|
58
|
-
vi.stubEnv("BASE_URL", "/docs/")
|
|
59
|
-
|
|
60
|
-
const { pathWithoutBase } = await import("../../src/utils/paths")
|
|
61
|
-
|
|
62
|
-
expect(pathWithoutBase("/docs/en/media")).toBe("/en/media")
|
|
63
|
-
expect(pathWithoutBase("/docs")).toBe("/")
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test("Should leave root-base pathname unchanged", async () => {
|
|
67
|
-
vi.stubEnv("BASE_URL", "/")
|
|
68
|
-
|
|
69
|
-
const { pathWithoutBase } = await import("../../src/utils/paths")
|
|
70
|
-
|
|
71
|
-
expect(pathWithoutBase("/en/media")).toBe("/en/media")
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test("Should support explicit base when stripping pathname", async () => {
|
|
75
|
-
const { pathWithoutBase } = await import("../../src/utils/paths")
|
|
76
|
-
|
|
77
|
-
expect(pathWithoutBase("/custom/en/media", "/custom/")).toBe("/en/media")
|
|
78
|
-
expect(pathWithoutBase("/en/media", "/custom/")).toBe("/en/media")
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test("Should preserve root path under Astro base", async () => {
|
|
82
|
-
vi.stubEnv("BASE_URL", "/docs/")
|
|
83
|
-
|
|
84
|
-
const { pathWithBase, localizePath } = await import("../../src/utils/paths")
|
|
85
|
-
|
|
86
|
-
expect(pathWithBase("/")).toBe("/docs/")
|
|
87
|
-
expect(localizePath(undefined, "/")).toBe("/docs/")
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test("Should preserve root path at root base", async () => {
|
|
91
|
-
vi.stubEnv("BASE_URL", "/")
|
|
92
|
-
|
|
93
|
-
const { pathWithBase, localizePath } = await import("../../src/utils/paths")
|
|
94
|
-
|
|
95
|
-
expect(pathWithBase("/")).toBe("/")
|
|
96
|
-
expect(localizePath(undefined, "/")).toBe("/")
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
test("Should preserve query strings and hashes", async () => {
|
|
100
|
-
vi.stubEnv("BASE_URL", "/docs/")
|
|
101
|
-
|
|
102
|
-
const { pathWithBase } = await import("../../src/utils/paths")
|
|
103
|
-
|
|
104
|
-
expect(pathWithBase("/en/media?category=comics#results")).toBe(
|
|
105
|
-
"/docs/en/media?category=comics#results",
|
|
106
|
-
)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test("Should normalize slashes between base and path", async () => {
|
|
110
|
-
vi.stubEnv("BASE_URL", "/docs/")
|
|
111
|
-
|
|
112
|
-
const { pathWithBase } = await import("../../src/utils/paths")
|
|
113
|
-
|
|
114
|
-
expect(pathWithBase("/en/about")).toBe("/docs/en/about")
|
|
115
|
-
expect(pathWithBase("en/about")).toBe("/docs/en/about")
|
|
116
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import config from "virtual:lightnet/config"
|
|
2
|
-
import { afterEach, expect, test, vi } from "vitest"
|
|
3
|
-
|
|
4
|
-
import { isExternalUrl } from "../../src/utils/urls"
|
|
5
|
-
|
|
6
|
-
// relative path should be treated as internal
|
|
7
|
-
test("Should treat relative paths as internal", () => {
|
|
8
|
-
expect(isExternalUrl("/page")).toBe(false)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
vi.unstubAllEnvs()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
// absolute url that matches the configured site should be internal
|
|
16
|
-
test("Should treat URLs matching import.meta.env.SITE as internal", () => {
|
|
17
|
-
vi.stubEnv("SITE", "https://sk8-ministries.dev")
|
|
18
|
-
|
|
19
|
-
expect(isExternalUrl("https://sk8-ministries.dev/page")).toBe(false)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
// domains listed in internalDomains should be treated as internal
|
|
23
|
-
test("Should treat configured internalDomains as internal", () => {
|
|
24
|
-
config.internalDomains.push("internal.test")
|
|
25
|
-
expect(isExternalUrl("https://internal.test/foo")).toBe(false)
|
|
26
|
-
config.internalDomains.pop()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
// any other absolute url should be external
|
|
30
|
-
test("Should treat other absolute URLs as external", () => {
|
|
31
|
-
expect(isExternalUrl("https://example.com")).toBe(true)
|
|
32
|
-
})
|
package/playwright.config.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { defineConfig, devices } from "@playwright/test"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* See https://playwright.dev/docs/test-configuration.
|
|
5
|
-
*/
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
testDir: "./__e2e__",
|
|
8
|
-
globalTeardown: "./__e2e__/global.teardown.ts",
|
|
9
|
-
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
10
|
-
forbidOnly: !!process.env.CI,
|
|
11
|
-
/* Retry on CI only */
|
|
12
|
-
retries: process.env.CI ? 2 : 0,
|
|
13
|
-
/* Opt out of parallel tests. */
|
|
14
|
-
workers: 1,
|
|
15
|
-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
16
|
-
reporter: "html",
|
|
17
|
-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
18
|
-
use: {
|
|
19
|
-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
20
|
-
trace: "on-first-retry",
|
|
21
|
-
viewport: { width: 1280, height: 800 }, // Set default viewport
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
/* Configure projects for major browsers */
|
|
25
|
-
projects: [
|
|
26
|
-
{
|
|
27
|
-
name: "chromium",
|
|
28
|
-
use: { ...devices["Desktop Chrome"] },
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
})
|
package/vitest.config.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config"
|
|
2
|
-
|
|
3
|
-
import { vitePluginLightnetConfig } from "./src/astro-integration/vite-plugin-lightnet-config"
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
test: {
|
|
7
|
-
include: ["__tests__/**/*.spec.ts"],
|
|
8
|
-
},
|
|
9
|
-
plugins: [
|
|
10
|
-
vitePluginLightnetConfig(
|
|
11
|
-
{
|
|
12
|
-
title: { en: "Sk8 Ministries" },
|
|
13
|
-
logo: { src: "./logo.svg" },
|
|
14
|
-
languages: [
|
|
15
|
-
{
|
|
16
|
-
code: "en",
|
|
17
|
-
label: { en: "English" },
|
|
18
|
-
isDefaultSiteLanguage: true,
|
|
19
|
-
isSiteLanguage: true,
|
|
20
|
-
fallbackLanguages: [],
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
code: "de",
|
|
24
|
-
label: { en: "German" },
|
|
25
|
-
isSiteLanguage: true,
|
|
26
|
-
fallbackLanguages: ["en"],
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
locales: ["en", "de"],
|
|
30
|
-
defaultLocale: "en",
|
|
31
|
-
internalDomains: [],
|
|
32
|
-
},
|
|
33
|
-
{ site: "https://sk8-ministries.dev" },
|
|
34
|
-
),
|
|
35
|
-
],
|
|
36
|
-
})
|