Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Final test #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions .github/workflows/deno3.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ export default function Home() {
return (
<div>
<a href="https://www.active-connector.com/">
<img
src="/logo.png"
alt="Active Connector company logo"
/>
<img src="/logo.png" alt="Active Connector company logo" />
</a>
<h2>
Skill Test (Software Engineer)
</h2>
<h2>Skill Test (Software Engineer)</h2>
<a href="https://www.active-connector.com/">
<button />
</a>
<input type="text"></input>
</div>
);
}
47 changes: 42 additions & 5 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand All @@ -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;
Expand All @@ -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;
});
Expand Down