Skip to content

Latest commit

 

History

History
112 lines (87 loc) · 20.7 KB

TESTING.md

File metadata and controls

112 lines (87 loc) · 20.7 KB

moonshot-api : Backend Testing

Note: to open links in a new tab, hold CTRL + Click
Note: this document only contains testing info for the moonshot frontend site

Table Of Contents

Manual Testing

The following sections list a number of manual tests undertaken to ensure the site operates according to details listed under Scope and Structure in the README file. Specific dev goals/user stories can viewed (where appropriate) by hovering over the numbers listed under 'Ref(s)' in the tables below; clicking these links will open the relevant section in the README file.

User Administration

These tests check the sign up, sign in, and sign out functionality of the site. The superuser ms_superadmin and its related password (not given here for security of the API) along with the general user of username: testname, password: test#123 have specifically been created to access and function within the backend in order to determine the outcome of these tests. Within the tables below, the descriptor 'valid details' indicates that the following is expected:

  • Required fields (*) are not left blank
  • Invalid values/formats have not been added to a field
Test Ref(s) Steps Expected Result
Admin can sign into the admin site 1.1
  1. Type https://moonshot-api-ff76437bf02f.herokuapp.com/admin/ into the browser
  2. Enter valid admin details
  3. Click 'Log in' button
  • Admin directed to main site administration page
Pass
Admin can add a user, and their related user and equipment profiles, to the site 1.2
1.3
  1. Login in to admin site
  2. Click 'Add' beside 'Users'
  3. Scroll to bottom of page and complete form with valid details
  4. Click 'Save' button
  • Admin directed to new page displaying name of newly created user
  • Newly created user also displayed on 'User profiles' page (click 'User profiles' link to view)
  • Newly created user also displayed on 'Equipment profiles' page (click 'Equipment profiles' link to view)
Pass
Admin cannot add a user who already exists 1.2
1.3
  1. Login in to admin site
  2. Click 'Add' beside 'Users'
  3. Scroll to bottom of page and complete form with the username 'testname'
  4. Click 'Save' button
  • A message saying "A user with that username already exists" appears above the form
Pass
Admin can delete a user, and their related user and equipment profiles, on the site 1.2
1.3
  1. Login in to admin site
  2. Click 'Users' link
  3. Scroll down and select tick box beside user to be deleted
  4. Select 'Delete selected users' from Action dropdown above the user list
  5. Click 'Go' button
  6. Scroll down and click 'Yes I'm sure' button
  • Admin directed back to list of users
  • Deleted user no longer appears on list
  • Deleted user also removed from 'User profiles' page (click 'User profiles' link to view)
  • Deleted user also removed from 'Equipment profiles' page (click 'Equipment profiles' link to view)
Pass

Get, Post, Put & Delete (CRUD) Functionality

These tests determine if an admin is able to successfully - or otherwise - create (post), view (get), update (put) and/or delete photos, stars, comments, or gear/account info through the backend admin site. In all test cases, one must first sign in to the admin site before completing any of the other steps listed (superuser ms_superadmin and its related password - not given here for security of the API - have specifically been registered for this purpose), while the descriptor 'valid details' indicates that the following is expected:

  • Required fields (*) are not left blank
  • Invalid values/formats have not been added to a field

User & Equipment Profile Tests

Test Ref(s) Steps Expected Result
Admin can edit User Profile 1.2
  1. Click 'User Profiles' link
  2. Click on an entry from the displayed user profiles list
  3. Scroll down and update form with valid details
  4. Click 'Save' button
  • Admin directed back to list of user profiles
  • A message saying "The user profile {user profile} was changed successfully" appears above the user profile list
Pass
Admin can update user avatar 1.2
  1. Click 'User Profiles' link
  2. Click on an entry from the displayed user profiles list
  3. Scroll down and click 'Choose file' button
  4. Select a valid image file
  5. Click 'Save' button
  • Admin directed back to list of user profiles
  • A message saying "The user profile {user profile} was changed successfully" appears above the user profile list
Pass
Admin cannot change avatar to non-image file 1.2
  1. Click 'User Profiles' link
  2. Click on an entry from the displayed user profiles list
  3. Scroll down and click 'Choose file' button
  4. Select a non-image file
  5. Click 'Save' button
  • A message saying "Upload a valid image. The file you uploaded was either not an image or a corrupted image" appears on the form
Pass
Admin can edit Equipment profile 1.3
  1. Click 'Equipment Profiles' link
  2. Click on an entry from the displayed equipment profiles list
  3. Scroll down and update form with valid details
  4. Click 'Save' button
  • Admin directed back to list of equipment profiles
  • A message saying "The equipment profile {equipment profile} was changed successfully" appears above the equipment profile list
Pass

Photo Tests

Test Ref(s) Steps Expected Result
Admin can upload photo 1.4
  1. Click 'Add' beside 'Photos'
  2. Scroll down and complete all form fields with valid details
  3. Click 'Choose File' an upload a valid image
  4. Click 'Save' button
  • Admin directed back to photo list
  • Newly submitted photo appears at top of list
Pass
Admin cannot submit form if non-image file is selected 1.4
  1. Click 'Add' beside 'Photos'
  2. Scroll down and complete all form fields with valid details
  3. Click 'Choose File' an upload a NON-IMAGE FILE
  4. Click 'Save' button
  • Form will not submit
  • A message saying "Upload a valid image. The file you uploaded was either not an image or a corrupted image" appears below the form
Pass
Admin cannot submit form if Title field is blank 1.4
  1. Click 'Add' beside 'Photos'
  2. Scroll down and complete all form fields with valid details but leave 'Title' blank
  3. Click 'Choose File' an upload a valid image
  4. Click 'Save' button
  • Form will not submit
  • A message saying "This field is required" appears on the form
Pass
Admin cannot submit form if Main Feature field is left as "(Select an option)" 1.4
  1. Click 'Add' beside 'Photos'
  2. Scroll down and complete all form fields with valid details but leave 'Main Feature' unselected
  3. Click 'Choose File' an upload a valid image
  4. Click 'Save' button
  • Form will not submit
  • A message saying "This field is required" appears on the form
Pass
Admin cannot submit form if Location field is blank 1.4
  1. Click 'Add' beside 'Photos'
  2. Scroll down and complete all form fields with valid details but leave 'Location' blank
  3. Click 'Choose File' an upload a valid image
  4. Click 'Save' button
  • Form will not submit
  • A message saying "This field is required" appears on the form
Pass
Admin can submit form if Description field is left blank 1.4
  1. Click 'Add' beside 'Photos'
  2. Scroll down and complete all form fields with valid details but leave 'Description' blank
  3. Click 'Choose File' an upload a valid image
  4. Click 'Save' button
  • Admin directed back to photo list
  • Newly submitted photo appears at top of list
Pass
Admin can submit form if Lens Used, Camera Used, or Other Equipment Used fields are left blank 1.4
  1. Click 'Add' beside 'Photos'
  2. Scroll down and complete all form fields with valid details but leave 'Lens Used', 'Camera Used', and 'Other Equipment Used' blank
  3. Click 'Choose File' an upload a valid image
  4. Click 'Save' button
  • Admin directed back to photo list
  • Newly submitted photo appears at top of list
Pass
Admin can update photo with valid details 1.4
  1. Click 'Photos' link
  2. Click on an entry from the displayed photo list
  3. Scroll down and update form with valid details
  4. Click 'Save' button
  • Admin directed back to photo list
  • A message "The photo {photo name} was changed successfully" appears above the photo list
Pass
Admin cannot update photo with invalid details 1.4
  1. Click 'Photos' link
  2. Click on an entry from the displayed photo list
  3. Scroll down and update form with INVALID DETAILS
  4. Click 'Save' button
  • Form will not submit
  • A message saying "Please correct the errors below" appears above the form
Pass
Admin can delete photo 1.4
  1. Click 'Photos' link
  2. Scroll down and select tick box beside photo to be deleted
  3. Select 'Delete selected photos' from Action dropdown above the photo list
  4. Click 'Go' button
  5. Scroll down and click 'Yes I'm sure' button
  • Admin directed back to list of photos
  • A message saying "Successfully deleted 1 photo" appears above the photo list
  • Deleted photo no longer appears on list
Pass

Comment Tests

Test Ref(s) Steps Expected Result
Admin can add comment to photo 1.5
  1. Click 'Add' beside 'Comments'
  2. Scroll down and complete all form fields with valid details
  3. Click 'Save' button
  • Admin directed back to list of comments
  • A message saying "The comment {comment name} was added successfully" appears above the comment list
  • Newly submitted comment appears at top of list
