From 8352bbce500660d4f1723b5f6b5fe74fc0997675 Mon Sep 17 00:00:00 2001 From: Taylor Y Date: Sat, 19 Aug 2023 08:46:47 -0700 Subject: [PATCH] upgrade tests --- .github/workflows/deno.yml | 20 +++++++++++--------- deno.json | 4 ++-- test/puppet_test.js | 21 +++++++++++++-------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml index 8c11e7f..fed1207 100644 --- a/.github/workflows/deno.yml +++ b/.github/workflows/deno.yml @@ -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: @@ -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 @@ -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 diff --git a/deno.json b/deno.json index e1b1d84..fada166 100644 --- a/deno.json +++ b/deno.json @@ -24,7 +24,7 @@ "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/", @@ -32,7 +32,7 @@ "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" diff --git a/test/puppet_test.js b/test/puppet_test.js index d365e8d..de31a27 100644 --- a/test/puppet_test.js +++ b/test/puppet_test.js @@ -1,6 +1,7 @@ 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 } @@ -8,55 +9,59 @@ const puppet_config = CURRENT_ENV === "development" 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`, {