Skip to content

Conversation

@brarsanmol
Copy link
Member

List of Changes

  • Fix spelling of accommodation in codebase.
  • Create enum for attendance options.
  • Add field in hacker.model.js to store their attendance preference.
  • Add field tohacker.validator.js.

Type of Change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Tests Run

Successful POST /api/hacker

Request Body:

{
    "accountId": "...",
    "application": {
        "general": {
            "school": "McGill University",
            "degree": "Undergraduate",
            "fieldOfStudy": ["Computer Science"],
            "graduationYear": "2021",
            "jobInterest": "Internship",
            "URL": {
                "resume": "resumes/1543458163426-5bff4d736f86be0a41badb91",
                "github": "https://github.com/abcd",
                "dropler": "https://dribbble.com/abcd",
                "personal": "https://www.hi.com/",
                "linkedIn": "https://linkedin.com/in/abcd",
                "other": "https://github.com/hackmcgill/hackerAPI/issues/168"
            }
        },
        "shortAnswer": {
            "skills": [
                "Javascript",
                "Typescript"
            ],
            "question1": "I love McHacks",
            "question2": "Pls accept me",
            "previousHackathons": 5,
            "comments": "hi!"
        },
        "other": {
            "gender": "male",
            "ethnicity": ["Asian or Pacific Islander"],
            "privacyPolicy": true,
            "codeOfConduct": true
        },
        "accommodation": {
            "travel": 0,
            "shirtSize": "XS",
+            "attendancePreference": "Remote"
        },
        "location": {
            "timeZone": "GMT-5",
            "country": "Canada",
            "city": "Montreal"
        }
    }
}

Response Body:

{
    "message": "Hacker creation successful.",
    "data": {
        "application": {
            "general": {
                "URL": {
                    "resume": "resumes/1543458163426-5bff4d736f86be0a41badb91",
                    "github": "https://github.com/abcd",
                    "personal": "https://www.hi.com/",
                    "linkedIn": "https://linkedin.com/in/abcd",
                    "other": "https://github.com/hackmcgill/hackerAPI/issues/168"
                },
                "fieldOfStudy": [
                    "Computer Science"
                ],
                "jobInterest": "Internship",
                "school": "McGill University",
                "degree": "Undergraduate",
                "graduationYear": 2021
            },
            "shortAnswer": {
                "skills": [
                    "Javascript",
                    "Typescript"
                ],
                "comments": "hi!",
                "question1": "I love McHacks",
                "question2": "Pls accept me",
                "previousHackathons": 5
            },
            "other": {
                "ethnicity": [
                    "Asian or Pacific Islander"
                ],
                "privacyPolicy": true,
                "codeOfConduct": true
            },
            "accommodation": {
                "impairments": "",
                "barriers": "",
                "travel": 0,
                "shirtSize": "XS",
                "attendancePreference": "Remote"
            },
            "location": {
                "timeZone": "GMT-5",
                "country": "Canada",
                "city": "Montreal"
            }
        },
        "status": "Applied",
        "accountId": "...",
        "id": "..."
    }
}

Failed POST /api/hacker (Invalid Enum)

Request Body:

{
    "accountId": "...",
    "application": {
        "general": {
            "school": "McGill University",
            "degree": "Undergraduate",
            "fieldOfStudy": ["Computer Science"],
            "graduationYear": "2021",
            "jobInterest": "Internship",
            "URL": {
                "resume": "resumes/1543458163426-5bff4d736f86be0a41badb91",
                "github": "https://github.com/abcd",
                "dropler": "https://dribbble.com/abcd",
                "personal": "https://www.hi.com/",
                "linkedIn": "https://linkedin.com/in/abcd",
                "other": "https://github.com/hackmcgill/hackerAPI/issues/168"
            }
        },
        "shortAnswer": {
            "skills": [
                "Javascript",
                "Typescript"
            ],
            "question1": "I love McHacks",
            "question2": "Pls accept me",
            "previousHackathons": 5,
            "comments": "hi!"
        },
        "other": {
            "gender": "male",
            "ethnicity": ["Asian or Pacific Islander"],
            "privacyPolicy": true,
            "codeOfConduct": true
        },
        "accommodation": {
            "travel": 0,
            "shirtSize": "XS",
-            "attendancePreference": "ShouldError"
        },
        "location": {
            "timeZone": "GMT-5",
            "country": "Canada",
            "city": "Montreal"
        }
    }
}

