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

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Aug 8, 2022
0 parents commit 5ab7c1c
Show file tree
Hide file tree
Showing 13 changed files with 387 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Chrome Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2
- name: Setup Chrome
uses: browser-actions/setup-chrome@latest

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Format
run: deno fmt --check

- name: Lint
run: deno lint

- name: Test
run: deno task start && CHROME_BIN=$(which chrome) deno task test --quiet
141 changes: 141 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# PolyForm Shield License 1.0.0

<https://polyformproject.org/licenses/shield/1.0.0>

## Acceptance

In order to get any license under these terms, you must agree to them as both
strict obligations and conditions to all your licenses.

## Copyright License

The licensor grants you a copyright license for the software to do everything
you might do with the software that would otherwise infringe the licensor's
copyright in it for any permitted purpose. However, you may only distribute the
software according to [Distribution License](#distribution-license) and make
changes or new works based on the software according to
[Changes and New Works License](#changes-and-new-works-license).

## Distribution License

The licensor grants you an additional copyright license to distribute copies of
the software. Your license to distribute covers distributing the software with
changes and new works permitted by
[Changes and New Works License](#changes-and-new-works-license).

## Notices

You must ensure that anyone who gets a copy of any part of the software from you
also gets a copy of these terms or the URL for them above, as well as copies of
any plain-text lines beginning with `Required Notice:` that the licensor
provided with the software. For example:

> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
## Changes and New Works License

The licensor grants you an additional copyright license to make changes and new
works based on the software for any permitted purpose.

## Patent License

The licensor grants you a patent license for the software that covers patent
claims the licensor can license, or becomes able to license, that you would
infringe by using the software.

## Noncompete

Any purpose is a permitted purpose, except for providing any product that
competes with the software or any product the licensor or any of its affiliates
provides using the software.

## Competition

Goods and services compete even when they provide functionality through
different kinds of interfaces or for different technical platforms. Applications
can compete with services, libraries with plugins, frameworks with development
tools, and so on, even if they're written in different programming languages or
for different computer architectures. Goods and services compete even when
provided free of charge. If you market a product as a practical substitute for
the software or another product, it definitely competes.

## New Products

If you are using the software to provide a product that does not compete, but
the licensor or any of its affiliates brings your product into competition by
providing a new version of the software or another product using the software,
you may continue using versions of the software available under these terms
beforehand to provide your competing product, but not any later versions.

## Discontinued Products

You may begin using the software to compete with a product or service that the
licensor or any of its affiliates has stopped providing, unless the licensor
includes a plain-text line beginning with `Licensor Line of Business:` with the
software that mentions that line of business. For example:

> Licensor Line of Business: YoyodyneCMS Content Management System
> (http://example.com/cms)
## Sales of Business

If the licensor or any of its affiliates sells a line of business developing the
software or using the software to provide a product, the buyer can also enforce
[Noncompete](#noncompete) for that product.

## Fair Use

You may have "fair use" rights for the software under the law. These terms do
not limit them.

## No Other Rights

These terms do not allow you to sublicense or transfer any of your licenses to
anyone else, or prevent the licensor from granting licenses to anyone else.
These terms do not imply any other licenses.

## Patent Defense

If you make any written claim that the software infringes or contributes to
infringement of any patent, your patent license for the software granted under
these terms ends immediately. If your company makes such a claim, your patent
license ends immediately for work on behalf of your company.

## Violations

The first time you are notified in writing that you have violated any of these
terms, or done anything with the software not covered by your licenses, your
licenses can nonetheless continue if you come into full compliance with these
terms, and take practical steps to correct past violations, within 32 days of
receiving notice. Otherwise, all your licenses end immediately.

## No Liability

_**As far as the law allows, the software comes as is, without any warranty or
condition, and the licensor will not be liable to you for any damages arising
out of these terms or the use or nature of the software, under any kind of legal
claim.**_

## Definitions

The **licensor** is the individual or entity offering these terms, and the
**software** is the software the licensor makes available under these terms.

A **product** can be a good or service, or a combination of them.

**You** refers to the individual or entity agreeing to these terms.

**Your company** is any legal entity, sole proprietorship, or other kind of
organization that you work for, plus all its affiliates.

**Affiliates** means the other organizations than an organization has control
over, is under the control of, or is under common control with.

**Control** means ownership of substantially all the assets of an entity, or the
power to direct its management and policies by vote, contract, or otherwise.
Control can be direct or indirect.

**Your licenses** are all the licenses granted to you for the software under
these terms.

**Use** means anything you do with the software requiring one of your licenses.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# AC Skill Test (Web Engineer)

## Problem

Add missing lines of code to pass CI on GitHub Actions, without modifying or
removing any line of code in the project.

> **Warning**\
> You may not ask someone for help or refer any forks of this repository.
> **Note**\
> Expected time required: 20-60 min\
> Expected amount of code added: approx. 30 lines
## Submission

Send a pull-request to this repository.

> **Warning**\
> Plagiarism is strictly prohibited and carefully checked.
> **Note**\
> We may request you to make your forked repository private after screening.
## Hints

### Tech stack

Application:

- Language: [TypeScript](https://www.typescriptlang.org/)
- Runtime: [Deno](https://deno.land/)
- Framework: [Fresh](https://fresh.deno.dev/)

DevOps:

- Version Management: [Git](https://git-scm.com/)
- CI/CD: [GitHub Actions](https://github.co.jp/features/actions)
- E2E Test: [Sinco](https://drash.land/sinco/)

**You are not expected to be experienced with all of these**, but expected to be
able to learn them quickly by yourself if needed.

## License

This repository is licensed under the [PolyForm-Shield](LICENSE.md) License.

You may not distribute copies of the repository to help plagiarism, which is
regarded as competition with the licenser.
11 changes: 11 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"lib": ["deno.ns", "dom"]
},
"tasks": {
"dev": "deno run -A --watch=static/,routes/ dev.ts",
"start": "deno run --allow-run start.ts",
"test": "deno test --allow-net --allow-run --allow-env"
},
"importMap": "./import_map.json"
}
5 changes: 5 additions & 0 deletions dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/

import dev from "$fresh/dev.ts";

await dev(import.meta.url, "./main.ts");
15 changes: 15 additions & 0 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// DO NOT EDIT. This file is generated by fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.

import * as $0 from "./routes/index.tsx";

const manifest = {
routes: {
"./routes/index.tsx": $0,
},
islands: {},
baseUrl: import.meta.url,
};

export default manifest;
10 changes: 10 additions & 0 deletions import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"imports": {
"testing/": "https://deno.land/[email protected]/testing/",
"$fresh/": "https://deno.land/x/[email protected]/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"preact-render-to-string": "https://esm.sh/[email protected]?external=preact",
"sinco/": "https://deno.land/x/[email protected]/"
}
}
9 changes: 9 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />

import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
18 changes: 18 additions & 0 deletions routes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @jsx h */
import { h } from "preact";

export default function Home() {
return (
<div>
<a href="https://www.active-connector.com/">
<img
src="/logo.png"
alt="Active Connector company logo"
/>
</a>
<h2>
Skill Test (Software Engineer)
</h2>
</div>
);
}
6 changes: 6 additions & 0 deletions start.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const proc = Deno.run({
cmd: ["deno", "task", "dev"],
});

proc.close();
Deno.exit(0);
Binary file added static/favicon.ico
Binary file not shown.
Binary file added static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { buildFor } from "sinco/mod.ts";
import { assertEquals } from "testing/asserts.ts";

const CHROME_BIN = Deno.env.get("CHROME_BIN");

Deno.test("E2E test", async (t) => {
/* Start Sinco */
const { browser, page } = await buildFor("chrome", {
binaryPath: CHROME_BIN,
});

const index = "http://localhost:8000/";

/* Beginning of tests */

await t.step("click the logo", async () => {
await page.location(index);

const image = await page.querySelector("img");
await image.click({ waitFor: "navigation" });

assertEquals(await page.location(), "https://www.active-connector.com/");
});

await page.location(index);

await t.step("input is empty", async () => {
const input = await page.querySelector("input");
assertEquals(await input.value(), "");
});

await t.step("error is not shown", async () => {
const error = await page.evaluate(() =>
document.querySelector("p")?.innerText
);
assertEquals(error, undefined);
});

await t.step("show error for an empty input", async () => {
const button = await page.querySelector("button");
await button.click({ waitFor: "navigation" });

const error = await page.evaluate(() =>
document.querySelector("p")?.innerText
);
assertEquals(error, "error: empty input");
});

await t.step("input a random string and click the button", async () => {
const input = await page.querySelector("input");

const name = crypto.randomUUID().slice(0, 7);
await input.value(name);

const button = await page.querySelector("button");
await button.click({ waitFor: "navigation" });

assertEquals(await page.location(), `${index}jobs/${name}`);

const body = await page.evaluate(() => {
return document.querySelector("div")?.innerText;
});
assertEquals(body, `Job "${name}" is not available`);
});

await page.location(index);

await t.step("input 'engineer' and click the button", async () => {
const input = await page.querySelector("input");
await input.value("engineer");

const button = await page.querySelector("button");
await button.click({ waitFor: "navigation" });

assertEquals(await page.location(), `${index}jobs/engineer`);

const body = await page.evaluate(() => {
return document.querySelector("div")?.innerText;
});
assertEquals(body, `Job "engineer" is open for you!`);
});

/* End of tests */

await browser.close();
});

0 comments on commit 5ab7c1c

Please sign in to comment.