Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows ci pass 2 #60

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
matrix:
os:
- ubuntu-latest
# - windows-latest
- windows-latest
- macos-latest
runtime:
- name: deno
Expand Down
47 changes: 26 additions & 21 deletions @mizu/http/event/mod_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
</render>
<script>
rendered.querySelector("div").dispatchEvent(new Event("event"))
await delay(100)
expect(http.request).toBeInstanceOf(Request)
expect(context.event).toBeInstanceOf(Event)
expect(context.content).toBe("bar")
await retry(() => {
expect(http.request).toBeInstanceOf(Request)
expect(context.event).toBeInstanceOf(Event)
expect(context.content).toBe("bar")
})
</script>
</test>

Expand All @@ -33,13 +34,14 @@
</render>
<script>
rendered.querySelector("div").dispatchEvent(new Event("event"))
await delay(100)
expect(http.request).toBeInstanceOf(Request)
expect(http.request.method).toBe("OPTIONS")
expect(http.request.headers.get("x-foo")).toBe("bar")
expect(http.request.received.body).toBe("foobar")
expect(context.event).toBeInstanceOf(Event)
expect(context.content).toBe("bar")
await retry(() => {
expect(http.request).toBeInstanceOf(Request)
expect(http.request.method).toBe("OPTIONS")
expect(http.request.headers.get("x-foo")).toBe("bar")
expect(http.request.received.body).toBe("foobar")
expect(context.event).toBeInstanceOf(Event)
expect(context.content).toBe("bar")
})
</script>
</test>

Expand All @@ -57,9 +59,10 @@
<script>
rendered.querySelector("p").dispatchEvent(new Event("a"))
rendered.querySelector("p").dispatchEvent(new Event("b"))
await delay(100)
expect(context.a).toBe(1)
expect(context.b).toBe(1)
await retry(() => {
expect(context.a).toBe(1)
expect(context.b).toBe(1)
})
</script>
</test>

Expand All @@ -77,13 +80,15 @@
</render>
<script>
rendered.querySelector("p").dispatchEvent(new Event("a"))
await delay(100)
expect(context.a).toBe("foo")
expect(context.b).toBeNull()
rendered.querySelector("p").dispatchEvent(new Event("b"))
await delay(100)
expect(context.a).toBe("foo")
expect(context.b).toBe("bar")
await retry(() => {
expect(context.a).toBe("foo")
expect(context.b).toBeNull()
rendered.querySelector("p").dispatchEvent(new Event("b"))
})
await retry(() => {
expect(context.a).toBe("foo")
expect(context.b).toBe("bar")
})
</script>
</test>

Expand Down
6 changes: 3 additions & 3 deletions @mizu/internal/testing/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function test(path: string | ImportMeta, runner = _test) {
let url = arguments[0]
if (!URL.canParse(url)) {
const { address: hostname, port } = testing.http.server?.address() as { address: string; port: number }
url = `http://${hostname.replace("0.0.0.0", "localhost")}:${port}${arguments[0]}`
url = `http://${hostname.replace("0.0.0.0", "127.0.0.1")}:${port}${arguments[0]}`
}
return fetch(url, ...Array.from(arguments).slice(1))
},
Expand Down Expand Up @@ -80,7 +80,7 @@ export function test(path: string | ImportMeta, runner = _test) {
} finally {
await testing.http.server?.close()
}
}, { permissions: { net: ["localhost", "0.0.0.0"] } })
}, { permissions: { net: ["localhost", "0.0.0.0", "127.0.0.1"] } })
})
}

Expand Down Expand Up @@ -288,7 +288,7 @@ async function http(operation: HTMLElement, testing: Testing) {
// Start server and update global location
testing.http.server.listen(0, "0.0.0.0", () => {
const { address: hostname, port } = testing.http.server?.address() as { address: string; port: number }
globalThis.location = Object.assign(new URL(`http://${hostname.replace("0.0.0.0", "localhost")}:${port}`), {
globalThis.location = Object.assign(new URL(`http://${hostname.replace("0.0.0.0", "127.0.0.1")}:${port}`), {
ancestorOrigins: testing.renderer.window.location.ancestorOrigins,
assign: testing.renderer.window.location.assign,
replace: testing.renderer.window.location.replace,
Expand Down
7 changes: 4 additions & 3 deletions @mizu/render/server/generate_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { testing } from "@libs/testing"
import { expect, fn, test } from "@libs/testing"
import { join, resolve } from "@std/path"
import { Server } from "./server.ts"
const output = resolve("/fake/path")
const root = resolve(import.meta.dirname!, "/")
const output = resolve(root, "/fake/path")
const encoder = new TextEncoder()
const fs = { stat: fn(), mkdir: fn(), rm: fn(), read: fn(), readdir: fn(() => []), write: fn() } as testing

Expand Down Expand Up @@ -94,8 +95,8 @@ test("`Server.generate()` can retrieve content from local files", async () => {
{ directory: "/", render: { select: "p", context: { foo: "baz" } } },
],
])
expect(write).toHaveBeenCalledWith(resolve("/fake/path/a/b/foo.html"), encoder.encode(`<p ~test.text="foo">bar</p>`))
expect(write).toHaveBeenCalledWith(resolve("/fake/path/bar.html"), encoder.encode(`<p ~test.text="foo">baz</p>`))
expect(write).toHaveBeenCalledWith(resolve(root, "/fake/path/a/b/foo.html"), encoder.encode(`<p ~test.text="foo">bar</p>`))
expect(write).toHaveBeenCalledWith(resolve(root, "/fake/path/bar.html"), encoder.encode(`<p ~test.text="foo">baz</p>`))
}
}, { permissions: { read: true } })

Expand Down
8 changes: 8 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,17 @@
"dependencies": ["build:www"]
},
"reinstall": {
"description": "Alias for task reinstall:deno",
"command": "sleep 0"
},
Comment on lines +120 to +122

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually alias it :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch !
Opened #64

"reinstall:deno": {
"description": "Clean and reinstall dependencies (deno)",
"command": "rm -rf node_modules deno.lock package.json package-lock.json && deno install"
},
"reinstall:node": {
"description": "Clean and reinstall dependencies (node)",
"command": "rm -rf node_modules package-lock.json && npm install"
},
// Miscellaneous tasks
"repo:fill-scopes": {
"description": "Fill scopes in repository files",
Expand Down
Loading