Skip to content
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

Frontend #502

Open
wants to merge 91 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
edc4ad6
updating readme with trello link
devCoder69409 Jun 12, 2023
3134bab
Merge pull request #1 from nrai14/trelloboard
nrai14 Jun 12, 2023
4108351
added first and last name to user
jasmine-asra Jun 12, 2023
b2c901c
Create main.yml
olic32 Jun 12, 2023
6f230ce
began styling home/landing page
Jun 12, 2023
e95cd56
Merge pull request #2 from nrai14/design
olic32 Jun 12, 2023
068e470
changed database schema
jasmine-asra Jun 12, 2023
c9dac6f
fixed conflicts
jasmine-asra Jun 12, 2023
3dd170e
fixed database issues
jasmine-asra Jun 13, 2023
1e177f5
initial test scenarios
devCoder69409 Jun 13, 2023
f2f1d8c
Merge pull request #3 from nrai14/test_scenarios
devCoder69409 Jun 13, 2023
35c063e
Update main.yml
olic32 Jun 13, 2023
13a982a
started styling signup page
Jun 13, 2023
7d3f794
displays error messages
jasmine-asra Jun 13, 2023
81885fe
displays error messages
jasmine-asra Jun 13, 2023
cffa4cc
Sign up (#4)
jasmine-asra Jun 13, 2023
c97d28b
merged main into design branch
Jun 13, 2023
ad3e337
fixed user unit test
jasmine-asra Jun 13, 2023
4cba0dc
Merge sign up to main
jasmine-asra Jun 13, 2023
4c94ea4
Sign up (#5)
jasmine-asra Jun 13, 2023
b785f7b
changed integration tests
olic32 Jun 13, 2023
3d78c5b
Update user_can_see_posts_count_on_post.js
olic32 Jun 13, 2023
485d6bf
new session functionality started
Jun 13, 2023
fccd28e
added unit tests
jasmine-asra Jun 13, 2023
a5be9d3
added unit tests
jasmine-asra Jun 13, 2023
20ea9ec
Sign up (#6)
jasmine-asra Jun 13, 2023
429c320
Merge pull request #7 from nrai14/design
oliver-weare Jun 13, 2023
9bfcba6
merged with main
jasmine-asra Jun 13, 2023
823543a
Merge branch 'main' of https://github.com/nrai14/acebook-betta
jasmine-asra Jun 13, 2023
48218fe
merged with main
jasmine-asra Jun 13, 2023
ed3ccaf
Update a single integration test just to check if it works
olic32 Jun 13, 2023
7331521
acebook user stories (#8)
devCoder69409 Jun 14, 2023
7ea3d29
removed password encrypting from sessions for now
Jun 14, 2023
cf1daad
Merge pull request #9 from nrai14/design
oliver-weare Jun 14, 2023
1125a38
added existing email validation
jasmine-asra Jun 14, 2023
1050862
Sign up (#10)
jasmine-asra Jun 14, 2023
d2ce37f
first and last name cannot contain punctuation
jasmine-asra Jun 14, 2023
64a1e6e
user already exists test
jasmine-asra Jun 14, 2023
569472c
added max character limit on name fields
jasmine-asra Jun 14, 2023
292c3e4
new cypress tests matching user stories
olic32 Jun 14, 2023
f5d7bdb
Merge pull request #11 from nrai14/cypressbranch
olic32 Jun 14, 2023
68a94e6
sign up stuff
afzaa25 Jun 14, 2023
82e2fcf
refactored code
jasmine-asra Jun 14, 2023
7388a05
max length validation
jasmine-asra Jun 14, 2023
ffe7201
merged sign-up versions
jasmine-asra Jun 14, 2023
a36f20c
up to date with origin sign-up branch
jasmine-asra Jun 14, 2023
e8b35e4
resolved conflicts
jasmine-asra Jun 14, 2023
c846344
Update main.yml
olic32 Jun 14, 2023
ba0c45a
Update cypress.json
olic32 Jun 14, 2023
58c062a
Update cypress.json
olic32 Jun 14, 2023
2eb2b83
Timeline (#12)
nrai14 Jun 14, 2023
1bcf96e
amended Cypress hooks for signup and sign in buttons
olic32 Jun 14, 2023
d2ef4f6
added input sanitization and tests
jasmine-asra Jun 14, 2023
a4371dc
added confirm password
jasmine-asra Jun 14, 2023
d2c96b6
added validation tests
jasmine-asra Jun 15, 2023
b903e50
ready to merge
jasmine-asra Jun 15, 2023
9c8b7b7
"ready to merge"
jasmine-asra Jun 15, 2023
6feef99
Sign up (#14)
jasmine-asra Jun 15, 2023
12d9642
Merge pull request #14 from nrai14/sign-up
olic32 Jun 15, 2023
39a10c6
fixed typo
jasmine-asra Jun 15, 2023
7e630e0
Sign up (#15)
jasmine-asra Jun 15, 2023
ed7e71b
Amended integration tests, added dropDatabase function, added new tests
olic32 Jun 15, 2023
ac342c8
Merge pull request #16 from nrai14/cypressnew
olic32 Jun 15, 2023
8ac1d35
amended database function
olic32 Jun 15, 2023
84f457e
Merge pull request #17 from nrai14/cypressnew
olic32 Jun 15, 2023
a18080f
altered post tests again to account for change tags
olic32 Jun 15, 2023
b293016
Merge pull request #18 from nrai14/cypresstest2
olic32 Jun 15, 2023
583619a
Selenium tests (#19)
devCoder69409 Jun 15, 2023
bdd8d9c
Update main.yml
olic32 Jun 15, 2023
72a22e9
Update main.yml
olic32 Jun 15, 2023
df91f32
Update package.json
olic32 Jun 15, 2023
42c7c0e
Update main.yml
olic32 Jun 15, 2023
3166936
Update package.json
olic32 Jun 15, 2023
2bbb127
Update main.yml
olic32 Jun 15, 2023
93ec651
update github actions to exclude e2e (#20)
devCoder69409 Jun 15, 2023
95b32c7
Update main.yml
olic32 Jun 15, 2023
f841d71
Posts (#22)
jasmine-asra Jun 16, 2023
b23e582
comma on post.js
devCoder69409 Jun 16, 2023
021ef71
fix comment.js
devCoder69409 Jun 16, 2023
ae8c38c
case sensitivity fix
devCoder69409 Jun 16, 2023
b39acb0
Update user_can_sign_up_spec.js
olic32 Jun 16, 2023
5c0a7b9
Debugging (#23)
jasmine-asra Jun 16, 2023
8567ff0
media query
afzaa25 Jun 16, 2023
76013f8
Debugging (#24)
jasmine-asra Jun 16, 2023
5f00e34
reversed post (#25)
nrai14 Jun 16, 2023
6ed7557
Merge pull request #26 from nrai14/design2
afzaa25 Jun 16, 2023
8698c8a
Amended cypress tests to account for new post structure, added random…
olic32 Jun 16, 2023
9c0e069
post.js typo fix
devCoder69409 Jun 16, 2023
50655ca
Merge pull request #27 from nrai14/cypressReview
olic32 Jun 16, 2023
cfca381
Update user_can_see_and_create_post.js
olic32 Jun 16, 2023
1c9511f
selenium tests covering mvp
devCoder69409 Jun 16, 2023
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
Binary file added .DS_Store
Binary file not shown.
21 changes: 3 additions & 18 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true,
"jest/globals": true,
"cypress/globals": true
},
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
"es2021": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2022
"ecmaVersion": "latest"
},
"plugins": [
"cypress",
"jest",
"node"
],
"rules": {
}
}
45 changes: 45 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
mongodb-version: ['6.0']

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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Install dependencies
run: npm install
# run the unit tests but exclude the selenium tests.
- name: Run unit tests
run: npm run test:unit
# run the cypress tests using cypress actions.
- name: Start test server
run: npm run start:test &

- name: Run all Cypress tests
uses: cypress-io/github-action@v5
with:
start: npm start
record: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

9 changes: 9 additions & 0 deletions .idea/acebook-betta.iml

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

6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It uses:

## Card wall

REPLACE THIS TEXT WITH A LINK TO YOUR CARD WALL
[Trello Board](https://trello.com/b/ZcUWX9qo/betta-acebook)

## Quickstart

Expand Down
44 changes: 43 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,41 @@ const postsRouter = require("./routes/posts");
const sessionsRouter = require("./routes/sessions");
const usersRouter = require("./routes/users");

const mongoose = require('mongoose')
const User = require("./models/user");

const sanitizeInput = require('./functions/sanitize')

const app = express();

// view engine setup
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "hbs");


app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));
app.use(methodOverride("_method"));


app.use(
session({
key: "user_sid",
secret: "super_secret",
resave: false,
saveUninitialized: false,
cookie: {
expires: 600000,
expires: 1200000,
},
rolling: true, // Extend the session expiration on each request
rollingTimeout: 1200000, // Set the rolling timeout to 10 minutes
})
);


// clear the cookies after user logs out
app.use((req, res, next) => {
if (req.cookies.user_sid && !req.session.user) {
Expand All @@ -44,13 +54,16 @@ app.use((req, res, next) => {
next();
});


// middleware function to check for logged-in users
const sessionChecker = (req, res, next) => {
if (!req.session.user && !req.cookies.user_sid) {
res.redirect("/sessions/new");
} else {
next();
}


};

// route setup
Expand All @@ -59,11 +72,13 @@ app.use("/posts", sessionChecker, postsRouter);
app.use("/sessions", sessionsRouter);
app.use("/users", usersRouter);


// catch 404 and forward to error handler
app.use((req, res, next) => {
next(createError(404));
});


// error handler
app.use((err, req, res) => {
// set locals, only providing error in development
Expand All @@ -75,4 +90,31 @@ app.use((err, req, res) => {
res.render("error");
});


app.post("/users/new", async (req, res) => {
try {
const { firstName, lastName, email, password, confirmPassword } = req.body;

// Sanitize and validate input
const sanitizedFirstName = sanitizeInput(firstName);
const sanitizedLastName = sanitizeInput(lastName);
const sanitizedEmail = sanitizeInput(email);

// Create a new user
const user = new User({
firstName: sanitizedFirstName,
lastName: sanitizedLastName,
email: sanitizedEmail,
password: password,
});

// Save the user to the database
await user.save();

res.status(200).json({ message: "Signup successful!" });
} catch (error) {
res.status(500).json({ message: "Signup failed." });
}
});

module.exports = app;
60 changes: 60 additions & 0 deletions betta_test_scenarios.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Acebook Betta - Test Scenarios
Making people's lives betta

#### **1. Home Page:**

| Test Case ID | Test Scenario | Test Steps | Expected Result | Actual Result |
|-------|----------------------------------------------------------------------------------------|---------------------------------------------------------------------------|-----------------------------------------------------|---------|
| HP_01 | Verify all links on the navigation bar | Click each link on the navigation bar <br/> signup link <br/>login link | Each link should direct to the correct page |
| HP_02 | Verify that menu options show on navigation bar when page size is reduced(mobile view) | Reduce the page size and check the menu | Menu should display and links should work correctly |
| HP_03 | Verify page title visibility(including accessibility) | Look at the title of the homepage(check if accessible) | The title should be visible and findable with label |
| HP_04 | Verify persistence of login session | Login, navigate away to another website, and return to homepage | User should still be logged in |

#### **2. Sign Up:**

| Test Case ID | Test Scenario | Test Steps | Expected Result | Actual Result |
|--------------|---------------------------------------------------------------------|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|--------------|
| SU_01 | Verify home link / cancel / back functionality | Click on each <br/>submit button <br/>cancel button | Should navigate to the corresponding page |
| SU_02 | Verify valid username, full name, email, password are only accepted | 1- Try to sign up with invalid credentials <br/>2- Try to sign up with valid credentials | 1- Error message should be displayed if fails <br/>2- Signup confirmation shown if succesful |
| SU_03 | Verify password hashing | Sign up and inspect database | Password should be stored as a hash |
| SU_04 | Unable to signup with existing email address | Try to sign up with an email already in use | Should throw an error message |
| SU_05 | Verify prevention of duplicate signup credentials | Try to sign up with duplicate credentials | Should throw an error message |
| SU_06 | Verify password criteria | Check if password requirements are displayed and enforced | Requirements should be enforced, and error message should be displayed if not met |
| SU_07 | Verify error message if fields left blank | Try to sign up leaving fields blank | Error message should be received |
| SU_08 | Verify confirm sign up button functionality | Click the confirm sign up button | Should return to homepage/landing page/profile page |
| SU_09 | Verify punctuation acceptance in name fields | Try to sign up with punctuation in name fields | Should throw error if entered incorrectly |
| SU_10 | Verify maximum character limit | Try to sign up with a name fields that exceeds character limit | Should throw error if character limit is exceeded |
| SU_11 | Verify auto log out feature (SECURITY) | Stay inactive for the duration of the session timeout | Should be logged out automatically |
| SU_12 | Verify prevention of harmful scripts | Try to inject harmful script during sign up | Should prevent script injection |

#### **3. Login Page:**

| Test Case ID | Test Scenario | Test Steps | Expected Result | Actual Result |
|--------------|----------------------------------------------------|---------------------------------------------|----------------|--------------|
| LP_01 | Verify only valid email address is accepted | Try to log in with an invalid email address | Should not be able to log in |
| LP_02 | Verify only valid passwords are accepted | Try to log in with an invalid password | Should not be able to log in |
| LP_03 | Verify error message for invalid login credentials | Try to log in with invalid credentials | Error message should display (should not specify if password/email is incorrect) |
| LP_04 | Verify prevention of harmful scripts | Try to inject harmful script during login | Should prevent script injection |
| LP_05 | Verify blank fields are not accepted | Try to log in with blank fields | Error message should display |

#### **4. Posts Page:**

| Test Case ID | Test Scenario | Test Steps | Expected Result | Actual Result |
|--------------|------------------------------------------------------------------------|---------------------------------------------------|----------------------------------------------------|----------------------------------------------|
| PP_01 | Verify ability to create a new post | Log in and try to create a new post | Should be able to create a post |
| PP_02 | Verify ability to create multiple posts | Log in and try to create multiple posts | Should be able to create multiple posts |
| PP_03 | Verify upper limit of number of posts shown <br/> (Check performance) | Create posts that exceed the limit | Should only show the maximum number of posts |
| PP_04 | Verify local date stamp on post | Create a post and check the local date stamp | Date stamp should match the current local date |
| PP_05 | Verify emoji acceptance | Create a post with emojis | Post should display with emojis | Pass |
| PP_06 | Verify special characters/punctuation acceptance | Create a post with special characters/punctuation | Post should display with special characters/punctuation |
| PP_07 | Verify UTF-8 language character support | Create a post with UTF-8 characters | Post should display with UTF-8 characters |
| PP_08 | Verify post creation only when signed in (SECURITY) | Try to create a post when not logged in | Should not be able to create a post |
| PP_09 | Verify handling of post creation with empty fields | Try to create a post with empty fields | Error message should display | Fail - Able to create posts with empty field |
| PP_10 | Verify navigation bar displays properly | Check the navigation bar on the posts page | Navigation bar should display properly |

#### **5. Performance Testing:**
| Test Case ID | Test Scenario | Test Steps | Expected Result | Actual Result |
|--------------|---------------|--------------|----------------|--------------|
| PT_01 | Sign up | placeholder | placeholder | placeholder |
| PT_02 | Login | placeholder | placeholder | placeholder |

55 changes: 55 additions & 0 deletions betta_user_stories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## **Acebook Betta User Stories**
Acebook aims to be an easy-to-use and accessible platform that simplifies staying in touch with friends.

Acebook will connect people and make their lives betta.

## User Stories
**Feature:** Signup
- As a new user,
When I am on homepage and I click on sign up,
I want to be taken to the sign up page,
I want to see the option to enter my first name, last name, email, password, confirm password
So that I can signup.

**Feature:** Login
- As a user with account,
When I am on homepage I want to be able click login,
So that I can be taken to the login page,
And be able to enter my account details,
So that I can be taken to my homepage

**Feature:** Logout
- As a user,
I want to be able to click logout,
So that I can end my session securely,
And be taken back to the login page.

**Feature:** Posts Page
- As a logged-in user,
I want to be able to see posts,
See comments on posts, and number of likes,
So that I can connect with friends.

**Feature:** Create Post
- As a logged-in user,
I want to be able to click create post,
And be taken to new post page,
Enter some content and upload an image,
So that I can create a post.

**Feature:** Comment on Post
- As a logged-in user,
I want to be able to comment on an existing post,
By entering a comment and submitting it,
So that I can see my comment is reflected on the post.

**Feature:** Like a Post
- As a logged-in user,
I want to be able to like an existing post,
By clicking a like button,
So that I can see my like is reflected on the post.

**Feature:** Upload Profile Picture
- As a logged-in user,
I want to be able to upload a profile picture,
So that it is displayed to other users across pages.
2 changes: 1 addition & 1 deletion controllers/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const HomeController = {
},
};

module.exports = HomeController;
module.exports = HomeController;
Loading