Response Body:

{
    "message": "Validation failed",
    "data": {
        "application.accommodation.attendancePreference": {
            "value": "ShouldError",
            "msg": "The value must be part of the enum",
            "param": "application.accommodation.attendancePreference",
            "location": "body"
        }
    }
}

Failed POST /api/hacker (Field Not Provided)

Request Body:

{
    "accountId": "...",
    "application": {
        "general": {
            "school": "McGill University",
            "degree": "Undergraduate",
            "fieldOfStudy": ["Computer Science"],
            "graduationYear": "2021",
            "jobInterest": "Internship",
            "URL": {
                "resume": "resumes/1543458163426-5bff4d736f86be0a41badb91",
                "github": "https://github.com/abcd",
                "dropler": "https://dribbble.com/abcd",
                "personal": "https://www.hi.com/",
                "linkedIn": "https://linkedin.com/in/abcd",
                "other": "https://github.com/hackmcgill/hackerAPI/issues/168"
            }
        },
        "shortAnswer": {
            "skills": [
                "Javascript",
                "Typescript"
            ],
            "question1": "I love McHacks",
            "question2": "Pls accept me",
            "previousHackathons": 5,
            "comments": "hi!"
        },
        "other": {
            "gender": "male",
            "ethnicity": ["Asian or Pacific Islander"],
            "privacyPolicy": true,
            "codeOfConduct": true
        },
        "accommodation": {
            "travel": 0,
            "shirtSize": "XS"
-                                                                                             
        },
        "location": {
            "timeZone": "GMT-5",
            "country": "Canada",
            "city": "Montreal"
        }
    }
}

Response Body:

{
    "message": "Validation failed",
    "data": {
        "application.accommodation.attendancePreference": {
            "msg": "The value being checked agains the enums must exist.",
            "param": "application.accommodation.attendancePreference",
            "location": "body"
        }
    }
}

Questions For Code Reviewers

  • Do we need to write unit tests for this?
  • How do I update the api docs to reflect the change in response data for the hacker model, without "fudging" with tabs in the api-docs.json.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Listed change(s) in the Changelog
  • New and existing unit tests pass locally with my changes
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

Questions:
- Do we need to write unit tests for this?
- Do we need to update/regenerate api docs to reflect the change in response data for the hacker model.
- Drew JSON for testing from the api docs and was getting a validator error, on closer inspection, the spelling of acccommodation was incorrect in the docs, and in my own commit for hacker.validator.js.
- unit test the following failures:
  - invalid enum.
  - option not passed to the request.

- add valid attendance preferences that vary across the dummy hackers.
fix: merge ci fixes and attendance preference changes.
shirtSize: "L",
travel: 0,
// Attendence Preference Must Be Remote or In Person
// attendancePreference: "asdf"
Copy link
Member

Choose a reason for hiding this comment

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

nit: i think these comments should be removed

});
});

// should fail due to attendance preference not being passed in the request body.
Copy link
Member

Choose a reason for hiding this comment

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

nit: uneven indent

@pengyk pengyk temporarily deployed to testing November 28, 2021 02:36 Inactive
@logan-r logan-r merged commit 91de861 into dev Nov 28, 2021
@logan-r logan-r deleted the feat/attendance-preference branch November 28, 2021 20:21
logan-r pushed a commit that referenced this pull request Nov 29, 2021
* - Implement attendance preference for hackers.

Questions:
- Do we need to write unit tests for this?
- Do we need to update/regenerate api docs to reflect the change in response data for the hacker model.

* Fix spelling errors for accommodation in the codebase.

- Drew JSON for testing from the api docs and was getting a validator error, on closer inspection, the spelling of acccommodation was incorrect in the docs, and in my own commit for hacker.validator.js.

* feat: add unit testing for attendance preference.

- unit test the following failures:
  - invalid enum.
  - option not passed to the request.

- add valid attendance preferences that vary across the dummy hackers.

* fix: remove accidental changes on valid test for code of conduct.

* fix: add missing component on unit tests.

* fix: add attendance preference field to remaining dummy hackers.

* Potential fix to invalid input test

Co-authored-by: Yun Kai Peng <yunkaipeng0129@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants