Skip to content

Commit

Permalink
upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldesigndj committed Aug 19, 2023
1 parent 9abccb7 commit 8352bbc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/deno.yml
Expand Up @@ -10,8 +10,8 @@ on:
branches: ["main","test"]

permissions:
id-token: write # This is required to allow the GitHub Action to authenticate with Deno Deploy.
contents: read
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository

jobs:
test:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.30.3
deno-version: v1.x

- name: Verify formatting
run: deno fmt --check
Expand All @@ -57,10 +57,12 @@ jobs:

- name: Run tests
run: deno test -A

- name: Build step
run: "deno task build" # 📝 Update the build command(s) if necessary

# - name: Deploy to Deno Deploy - fresh-strapi.deno.dev
# uses: denoland/deployctl@v1
# with:
# project: fresh-strapi # the name of the project on Deno Deploy
# entrypoint: main.ts # the entrypoint to deploy
# import-map: import_map.json # because fresh needs this
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "fresh-strapi" # 📝 Update the deploy project name if necessary
entrypoint: "./main.ts" # 📝 Update the entrypoint if necessary
4 changes: 2 additions & 2 deletions deno.json
Expand Up @@ -24,15 +24,15 @@
"imports": {
"@/": "./",
"$fresh/": "https://deno.land/x/fresh@1.4.2/",
"$std/": "https://deno.land/std@0.177.0/",
"$std/": "https://deno.land/std@0.198.0/",
"gfm": "https://deno.land/x/gfm@0.1.22/mod.ts",
"preact": "https://esm.sh/preact@10.15.1",
"preact/": "https://esm.sh/preact@10.15.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.1",
"twind": "https://esm.sh/twind@0.16.19",
"twind/": "https://esm.sh/twind@0.16.19/",
"redis": "https://deno.land/x/redis@v0.29.1/mod.ts",
"fresh_marionette": "https://deno.land/x/fresh_marionette@v1.1.0/mod.js",
"fresh_marionette": "https://deno.land/x/fresh_marionette@v2.0.1/mod.js",
"envalid": "https://deno.land/x/envalid@0.1.2/mod.ts",
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.2.3"
Expand Down
21 changes: 13 additions & 8 deletions test/puppet_test.js
@@ -1,62 +1,67 @@
import { assertEquals } from "$std/testing/asserts.ts"
import { freshPuppetTestWrapper } from "fresh_marionette"
import { BASE_URL, CURRENT_ENV } from "@/utils/config.js"
import { Status } from "$std/http/http_status.ts"

const puppet_config = CURRENT_ENV === "development"
? { headless: false, defaultViewport: null }
: { headless: true }

Deno.test(
"Public Pages Testing",
{
sanitizeResources: false,
sanitizeOps: false,
},
freshPuppetTestWrapper(puppet_config, async (t, page) => {
await t.step("The homepage should work", async () => {
const response = await page.goto(`${BASE_URL}`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 200)
assertEquals(response.status(), Status.OK)
})
await t.step("The login page should 200", async () => {
const response = await page.goto(`${BASE_URL}/login`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 200)
assertEquals(response.status(), Status.OK)
})
await t.step("The logout page should 200", async () => {
const response = await page.goto(`${BASE_URL}/login`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 200)
assertEquals(response.status(), Status.OK)
})
await t.step("The forgot password page should 200", async () => {
const response = await page.goto(`${BASE_URL}/forgot-password`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 200)
assertEquals(response.status(), Status.OK)
})
await t.step("The forgot password success page should 200", async () => {
const response = await page.goto(`${BASE_URL}/forgot-password/success`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 200)
assertEquals(response.status(), Status.OK)
})
await t.step("The reset password page should 200", async () => {
const response = await page.goto(`${BASE_URL}/reset-password`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 200)
assertEquals(response.status(), Status.OK)
})
await t.step("The account page should 401", async () => {
// This is really a 301 to 401...
const response = await page.goto(`${BASE_URL}/account`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 401)
assertEquals(response.status(), Status.Unauthorized)
})
await t.step("The error page should 404", async () => {
const response = await page.goto(`${BASE_URL}/404`, {
waitUntil: "networkidle2",
})
assertEquals(response.status(), 404)
assertEquals(response.status(), Status.NotFound)
})
await t.step("The unauthorized page should 401", async () => {
const response = await page.goto(`${BASE_URL}/unauthorized`, {
Expand Down

0 comments on commit 8352bbc

Please sign in to comment.