From a1499013dc86e29deef1c18a75cf4c343424b3e4 Mon Sep 17 00:00:00 2001 From: Kara Hoagland Date: Sun, 4 Dec 2022 17:53:13 -0800 Subject: [PATCH 1/8] -Req Star Message -Load More Position -Cancel Update Form --- source/ReviewDetails.html | 4 +--- source/assets/scripts/CreatePage.js | 4 +--- source/assets/scripts/ReviewCard.js | 3 --- source/assets/scripts/ReviewDetails.js | 10 ++++++---- source/assets/scripts/{main.js => homepage.js} | 7 ++++--- source/index.html | 5 ++--- source/static/homepage.css | 5 +++++ source/sw.js | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) rename source/assets/scripts/{main.js => homepage.js} (97%) diff --git a/source/ReviewDetails.html b/source/ReviewDetails.html index 521ddb4..c76976d 100644 --- a/source/ReviewDetails.html +++ b/source/ReviewDetails.html @@ -13,8 +13,6 @@ - - @@ -139,7 +137,7 @@ - + diff --git a/source/assets/scripts/CreatePage.js b/source/assets/scripts/CreatePage.js index f539e9d..8978e65 100644 --- a/source/assets/scripts/CreatePage.js +++ b/source/assets/scripts/CreatePage.js @@ -110,8 +110,6 @@ function initFormHandler() { // Adds data to the reviewObject from form data for (let [key, value] of formData) { - console.log(`${key}`); - console.log(`${value}`); if (`${key}` !== "tag-form") { reviewObject[`${key}`] = `${value}`; } @@ -141,7 +139,7 @@ function initFormHandler() { } // Does not let user proceed if rating is not complete else { - window.alert("NO! FILL IN STARS"); + window.alert("Please fill in rating by selecting the stars :)"); } }); diff --git a/source/assets/scripts/ReviewCard.js b/source/assets/scripts/ReviewCard.js index 3600f2d..3a06fe6 100644 --- a/source/assets/scripts/ReviewCard.js +++ b/source/assets/scripts/ReviewCard.js @@ -109,8 +109,6 @@ class ReviewCard extends HTMLElement { // Attach event listener to each review-card this.addEventListener("click", (event) => { - console.log(event.target); - console.log(event.target.reviewId); // Saves the ID for corresponding review on new page (for data retrieval) sessionStorage.setItem("currID", JSON.stringify(event.target.data.reviewID)); // Goes to the new page for the review @@ -251,7 +249,6 @@ class ReviewCard extends HTMLElement { // Get comment section let comments = this.shadowEl.getElementById("a-comments"); - console.log(comments); dataContainer["comments"] = comments.innerText; // Get rating diff --git a/source/assets/scripts/ReviewDetails.js b/source/assets/scripts/ReviewDetails.js index 549ce35..2a2e638 100644 --- a/source/assets/scripts/ReviewDetails.js +++ b/source/assets/scripts/ReviewDetails.js @@ -161,7 +161,6 @@ function setupUpdate() { let select = document.getElementById("select"); const input = document.getElementById("mealImg"); select.addEventListener("change", function () { - console.log("1"); // Select a photo with HTML file selector if (select.value == "file") { // enabling file upload components and hiding photo taking components @@ -192,7 +191,6 @@ function setupUpdate() { //addressing sourcing image from local file document.getElementById("mealImg").addEventListener("change", function () { - console.log("reading used"); const reader = new FileReader(); //store image data URL after successful image load @@ -208,6 +206,12 @@ function setupUpdate() { reader.readAsDataURL(document.getElementById("mealImg").files[0]); }); + //cancel button on update form hids form not making any changes + let cancelBtn = document.getElementById("cancel-btn"); + cancelBtn.addEventListener("click", function(){ + updateDiv.classList.add("hidden"); + }) + //Take formdata values as newData when submit form.addEventListener("submit", function () { /* @@ -218,8 +222,6 @@ function setupUpdate() { let newData = {}; //iterate through formData and add to newData for (let [key, value] of formData) { - console.log(`${key}`); - console.log(`${value}`); if (`${key}` !== "tag-form") { newData[`${key}`] = `${value}`; } diff --git a/source/assets/scripts/main.js b/source/assets/scripts/homepage.js similarity index 97% rename from source/assets/scripts/main.js rename to source/assets/scripts/homepage.js index cd98eb7..e17c060 100644 --- a/source/assets/scripts/main.js +++ b/source/assets/scripts/homepage.js @@ -1,4 +1,4 @@ -// main.js +// homepage.js import { getIDsByTag, getIDsFromStorage, getReviewFromStorage, getTopIDsFromStorage } from "./localStorage.js"; // Run the init() function when the page has loaded @@ -101,6 +101,7 @@ function sortAndFilter(searchTag) { */ function loadReviews(index, reviewIDs) { let reviewBox = document.getElementById("review-container"); + let footer = document.querySelector("footer"); // label if there are no reviews to display if (reviewIDs.length == 0) { let emptyLabel = document.createElement("label"); @@ -116,7 +117,7 @@ function loadReviews(index, reviewIDs) { let moreBtn = document.getElementById("more-btn"); //delete load more button if exists if (moreBtn) { - reviewBox.removeChild(moreBtn); + footer.removeChild(moreBtn); } let reviewArr = []; //check if there are more than 9 reviews left @@ -140,7 +141,7 @@ function loadReviews(index, reviewIDs) { moreBtn.addEventListener("click", function () { loadReviews(index + 9, reviewIDs); }); - reviewBox.append(moreBtn); + footer.append(moreBtn); } } diff --git a/source/index.html b/source/index.html index 4324847..bf63b05 100644 --- a/source/index.html +++ b/source/index.html @@ -13,10 +13,8 @@ - - - + @@ -61,5 +59,6 @@
+ diff --git a/source/static/homepage.css b/source/static/homepage.css index 3487761..308612b 100644 --- a/source/static/homepage.css +++ b/source/static/homepage.css @@ -118,3 +118,8 @@ img#create-btn-invis { background-color: #f1f1f1; text-align: center; } + +footer { + display: flex; + justify-content: center; +} diff --git a/source/sw.js b/source/sw.js index 42e3c39..54ca618 100644 --- a/source/sw.js +++ b/source/sw.js @@ -24,7 +24,7 @@ const ASSETS = [ "assets/images/search_button.png", "assets/scripts/CreatePage.js", "assets/scripts/localStorage.js", - "assets/scripts/main.js", + "assets/scripts/homepage.js", "assets/scripts/ReviewCard.js", "assets/scripts/ReviewDetails.js", ]; From aad4f70304fa8f34ade17dfb2b2bd0cbb2dec959 Mon Sep 17 00:00:00 2001 From: Gavyn Ezell <72951570+gavyn-ezell@users.noreply.github.com> Date: Sun, 4 Dec 2022 18:32:15 -0800 Subject: [PATCH 2/8] min icomment run thru --- source/assets/scripts/ReviewDetails.js | 2 +- source/assets/scripts/homepage.js | 3 +-- source/assets/scripts/main.e2e.test.js | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/source/assets/scripts/ReviewDetails.js b/source/assets/scripts/ReviewDetails.js index 2a2e638..2f02693 100644 --- a/source/assets/scripts/ReviewDetails.js +++ b/source/assets/scripts/ReviewDetails.js @@ -212,7 +212,7 @@ function setupUpdate() { updateDiv.classList.add("hidden"); }) - //Take formdata values as newData when submit + //Take form data values as newData when submit form.addEventListener("submit", function () { /* * User submits the form for their review. diff --git a/source/assets/scripts/homepage.js b/source/assets/scripts/homepage.js index e17c060..60f8f4e 100644 --- a/source/assets/scripts/homepage.js +++ b/source/assets/scripts/homepage.js @@ -32,8 +32,6 @@ function initFormHandler() { let searchBtn = document.getElementById("search-btn"); let searchTag = null; //adding search functionality - //TODO: Add ability to enter without refresh of search bar - //filter by selected tag when button clicked searchBtn.addEventListener("click", function () { searchTag = searchField.value; sortAndFilter(searchTag); @@ -145,6 +143,7 @@ function loadReviews(index, reviewIDs) { } } +//setting up service worker const registerServiceWorker = async () => { if ("serviceWorker" in navigator) { try { diff --git a/source/assets/scripts/main.e2e.test.js b/source/assets/scripts/main.e2e.test.js index 9123651..6b2b02a 100644 --- a/source/assets/scripts/main.e2e.test.js +++ b/source/assets/scripts/main.e2e.test.js @@ -15,7 +15,6 @@ describe("test App end to end", async () => { root = false; } - //browser = await puppeteer.launch({headless: false, slowMo: 250, args: root ? ['--no-sandbox'] : undefined}); browser = await puppeteer.launch({ args: root ? ["--no-sandbox"] : undefined }); page = await browser.newPage(); try { From 6d8dc935436f695d6f5cff5991b4fb3c526be357 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 4 Dec 2022 19:31:27 -0800 Subject: [PATCH 3/8] try nyc --- .github/workflows/js-unittest.yml | 4 ++-- .gitignore | 3 ++- package.json | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/js-unittest.yml b/.github/workflows/js-unittest.yml index daaab10..fc39c95 100644 --- a/.github/workflows/js-unittest.yml +++ b/.github/workflows/js-unittest.yml @@ -25,5 +25,5 @@ jobs: run: sudo npm install - name: Start local http server run: sudo npm run http-server & - - name: Run tests - run: sudo npm test + - name: Run tests with coverage + run: sudo npm run coverage diff --git a/.gitignore b/.gitignore index ea296b8..fc83b8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/.devcontainer/* **/node_modules/* **/package-lock.json -**/*.vscode/* \ No newline at end of file +**/.vscode/* +**/.nyc_output/* \ No newline at end of file diff --git a/package.json b/package.json index 719337f..1d9daa4 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "type": "module", "scripts": { "test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'", + "coverage": "nyc --all npm run test", "lint-js": "eslint **/*.js", "fix-js": "eslint --fix **/*.js", "lint-html": "htmlhint **/*.html", @@ -20,6 +21,7 @@ "http-server": "", "mocha": "10", "mock-local-storage": "^1.1.23", + "nyc": "^14.0.0", "prettier": "2.8.0", "puppeteer": "^18.2.1", "stylelint": "14.14.1", From 35c8619f874ce3bc66055032a04a2e9592ecdc92 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 4 Dec 2022 19:38:52 -0800 Subject: [PATCH 4/8] switch to c8 --- .gitignore | 3 ++- package.json | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fc83b8e..7dd6a0b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ **/node_modules/* **/package-lock.json **/.vscode/* -**/.nyc_output/* \ No newline at end of file +**/.nyc_output/* +**/coverage/* \ No newline at end of file diff --git a/package.json b/package.json index 1d9daa4..a514b38 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'", - "coverage": "nyc --all npm run test", + "coverage": "c8 npm run test", "lint-js": "eslint **/*.js", "fix-js": "eslint --fix **/*.js", "lint-html": "htmlhint **/*.html", @@ -16,12 +16,12 @@ "js-doc": "jsdoc -d source/docs/ -r source/" }, "devDependencies": { + "c8": "^7.12.0", "eslint": "^8.27.0", "htmlhint": "1.1.4", "http-server": "", "mocha": "10", "mock-local-storage": "^1.1.23", - "nyc": "^14.0.0", "prettier": "2.8.0", "puppeteer": "^18.2.1", "stylelint": "14.14.1", From 08bd1dc3ba3690c461ed1e9c03db320d6f95d5e7 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 4 Dec 2022 19:44:30 -0800 Subject: [PATCH 5/8] add coverage check, try permision fix --- .github/workflows/js-unittest.yml | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/js-unittest.yml b/.github/workflows/js-unittest.yml index fc39c95..3234bc9 100644 --- a/.github/workflows/js-unittest.yml +++ b/.github/workflows/js-unittest.yml @@ -23,6 +23,8 @@ jobs: uses: actions/checkout@v3 - name: Install dependencies run: sudo npm install + - name: Give permissions to npm folder + run: sudo chown -R 1001:123 "/root/.npm" - name: Start local http server run: sudo npm run http-server & - name: Run tests with coverage diff --git a/package.json b/package.json index a514b38..44dc522 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'", - "coverage": "c8 npm run test", + "coverage": "c8 --check-coverage --lines 90 --functions 90 --branches 90 npm run test", "lint-js": "eslint **/*.js", "fix-js": "eslint --fix **/*.js", "lint-html": "htmlhint **/*.html", From cb5882a04f98ccb94dde5ca0c16ea9ff2d62818b Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 4 Dec 2022 19:49:21 -0800 Subject: [PATCH 6/8] try loglevel verbose --- .github/workflows/js-unittest.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/js-unittest.yml b/.github/workflows/js-unittest.yml index 3234bc9..e51538d 100644 --- a/.github/workflows/js-unittest.yml +++ b/.github/workflows/js-unittest.yml @@ -23,9 +23,7 @@ jobs: uses: actions/checkout@v3 - name: Install dependencies run: sudo npm install - - name: Give permissions to npm folder - run: sudo chown -R 1001:123 "/root/.npm" - name: Start local http server run: sudo npm run http-server & - name: Run tests with coverage - run: sudo npm run coverage + run: sudo npm run coverage --loglevel=verbose From 0d27862c89a158732ace9cd468f71412578cd43f Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 4 Dec 2022 19:52:41 -0800 Subject: [PATCH 7/8] try no sudo --- .github/workflows/js-unittest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/js-unittest.yml b/.github/workflows/js-unittest.yml index e51538d..0d746b9 100644 --- a/.github/workflows/js-unittest.yml +++ b/.github/workflows/js-unittest.yml @@ -22,8 +22,8 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install dependencies - run: sudo npm install + run: npm install - name: Start local http server - run: sudo npm run http-server & + run: npm run http-server & - name: Run tests with coverage - run: sudo npm run coverage --loglevel=verbose + run: npm run coverage From f48cc18b38f0b0f40b1359fb3d581306f27d83ee Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Mon, 5 Dec 2022 22:20:17 +0000 Subject: [PATCH 8/8] fix prettier linting Signed-off-by: Arthur Lu --- source/ReviewDetails.html | 2 +- source/assets/scripts/ReviewDetails.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/ReviewDetails.html b/source/ReviewDetails.html index c76976d..fb2a09a 100644 --- a/source/ReviewDetails.html +++ b/source/ReviewDetails.html @@ -137,7 +137,7 @@ - + diff --git a/source/assets/scripts/ReviewDetails.js b/source/assets/scripts/ReviewDetails.js index 2f02693..17c4b52 100644 --- a/source/assets/scripts/ReviewDetails.js +++ b/source/assets/scripts/ReviewDetails.js @@ -208,9 +208,9 @@ function setupUpdate() { //cancel button on update form hids form not making any changes let cancelBtn = document.getElementById("cancel-btn"); - cancelBtn.addEventListener("click", function(){ + cancelBtn.addEventListener("click", function () { updateDiv.classList.add("hidden"); - }) + }); //Take form data values as newData when submit form.addEventListener("submit", function () {