mirror of
				https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
				synced 2025-10-30 19:46:49 +00:00 
			
		
		
		
	Merge pull request #110 from cse110-fa22-group29/mini-changes
End Sprint Modifications
This commit is contained in:
		
							
								
								
									
										8
									
								
								.github/workflows/js-unittest.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/js-unittest.yml
									
									
									
									
										vendored
									
									
								
							| @@ -22,8 +22,8 @@ jobs: | |||||||
|             - name: Checkout |             - name: Checkout | ||||||
|               uses: actions/checkout@v3 |               uses: actions/checkout@v3 | ||||||
|             - name: Install dependencies |             - name: Install dependencies | ||||||
|               run: sudo npm install |               run: npm install | ||||||
|             - name: Start local http server |             - name: Start local http server | ||||||
|               run: sudo npm run http-server & |               run: npm run http-server & | ||||||
|             - name: Run tests |             - name: Run tests with coverage | ||||||
|               run: sudo npm test |               run: npm run coverage | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,6 @@ | |||||||
| **/.devcontainer/* | **/.devcontainer/* | ||||||
| **/node_modules/* | **/node_modules/* | ||||||
| **/package-lock.json | **/package-lock.json | ||||||
| **/*.vscode/* | **/.vscode/* | ||||||
|  | **/.nyc_output/* | ||||||
|  | **/coverage/* | ||||||
| @@ -4,6 +4,7 @@ | |||||||
| 	"type": "module", | 	"type": "module", | ||||||
| 	"scripts": { | 	"scripts": { | ||||||
| 		"test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'", | 		"test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'", | ||||||
|  | 		"coverage": "c8 --check-coverage --lines 90 --functions 90 --branches 90 npm run test", | ||||||
| 		"lint-js": "eslint **/*.js", | 		"lint-js": "eslint **/*.js", | ||||||
| 		"fix-js": "eslint --fix **/*.js", | 		"fix-js": "eslint --fix **/*.js", | ||||||
| 		"lint-html": "htmlhint **/*.html", | 		"lint-html": "htmlhint **/*.html", | ||||||
| @@ -15,6 +16,7 @@ | |||||||
| 		"js-doc": "jsdoc -d source/docs/ -r source/" | 		"js-doc": "jsdoc -d source/docs/ -r source/" | ||||||
| 	}, | 	}, | ||||||
| 	"devDependencies": { | 	"devDependencies": { | ||||||
|  | 		"c8": "^7.12.0", | ||||||
| 		"eslint": "^8.27.0", | 		"eslint": "^8.27.0", | ||||||
| 		"htmlhint": "1.1.4", | 		"htmlhint": "1.1.4", | ||||||
| 		"http-server": "", | 		"http-server": "", | ||||||
|   | |||||||
| @@ -13,8 +13,6 @@ | |||||||
| 		<script src="assets/scripts/ReviewCard.js" type="module"></script> | 		<script src="assets/scripts/ReviewCard.js" type="module"></script> | ||||||
|  |  | ||||||
| 		<!-- Main Stylesheets & Scripts --> | 		<!-- Main Stylesheets & Scripts --> | ||||||
| 		<!-- Temporarily commented out reset.css due to furthur discussion needed on the values of the default config--> |  | ||||||
| 		<!-- <link rel="stylesheet" href="/static/reset.css" /> --> |  | ||||||
| 		<link rel="stylesheet" href="./static/ReviewDetails.css" /> | 		<link rel="stylesheet" href="./static/ReviewDetails.css" /> | ||||||
| 		<link rel="stylesheet" href="./static/Form.css" /> | 		<link rel="stylesheet" href="./static/Form.css" /> | ||||||
| 		<script src="assets/scripts/ReviewDetails.js" type="module"></script> | 		<script src="assets/scripts/ReviewDetails.js" type="module"></script> | ||||||
| @@ -139,7 +137,7 @@ | |||||||
| 				</fieldset> | 				</fieldset> | ||||||
|  |  | ||||||
| 				<button type="submit" id="save-btn" value="Submit">Save</button> | 				<button type="submit" id="save-btn" value="Submit">Save</button> | ||||||
| 				<input type="button" value="Cancel" id="home-btn" onclick="window.location.assign('./index.html')" /> | 				<input type="button" value="Cancel" id="cancel-btn" /> | ||||||
| 			</form> | 			</form> | ||||||
| 		</div> | 		</div> | ||||||
| 	</body> | 	</body> | ||||||
|   | |||||||
| @@ -110,8 +110,6 @@ function initFormHandler() { | |||||||
|  |  | ||||||
| 		// Adds data to the reviewObject from form data | 		// Adds data to the reviewObject from form data | ||||||
| 		for (let [key, value] of formData) { | 		for (let [key, value] of formData) { | ||||||
| 			console.log(`${key}`); |  | ||||||
| 			console.log(`${value}`); |  | ||||||
| 			if (`${key}` !== "tag-form") { | 			if (`${key}` !== "tag-form") { | ||||||
| 				reviewObject[`${key}`] = `${value}`; | 				reviewObject[`${key}`] = `${value}`; | ||||||
| 			} | 			} | ||||||
| @@ -141,7 +139,7 @@ function initFormHandler() { | |||||||
| 		} | 		} | ||||||
| 		// Does not let user proceed if rating is not complete | 		// Does not let user proceed if rating is not complete | ||||||
| 		else { | 		else { | ||||||
| 			window.alert("NO! FILL IN STARS"); | 			window.alert("Please fill in rating by selecting the stars :)"); | ||||||
| 		} | 		} | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -109,8 +109,6 @@ class ReviewCard extends HTMLElement { | |||||||
|  |  | ||||||
| 		// Attach event listener to each review-card | 		// Attach event listener to each review-card | ||||||
| 		this.addEventListener("click", (event) => { | 		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) | 			// Saves the ID for corresponding review on new page (for data retrieval) | ||||||
| 			sessionStorage.setItem("currID", JSON.stringify(event.target.data.reviewID)); | 			sessionStorage.setItem("currID", JSON.stringify(event.target.data.reviewID)); | ||||||
| 			// Goes to the new page for the review | 			// Goes to the new page for the review | ||||||
| @@ -251,7 +249,6 @@ class ReviewCard extends HTMLElement { | |||||||
|  |  | ||||||
| 		// Get comment section | 		// Get comment section | ||||||
| 		let comments = this.shadowEl.getElementById("a-comments"); | 		let comments = this.shadowEl.getElementById("a-comments"); | ||||||
| 		console.log(comments); |  | ||||||
| 		dataContainer["comments"] = comments.innerText; | 		dataContainer["comments"] = comments.innerText; | ||||||
|  |  | ||||||
| 		// Get rating | 		// Get rating | ||||||
|   | |||||||
| @@ -161,7 +161,6 @@ function setupUpdate() { | |||||||
| 		let select = document.getElementById("select"); | 		let select = document.getElementById("select"); | ||||||
| 		const input = document.getElementById("mealImg"); | 		const input = document.getElementById("mealImg"); | ||||||
| 		select.addEventListener("change", function () { | 		select.addEventListener("change", function () { | ||||||
| 			console.log("1"); |  | ||||||
| 			// Select a photo with HTML file selector | 			// Select a photo with HTML file selector | ||||||
| 			if (select.value == "file") { | 			if (select.value == "file") { | ||||||
| 				// enabling file upload components and hiding photo taking components | 				// enabling file upload components and hiding photo taking components | ||||||
| @@ -192,7 +191,6 @@ function setupUpdate() { | |||||||
|  |  | ||||||
| 		//addressing sourcing image from local file | 		//addressing sourcing image from local file | ||||||
| 		document.getElementById("mealImg").addEventListener("change", function () { | 		document.getElementById("mealImg").addEventListener("change", function () { | ||||||
| 			console.log("reading used"); |  | ||||||
| 			const reader = new FileReader(); | 			const reader = new FileReader(); | ||||||
|  |  | ||||||
| 			//store image data URL after successful image load | 			//store image data URL after successful image load | ||||||
| @@ -208,7 +206,13 @@ function setupUpdate() { | |||||||
| 			reader.readAsDataURL(document.getElementById("mealImg").files[0]); | 			reader.readAsDataURL(document.getElementById("mealImg").files[0]); | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
| 		//Take formdata values as newData when submit | 		//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 form data values as newData when submit | ||||||
| 		form.addEventListener("submit", function () { | 		form.addEventListener("submit", function () { | ||||||
| 			/* | 			/* | ||||||
| 			 *  User submits the form for their review. | 			 *  User submits the form for their review. | ||||||
| @@ -218,8 +222,6 @@ function setupUpdate() { | |||||||
| 			let newData = {}; | 			let newData = {}; | ||||||
| 			//iterate through formData and add to newData | 			//iterate through formData and add to newData | ||||||
| 			for (let [key, value] of formData) { | 			for (let [key, value] of formData) { | ||||||
| 				console.log(`${key}`); |  | ||||||
| 				console.log(`${value}`); |  | ||||||
| 				if (`${key}` !== "tag-form") { | 				if (`${key}` !== "tag-form") { | ||||||
| 					newData[`${key}`] = `${value}`; | 					newData[`${key}`] = `${value}`; | ||||||
| 				} | 				} | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| // main.js
 | // homepage.js
 | ||||||
| import { getIDsByTag, getIDsFromStorage, getReviewFromStorage, getTopIDsFromStorage } from "./localStorage.js"; | import { getIDsByTag, getIDsFromStorage, getReviewFromStorage, getTopIDsFromStorage } from "./localStorage.js"; | ||||||
| 
 | 
 | ||||||
| // Run the init() function when the page has loaded
 | // Run the init() function when the page has loaded
 | ||||||
| @@ -32,8 +32,6 @@ function initFormHandler() { | |||||||
| 	let searchBtn = document.getElementById("search-btn"); | 	let searchBtn = document.getElementById("search-btn"); | ||||||
| 	let searchTag = null; | 	let searchTag = null; | ||||||
| 	//adding search functionality
 | 	//adding search functionality
 | ||||||
| 	//TODO: Add ability to enter without refresh of search bar
 |  | ||||||
| 	//filter by selected tag when button clicked
 |  | ||||||
| 	searchBtn.addEventListener("click", function () { | 	searchBtn.addEventListener("click", function () { | ||||||
| 		searchTag = searchField.value; | 		searchTag = searchField.value; | ||||||
| 		sortAndFilter(searchTag); | 		sortAndFilter(searchTag); | ||||||
| @@ -101,6 +99,7 @@ function sortAndFilter(searchTag) { | |||||||
|  */ |  */ | ||||||
| function loadReviews(index, reviewIDs) { | function loadReviews(index, reviewIDs) { | ||||||
| 	let reviewBox = document.getElementById("review-container"); | 	let reviewBox = document.getElementById("review-container"); | ||||||
|  | 	let footer = document.querySelector("footer"); | ||||||
| 	// label if there are no reviews to display
 | 	// label if there are no reviews to display
 | ||||||
| 	if (reviewIDs.length == 0) { | 	if (reviewIDs.length == 0) { | ||||||
| 		let emptyLabel = document.createElement("label"); | 		let emptyLabel = document.createElement("label"); | ||||||
| @@ -116,7 +115,7 @@ function loadReviews(index, reviewIDs) { | |||||||
| 	let moreBtn = document.getElementById("more-btn"); | 	let moreBtn = document.getElementById("more-btn"); | ||||||
| 	//delete load more button if exists
 | 	//delete load more button if exists
 | ||||||
| 	if (moreBtn) { | 	if (moreBtn) { | ||||||
| 		reviewBox.removeChild(moreBtn); | 		footer.removeChild(moreBtn); | ||||||
| 	} | 	} | ||||||
| 	let reviewArr = []; | 	let reviewArr = []; | ||||||
| 	//check if there are more than 9 reviews left
 | 	//check if there are more than 9 reviews left
 | ||||||
| @@ -140,10 +139,11 @@ function loadReviews(index, reviewIDs) { | |||||||
| 		moreBtn.addEventListener("click", function () { | 		moreBtn.addEventListener("click", function () { | ||||||
| 			loadReviews(index + 9, reviewIDs); | 			loadReviews(index + 9, reviewIDs); | ||||||
| 		}); | 		}); | ||||||
| 		reviewBox.append(moreBtn); | 		footer.append(moreBtn); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //setting up service worker
 | ||||||
| const registerServiceWorker = async () => { | const registerServiceWorker = async () => { | ||||||
| 	if ("serviceWorker" in navigator) { | 	if ("serviceWorker" in navigator) { | ||||||
| 		try { | 		try { | ||||||
| @@ -15,7 +15,6 @@ describe("test App end to end", async () => { | |||||||
| 			root = false; | 			root = false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		//browser = await puppeteer.launch({headless: false, slowMo: 250, args: root ? ['--no-sandbox'] : undefined}); |  | ||||||
| 		browser = await puppeteer.launch({ args: root ? ["--no-sandbox"] : undefined }); | 		browser = await puppeteer.launch({ args: root ? ["--no-sandbox"] : undefined }); | ||||||
| 		page = await browser.newPage(); | 		page = await browser.newPage(); | ||||||
| 		try { | 		try { | ||||||
|   | |||||||
| @@ -13,10 +13,8 @@ | |||||||
| 		<script src="assets/scripts/ReviewCard.js" type="module"></script> | 		<script src="assets/scripts/ReviewCard.js" type="module"></script> | ||||||
|  |  | ||||||
| 		<!-- Main Stylesheets & Scripts --> | 		<!-- Main Stylesheets & Scripts --> | ||||||
| 		<!-- Temporarily commented out reset.css due to furthur discussion needed on the values of the default config--> |  | ||||||
| 		<!-- <link rel="stylesheet" href="/static/reset.css" /> --> |  | ||||||
| 		<link rel="stylesheet" href="./static/homepage.css" /> | 		<link rel="stylesheet" href="./static/homepage.css" /> | ||||||
| 		<script src="assets/scripts/main.js" type="module"></script> | 		<script src="assets/scripts/homepage.js" type="module"></script> | ||||||
| 	</head> | 	</head> | ||||||
|  |  | ||||||
| 	<body> | 	<body> | ||||||
| @@ -61,5 +59,6 @@ | |||||||
| 				<div style="width: 20%"></div> | 				<div style="width: 20%"></div> | ||||||
| 			</div> | 			</div> | ||||||
| 		</main> | 		</main> | ||||||
|  | 		<footer></footer> | ||||||
| 	</body> | 	</body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -118,3 +118,8 @@ img#create-btn-invis { | |||||||
| 	background-color: #f1f1f1; | 	background-color: #f1f1f1; | ||||||
| 	text-align: center; | 	text-align: center; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | footer { | ||||||
|  | 	display: flex; | ||||||
|  | 	justify-content: center; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ const ASSETS = [ | |||||||
| 	"assets/images/search_button.png", | 	"assets/images/search_button.png", | ||||||
| 	"assets/scripts/CreatePage.js", | 	"assets/scripts/CreatePage.js", | ||||||
| 	"assets/scripts/localStorage.js", | 	"assets/scripts/localStorage.js", | ||||||
| 	"assets/scripts/main.js", | 	"assets/scripts/homepage.js", | ||||||
| 	"assets/scripts/ReviewCard.js", | 	"assets/scripts/ReviewCard.js", | ||||||
| 	"assets/scripts/ReviewDetails.js", | 	"assets/scripts/ReviewDetails.js", | ||||||
| ]; | ]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user