Skip to content

Commit

Permalink
Release 1.1.3 (#340)
Browse files Browse the repository at this point in the history
* Added testing to pull request template

* Feature/issue 314 (#319)

* Install Cypress & needed packages

Update eslint config
Update gitignore
Add testing development mongo path

* Add nock Passport.js Discord request interception

* Add Cypress tests

* Disable server logging when testing

* Fix delay-toggling environment variable

Cypress wasn't properly listening to the CYPRESS_NO_DELAYS environment variable to disable the animations waits

* added modulus to getHoursAndMinutes

---------

Co-authored-by: Caleb Cohen <CalebCohen@hotmail.com>

* starting workflow for actions

* typo within review pull request

* add environment dev to workflow

* workflow changes

* lint fixes (#324)

* Actions timeout (#326)

* Add timeout to GitHub actions

GitHub action workflows should be limited so minutes aren't wasted if it hangs and bugs can be caught earlier. If 30 minutes isn't enough, it can be increased later on

* change timeout to 10 minutes

* Modified app metadata to "Together is a scheduling and collaboration … (#325)

* Modified app metadata to "Together is a scheduling and collaboration tool built for and  by 100Devs community for creating, discovering and keeping track of events on discord."

* Deleted the extra space.

* Server tests. #288 (#289)

* install jest and supertest

* separate app and server into different files

* add jest coverage folder to gitignore

* allow the use of mock user in test environment

* change validateBody to be a sync function

* add 'use strict', fix variable declarations

* extract constants

* remove console logs

* add mock user to db

* refactor, fix validation bugs in createEventSchema

* test httpError

* test validateObjectId

* test validateBody

* refactor unit tests

* export STRING_MAX_LENGTH to be used in tests

* fix dotenv path to work in tests

* modify mock request

* test routes

* refactor maxEvents middleware

* add tests for maxEvents

* allow event end time (not date) to be before start time

* test create event with valid data

* timezone bug fix: add offset to days

* test createEventArray

* create date range with Date  instead of datefns lib

* test createEventsArray in JST timezone

* refactor createEventsArray and tests

* fix test JST time

* use Temporal to work with dates

* fix event duration using Temporal

* test cases for createEventsArray

* test validateBody

* fix acceptance tests

* change hardcoded timezone to machine timezone

* update test script

* remove irrelevant test (maxEvents)

* update front-end test

* add script to run all tests together

* add route tests

* added formidable, jsbi, moved jest and supertest to dev dependencies

---------

Co-authored-by: Caleb Cohen <CalebCohen@hotmail.com>

* Fix guest modal and and updated test (#327)

* Fix guest modal and and updated test

* author changes and lint fix

* Make time-asserting code locale-based

---------

Co-authored-by: Rascal_Two <therealrascaltwo@gmail.com>

* Removed delete all button from non-recurring events (#332)

* Removed delete all button from non-recurring events

* Removed console.log from file

* Feature/issue 305 (#339)

* changed description section input element to textarea element. This change added multi-line functionality and a larger textbox size.

* In the input object, I changed the input element text to textarea. Cypress now reflects the changes made in the codebase for proper testing.

* Created a close button, in UserForm.js (#333)

---------

Co-authored-by: Rascal Two <therealrascaltwo@gmail.com>
Co-authored-by: Jacob Asper <jacobasper191@gmail.com>
Co-authored-by: uaravindshenoy <75222342+uaravindshenoy@users.noreply.github.com>
Co-authored-by: Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
Co-authored-by: Lalysi <75863568+lalysi@users.noreply.github.com>
Co-authored-by: Mike Jakuszewski <114702999+MikeJakuszewski@users.noreply.github.com>
Co-authored-by: Jae Salaski <hello@jsalaski.com>
  • Loading branch information
8 people authored Feb 18, 2023
1 parent f08f5be commit f22f80d
Show file tree
Hide file tree
Showing 52 changed files with 8,211 additions and 4,434 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
es2021: true,
node: true,
browser: true,
"cypress/globals": true
},
extends: ["eslint:recommended", "plugin:react/recommended", "prettier"],
parserOptions: {
Expand All @@ -16,7 +17,7 @@ module.exports = {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["react", "react-hooks", "prettier"],
plugins: ["react", "react-hooks", "prettier", "cypress"],
rules: {
indent: [
"error",
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/review-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Review Pull Request

on:

push:
branches:
- main
- development
pull_request:
branches:
- main
- development

permissions:
checks: write
contents: write

jobs:
review-pull-request:
name: Run tests to review pull requests
timeout-minutes: 10
runs-on: ubuntu-latest
environment: DEV
env:
DB_STRING: ${{ vars.DB_STRING }}
DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }}
DISCORD_CLIENT_SECRET: ${{ secrets.DISCORD_CLIENT_SECRET }}
OAUTH_REDIRECT_URL: ${{ vars.OAUTH_REDIRECT_URL }}
MOCK_USER: ${{ vars.MOCK_USER }}
NODE_ENV: ${{ vars.NODE_ENV }}

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 16.15.0

- name: Install Node.js dependencies
run: npm ci

- name: Run linters
uses: wearerequired/lint-action@v2
with:
eslint: true

- name: Run Front end test
run: npm run test-frontend

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ node_modules
.vscode
build
.DS_Store
.mongo
.mongo*
formLogic.txt
coverage
.nyc_output
cypress/screenshots
cypress/videos
4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"proxy": "http://localhost:2121",
"scripts": {
"start": "react-scripts start",
"start:coverage": "react-scripts -r @cypress/instrument-cra start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
Expand Down Expand Up @@ -31,5 +32,6 @@
"tailwindcss": "^3.2.2",
"axios": "^1.1.3",
"nanoid": "^4.0.0"
}
},
"cypressWebpackConfigPath": "../node_modules/react-scripts/config/webpack.config.js"
}
2 changes: 1 addition & 1 deletion client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="Together is a scheduling and collaboration tool built for and by the 100Devs community for creating, discovering and keeping track of events on discord."
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
Expand Down
2 changes: 1 addition & 1 deletion client/src/contexts/AuthContext/useProvideAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const useProvideAuth = () => {
setCurrentPage("calendarPage")
}
});
}, []);
}, [setCurrentPage]);

const logout = () => {
DataService.logout();
Expand Down
26 changes: 3 additions & 23 deletions client/src/contexts/FormContext/useProvideForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState } from "react";
import DataService from "services/dataService";
import { dateToTimestamp } from "utilities/calendar";
import { useEventsContext } from "contexts/EventsContext";

const useProvideForm = () => {
Expand All @@ -25,29 +24,10 @@ const useProvideForm = () => {

// Submit form to server
if (newStep === 4) {
const { initialDate, startTime, finalDate, endTime, ...rest } = formData;
// start and end timestamps of the earliest possible event
const firstEventStart = dateToTimestamp(initialDate, startTime);
const firstEventEnd = dateToTimestamp(initialDate, endTime);
// start timestamp of the last possible event
const lastEventStart = dateToTimestamp(finalDate, startTime);

const recurrOffset =
new Date(firstEventStart).getUTCDay() -
new Date(firstEventStart).getDay();
// console.log(`recurrOffset: ${recurrOffset}`);

const { days } = formData.recurring;
const daysWithOffset = days.map(e =>
String((Number(e) + recurrOffset + 7) % 7)
);

// console.log(formData.recurring.days);
formData.recurring.days = daysWithOffset;
// console.log(formData.recurring.days);

// User timezone
const { timeZone } = Intl.DateTimeFormat().resolvedOptions();
// Event data to be sent to the backend
const event = { ...rest, firstEventStart, firstEventEnd, lastEventStart };
const event = { ...formData, timeZone };

let response;
try {
Expand Down
3 changes: 1 addition & 2 deletions client/src/contexts/RoutingContext/useProvideRouting.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState, useEffect } from "react";
import {useAuthContext} from '../AuthContext/'
import { useState } from "react";


const useProvideRouting = () => {
Expand Down
4 changes: 2 additions & 2 deletions client/src/features/form/FormConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ export default function FormConfirm() {
<div className="flex space-x-4 items-center">
<input
type="checkbox"
value="0"
value="7"
name="Sunday"
readOnly
checked={!!formData.recurring.days.includes("0")}
checked={!!formData.recurring.days.includes("7")}
className="mx-1 outline-non text-gray-800"
/>
<p>Sunday</p>
Expand Down
5 changes: 3 additions & 2 deletions client/src/features/form/FormCreateEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ export default function FormCreateEvent() {
Description
</div>
<div className="bg-white my-2 p-1 flex border border-gray-200 rounded">
<input
<textarea
type="text"
onChange={handleChange}
value={formData["description"] || ""}
name="description"
placeholder="Description"
className="p-1 px-2 appearance-none outline-non w-full text-gray-800"
/>
rows="8" >
</textarea>
</div>
</div>

Expand Down
8 changes: 4 additions & 4 deletions client/src/features/form/FormMoverControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ const FormMoverControl = () => {
errorArray.push("Error: Weekly recurring event MUST include at least one day of the week");
}

// Compares the date + time combined (i.e. start and end datetime)
const startDateTime = new Date(formData["initialDate"] + " " + formData["startTime"]);
const endDateTime = new Date(formData["finalDate"] + " " + formData["endTime"]);
if (endDateTime < startDateTime) {
// initialDate should be the same as or before the finalDate
const initialDate = new Date(formData.initialDate);
const finalDate = new Date(formData.finalDate);
if (finalDate < initialDate) {
errorArray.push("Error: End time is before Start time");
}

Expand Down
4 changes: 2 additions & 2 deletions client/src/features/form/FormRecurringDates.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ export default function FormRecurringDates() {
<input
type="checkbox"
onChange={handleDaysOfWeekChange}
value="0"
value="7"
name="Sunday"
checked={!!formData.recurring.days.includes("0")}
checked={!!formData.recurring.days.includes("7")}
className="mx-1 outline-non text-gray-800"
/>
<p>Sunday</p>
Expand Down
12 changes: 12 additions & 0 deletions client/src/features/form/UserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import FormCreateEvent from "./FormCreateEvent";
import FormScheduleEvent from "./FormScheduleEvent";
import FormConfirm from "./FormConfirm";
import FormSuccess from "./FormSuccess";
import { useFormModalContext } from "contexts/FormModalContext";

// This is the code for the form where you add events to the calendar
const UserForm = () => {

// Specifically extract the currentStep and totalSteps from userFormContext
const { currentStep, totalSteps } = useFormContext();

const modal = useFormModalContext();


// Called to display different parts of the form based on the latest step.
const displayStep = step => {
switch (step) {
Expand All @@ -34,6 +38,14 @@ const UserForm = () => {
return (
<div className="md:w mx-auto shadow-xl rounded-2xl pb-2 bg-white">
<div className="container horizontal mt-5">
<div className="flex flex-col items-center">
<button
className="w-auto h-12 mt-5 px-2 border-solid border-2 border-gray outline-none rounded font-semibold text-xl hover:bg-teal-600 active:bg-teal-700 focus:outline-none focus:ring focus:ring-teal-300"
onClick={modal.handleClose}
>
Close
</button>
</div>
<FormMover />

<div className="my-1 p-5">
Expand Down
7 changes: 2 additions & 5 deletions client/src/features/home/CalendarPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useAuthContext } from "contexts/AuthContext";
import { useFormModalContext } from "contexts/FormModalContext";
import EventModal from "features/modal/EventModal";
import { useModalContext } from "contexts/ModalContext";
import RejectionModal from "features/modal/RejectionModal";

function CalendarPage() {
const auth = useAuthContext();
Expand All @@ -29,18 +30,14 @@ function CalendarPage() {
<CalendarHeader date={date} />
<Calendar date={date} />
</main>
{auth?.user && (
<div className="md:w-1/2 mx-auto shadow-xl rounded-2xl pb-2 bg-white">
<Modal context={modal}>
<EventModal />
</Modal>
{auth?.user &&
<Modal context={formModal}>
<UserForm />
{auth?.user ? ( <UserForm /> ) : ( <RejectionModal handleClose={formModal.handleClose}/> )}
</Modal>
}
</div>
)}
</FormProvider>
);
}
Expand Down
2 changes: 0 additions & 2 deletions client/src/features/home/LogoContainer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { useRoutingContext } from "contexts/RoutingContext";

const LogoContainer = ({ logo, logotext }) => {
const routing = useRoutingContext();
return (
<div
className="self-center p-3 hidden tablet:inline-flex desktop:inline-flex overflow-hidden rounded-3xl border-2 border-black laptop:w-5/12 tablet:h-28 desktop:w-auto desktop:h-auto bg-white tablet:px-auto tablet:py-3 desktop:px-10 desktop:py-5"
Expand Down
19 changes: 12 additions & 7 deletions client/src/features/modal/EventModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import { useAuthContext } from "contexts/AuthContext";

const EventModal = () => {
const modal = useModalContext();

//grabs user compares user from context and event author
//displays delete buttons if true
const { user } = useAuthContext();
const userId = user?._id;
const authorCheck = userId === modal.activeEvent.user._id;


return (
<div className="flex flex-col items-center py-0 px-2rem rounded-xl bg-white pb-4">
<button
Expand All @@ -39,7 +39,7 @@ const EventModal = () => {
Delete Specific Event
</button>
)}
{authorCheck && (
{authorCheck && modal.activeEvent.groupId && (
<button
className="w-auto h-10 mt-5 px-2 border-solid border-2 border-gray outline-none rounded font-semibold text-xl hover:bg-teal-600 active:bg-teal-700 focus:outline-none focus:ring focus:ring-teal-300 inline-block"
onClick={() =>
Expand Down Expand Up @@ -99,12 +99,17 @@ const EventModal = () => {
<IoLocationOutline className="mt-1" />{" "}
<span>Location: {modal.activeEvent.location}</span>
</section>
<section className="flex m-3 gap-1 font-semibold">
<IoPersonOutline className="mt-1" />{" "}
<span>
Event Author: {modal.activeEvent.user?.displayName || "Deleted"}
</span>
{user
? <>
<section className="flex m-3 gap-1 font-semibold">
<IoPersonOutline className="mt-1" />{" "}
<span>
Event Author: {modal.activeEvent.user?.displayName || "Deleted"}
</span>
</section>
</>
: <span className="flex m-3 gap-1 font-semibold"> Event Author: Must be logged in to view author </span>
}
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion client/src/services/dataService.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ class DataService {
}
}

export default new DataService();
const dataService = new DataService();
export default dataService
55 changes: 55 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
env: {
CYPRESS_NO_DELAYS: process.env.CYPRESS_NO_DELAYS
},
e2e: {
baseUrl: "http://localhost:3000",
experimentalRunAllSpecs: true,
setupNodeEvents(on, config) {
require("@cypress/code-coverage/task")(on, config);
on("task", {
clearDatabase() {
require("dotenv").config({ path: "./server/config/.env" });
return require("./server/config/database")().then(async conn => {
for (const { name } of await conn.connection.db
.listCollections()
.toArray()) {
await conn.connection.db.collection(name).deleteMany();
}
return null;
});
},
createEvent({
title,
description,
startAt,
endAt,
location,
user,
groupId,
}) {
require("dotenv").config({ path: "./server/config/.env" });
return require("./server/config/database")().then(async () => {
const { Event } = require("./server/models/Event");
const event = await Event.create({
title,
description,
startAt,
endAt,
location,
user,
groupId,
});
return event;
});
},
generateObjectId() {
return require("mongoose").Types.ObjectId().toString();
},
});
return config;
},
},
});
Loading

0 comments on commit f22f80d

Please sign in to comment.