Skip to content

solution #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits 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
4 changes: 4 additions & 0 deletions .github/workflows/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see a new workflow file added for automated testing! This will definitely help to ensure code quality and streamline the testing process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's recommended to use an LTS version of Node.js for better stability and long-term support. Consider changing the node-version to 16 instead of 18.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice usage of npm ci for a deterministic dependency installation! This ensures that the installed dependencies match the lockfile exactly, making the build process more consistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job setting up the GitHub Actions workflow! It's well-structured and easy to understand.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: JobSimulator.dev Test Checker

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

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
test:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.31.0-focal
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci && cd .github/workflows && npm ci && cd ../..

- name: build app
run: npx webpack

- name: start webpack server
run: npx webpack serve &

- name: start backend
run: npm run start-json-server &

- name: Run Tests
run: node .github/workflows/test.js
169 changes: 169 additions & 0 deletions .github/workflows/package-lock.json
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you've added a package-lock.json file in the .github/workflows directory. Typically, package-lock.json should be at the root level of the project, alongside the package.json file. Please move the package-lock.json file to the correct location.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the package-lock.json file has been added inside the .github/workflows directory. Please move it to the root of the project, as it should be placed alongside the package.json file.

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

8 changes: 8 additions & 0 deletions .github/workflows/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "module",
"devDependencies": {
"playwright": "^1.31.1",
"uvu": "^0.5.6"
},
"scripts": {}
}
96 changes: 96 additions & 0 deletions .github/workflows/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { chromium } from "playwright";
import { setTimeout } from "timers/promises";
import { test } from "uvu";
import * as assert from "uvu/assert";

let browser;
let context;
let page;

test.before(async () => {
browser = await chromium.launch({
use: { timezoneId: "Etc/UTC" },
});
context = await browser.newContext();
});

test.before.each(async () => {
page = await context.newPage();
});

test.after.each(async () => {
await page.close();
});

test.after(async () => {
await browser.close();
await context.close();
});

test("Solved Issue #1: Company Names are Present", async () => {
await page.goto("http://localhost:8080");
await setTimeout(250);

var text = await page.$eval("body > table > tbody > tr:nth-child(2) > td:nth-child(1)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "Fusion LLC");

var text = await page.$eval("body > table > tbody > tr:nth-child(3) > td:nth-child(1)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "Techopolis Ltd.");

var text = await page.$eval("body > table > tbody > tr:nth-child(4) > td:nth-child(1)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "Code learning LLC");
});

test("Solved Issue #2: display dates in 24-hour time format", async () => {
await page.goto("http://localhost:8080");
await setTimeout(250);

var text = await page.$eval("body > table > tbody > tr:nth-child(2) > td:nth-child(3)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "03:41");

var text = await page.$eval("body > table > tbody > tr:nth-child(3) > td:nth-child(3)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "08:45");

var text = await page.$eval("body > table > tbody > tr:nth-child(4) > td:nth-child(3)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "12:45");
});

test("Solved Issue #3: display revenue numbers in a human readable format", async () => {
await page.goto("http://localhost:8080");
await setTimeout(250);

var text = await page.$eval("body > table > tbody > tr:nth-child(2) > td:nth-child(4)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "17 000 000");

var text = await page.$eval("body > table > tbody > tr:nth-child(3) > td:nth-child(4)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "7 375 294");

var text = await page.$eval("body > table > tbody > tr:nth-child(4) > td:nth-child(4)", (el) => el.textContent);
assert.type(text, "string");
assert.is(text, "100 000");
});

test("Solved Issue #4: make table look prettier", async () => {
await page.goto("http://localhost:8080");
await setTimeout(250);

var headerColor = await page.$eval("tr:first-of-type", (el) =>
getComputedStyle(el).getPropertyValue("background-color")
);
assert.is(headerColor, "rgb(173, 216, 230)");

var tableBorderColor = await page.$eval("body > table", (el) =>
getComputedStyle(el).getPropertyValue("border-color")
);
assert.is(tableBorderColor, "rgb(173, 216, 230)");
});

test.run();
2 changes: 1 addition & 1 deletion .gitignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update to the .gitignore file to ensure all 'node_modules' directories are ignored, not just the top-level one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job updating the .gitignore to ignore node_modules in all subdirectories! This will help keep the repository clean from unnecessary files.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ yarn-error.log*


# Dependency directories
node_modules/
**node_modules**
jspm_packages/

# Optional npm cache directory
Expand Down
Binary file added javascript-crm-main.zip
Binary file not shown.
Loading