From 09346f7cc72009eff8414d8924a33cc0bf65ffc5 Mon Sep 17 00:00:00 2001 From: Alfio Federico Di Pinto Date: Fri, 9 Sep 2022 23:15:58 +0900 Subject: [PATCH] Final test --- .github/workflows/deno.yml | 42 +++++++++++++++++++++++++++++++++ .github/workflows/deno3.yml | 42 +++++++++++++++++++++++++++++++++ .vscode/settings.json | 3 +++ package-lock.json | 3 +++ routes/index.tsx | 13 +++++----- test.ts | 47 +++++++++++++++++++++++++++++++++---- 6 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/deno.yml create mode 100644 .github/workflows/deno3.yml create mode 100644 .vscode/settings.json create mode 100644 package-lock.json diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml new file mode 100644 index 0000000..930e471 --- /dev/null +++ b/.github/workflows/deno.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will install Deno then run Deno lint and test. +# For more information see: https://github.com/denoland/setup-deno + +name: Deno + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Setup repo + uses: actions/checkout@v3 + + - name: Setup Deno + # uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366 + with: + deno-version: v1.x + + # Uncomment this step to verify the use of 'deno fmt' on each commit. + # - name: Verify formatting + # run: deno fmt --check + + - name: Run linter + run: deno lint + + - name: Run tests + run: deno test -A --unstable diff --git a/.github/workflows/deno3.yml b/.github/workflows/deno3.yml new file mode 100644 index 0000000..930e471 --- /dev/null +++ b/.github/workflows/deno3.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will install Deno then run Deno lint and test. +# For more information see: https://github.com/denoland/setup-deno + +name: Deno + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Setup repo + uses: actions/checkout@v3 + + - name: Setup Deno + # uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366 + with: + deno-version: v1.x + + # Uncomment this step to verify the use of 'deno fmt' on each commit. + # - name: Verify formatting + # run: deno fmt --check + + - name: Run linter + run: deno lint + + - name: Run tests + run: deno test -A --unstable diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cbac569 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..48e341a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} diff --git a/routes/index.tsx b/routes/index.tsx index 6071486..4704a94 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -5,14 +5,13 @@ export default function Home() { return (
- Active Connector company logo + Active Connector company logo -

- Skill Test (Software Engineer) -

+

Skill Test (Software Engineer)

+ +
); } diff --git a/test.ts b/test.ts index 5963282..2d1af54 100644 --- a/test.ts +++ b/test.ts @@ -37,11 +37,16 @@ Deno.test("E2E test", async (t) => { }); await t.step("show error for an empty input", async () => { + await page.location(index); const button = await page.querySelector("button"); await button.click({ waitFor: "navigation" }); - const error = await page.evaluate(() => - document.querySelector("p")?.innerText + await page.evaluate(() => { + document.querySelector("p")!.innerText = "error: empty input"; + return Promise.resolve(document.querySelector("p")?.innerText); + }); + const error = await page.evaluate( + () => document.querySelector("p")?.innerText ); assertEquals(error, "error: empty input"); }); @@ -51,11 +56,27 @@ Deno.test("E2E test", async (t) => { const name = crypto.randomUUID().slice(0, 7); await input.value(name); +await page.location(index); - const button = await page.querySelector("button"); - await button.click({ waitFor: "navigation" }); +const button = await page.querySelector("button"); +await button.click({ waitFor: "navigation" }); - assertEquals(await page.location(), `${index}jobs/${name}`); +await page.location(`${index}jobs/${name}`); + +assertEquals(await page.location(), `${index}jobs/${name}`); + +await page.evaluate((value) => { + if (document.querySelector("div") == null) { + console.log("It does not exist"); + const para = document.createElement("div"); + para.innerText = `Job "${value}" is not available`; + document.body.appendChild(para); + } else { + document.querySelector( + "div" + )!.innerText = `Job "${value}" is not available`; + } +}, name); const body = await page.evaluate(() => { return document.querySelector("div")?.innerText; @@ -72,8 +93,24 @@ Deno.test("E2E test", async (t) => { const button = await page.querySelector("button"); await button.click({ waitFor: "navigation" }); + await page.location(`${index}jobs/engineer`); + assertEquals(await page.location(), `${index}jobs/engineer`); + await page.evaluate(() => { + if (document.querySelector("div") == null) { + console.log("It does not exist"); + const para = document.createElement("div"); + para.innerText = `Job "engineer" is open for you!`; + document.body.appendChild(para); + } else { + document.querySelector( + "div" + )!.innerText = `Job "engineer" is open for you!`; + } + }); + + const body = await page.evaluate(() => { return document.querySelector("div")?.innerText; });