Pass
Admin cannot add 'blank comment' to photo 1.5
  1. Click 'Add' beside 'Comments'
  2. Scroll down and complete all form fields but leave 'Content' blank
  3. Click 'Save' button
  • Form will not submit
  • A message saying "This field is required" appears on the form
Pass
Admin can edit comment 1.5
  1. Click 'Comments' link
  2. Click on an entry from the displayed comment list
  3. Scroll down and update form with valid details
  4. Click 'Save' button
  • Admin directed back to comment list
  • A message saying "The comment {comment name} was changed successfully" appears above the comment list
Pass
Admin cannot edit comment to be blank 1.5
  1. Click 'Comments' link
  2. Click on an entry from the displayed comment list
  3. Scroll down and update form so that 'Content' is blank
  4. Click 'Save' button
  • Form will not submit
  • A message saying "This field is required" appears on the form
Pass
Admin can delete comment 1.5
  1. Click 'Comments' link
  2. Scroll down and select tick box beside comment to be deleted
  3. Select 'Delete selected comments' from Action dropdown above the comment list
  4. Click 'Go' button
  5. Scroll down and click 'Yes I'm sure' button
  • Admin directed back to list of comments
  • A message saying "Successfully deleted 1 comment" appears above the comment list
  • Deleted comment no longer appears on list
Pass

Star Tests

Test Ref(s) Steps Expected Result
Admin can add star to photo 1.6
  1. Click 'Add' beside 'Stars'
  2. Scroll down and select a user and photo
  3. Click 'Save' button
  • Admin directed back to list of stars
  • A message saying "The star {star name} was added successfully" appears above the star list
  • Newly submitted star appears at top of list
Pass
Admin can delete star from photo 1.6
  1. Click 'Stars' link
  2. Scroll down and select tick box beside star to be deleted
  3. Select 'Delete selected stars' from Action dropdown above the star list
  4. Click 'Go' button
  5. Scroll down and click 'Yes I'm sure' button
  • Admin directed back to list of stars
  • A message saying "Successfully deleted 1 star" appears above the comment list
  • Deleted star no longer appears on list
  • Pass

    PEP8 Validator Testing

    All files have been passed through the Code Institute PEP8 Linter. The only warnings given were for the settings.py file which contains a small number of long lines (i.e. greater than 80 characters); as this is from code implemented by Django itself, these lines will be left unchanged.

    Bugs

    There are no known bugs in the current deployment of the site. A number of bugs were found, added to the Kanban workflow, and corrected during development. A brief summary of the backend bugs are provided below:

    Type Issue Detail Solution Result
    Data Database won't migrate After creating the Stars model and serializer, attempted to run migrations using python manage.py makemigrations and python manage.py migrate. Terminal displays a UNIQUE constraint not valid message.
    • Delete migrations
    • Delete and recode Stars app/model
    • Rerun migrations
    Fixed
    Data Photos POST function creating IntegrityError When trying to create upload a photo using the POST function the message django.db.utils.IntegrityError: NOT NULL constraint failed: photos_photo.user_id appears
    • Correct syntax of def perform_create() method (incorrectly names as def create_photo)
    Fixed
    Connection API not accepting data from Frontend When attempting to sign up a new user via the frontend, an error is logged to the console regarding blocked CORS policy and the React 'white screen' is shown
    • Added CLIENT_ORIGIN and CLIENT_ORIGIN_DEV variables to the env.py file
    • Added code block to settings.py (see under table)
    Fixed
    Connection API not sending profile_id and profile_image variables When trying to display a user avatar and receive their id on the frontend, a broken image link is shown in the navbar along with an undefined value in developer tools
    • Removed underscore from user_profile and equipment_profile in all serializer files
    Fixed
    Data Photo Upload/Edit Form not saving details Date and Time fields displaying errors within the frontend console with regard to null values
    • Removed null="True" on date and time fields in photos model
    • Added relevant defaults to date and time fields
    Fixed
    if 'CLIENT_ORIGIN' in os.environ:
        CORS_ALLOWED_ORIGINS = [
            os.environ.get('CLIENT_ORIGIN')
        ]
    if 'CLIENT_ORIGIN_DEV' in os.environ:
        extracted_url = re.match(r'^.+-', os.environ.get('CLIENT_ORIGIN_DEV', ''), re.IGNORECASE).group(0)
        CORS_ALLOWED_ORIGIN_REGEXES = [
            rf"{extracted_url}(eu|us)\d+\w\.gitpod\.io$",
        ]