Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/heystone999/memo-minder
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
Sara-Ho99 committed Mar 18, 2024
2 parents 92db5ec + 19e5836 commit 1b71b6b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion memo-backend/users_routes_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- **Status**: 201 Created
- **Body**:
- `message`: String - Confirmation message.
- `username`: String - The username of the user.
- `email`: String - The email address of the user.
- `id`: String - userId.

## Login

Expand All @@ -30,4 +33,7 @@
- **Status**: 200 OK
- **Body**:
- `message`: String - Confirmation message.
- `token`: String - JWT token for authentication.
- `token`: String - JWT token for authentication.
- `username`: String - The username of the user.
- `email`: String - The email address of the user.
- `id`: String - userId.

2 comments on commit 1b71b6b

@heystone999
Copy link
Owner

Choose a reason for hiding this comment

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

Coverage report for backend

Caution

Test run failed

St.
Category Percentage Covered / Total
🔴 Statements 48.73% 96/197
🔴 Branches 28.57% 18/63
🔴 Functions 22.22% 4/18
🔴 Lines 48.73% 96/197

Test suite run failed

Failed tests: 4/7. Failed suites: 3/3.
  ● POST /api/habits › should add a new habit

    expected 200 "OK", got 401 "Unauthorized"

      30 |     .post('/api/login')
      31 |     .send({ username: username, password: password })
    > 32 |     .expect(200);
         |      ^
      33 |
      34 |   // Extract the token from the response body
      35 |   token = res.body.token;

      at Object.expect (tests/habits.test.js:32:6)
      ----
      at Test._assertStatus (node_modules/supertest/lib/test.js:252:14)
      at assertFn (node_modules/supertest/lib/test.js:308:13)
      at Test.fn [as _assertFunction] (node_modules/supertest/lib/test.js:285:13)
      at Test._assertFunction [as assert] (node_modules/supertest/lib/test.js:164:23)
      at Server.assert (node_modules/supertest/lib/test.js:120:14)


  ● User endpoints › GET /api/users returns all users

    expect(received).toHaveLength(expected)

    Expected length: 1
    Received length: 2
    Received array:  [{"email": "[email protected]", "id": "65f8aa44ffca674b0b7d44ec", "username": "user1"}, {"email": "[email protected]", "id": "65f8aa4411c0e2c7b8438341", "username": "testuser"}]

      15 |     const response = await api.get('/api/users').expect(200).expect('Content-Type', /application\/json/)
      16 |
    > 17 |     expect(response.body).toHaveLength(1)
         |                           ^
      18 |   })
      19 |
      20 |   test('POST /api/users creates a new user', async () => {

      at Object.toHaveLength (tests/users.test.js:17:27)

  ● User endpoints › POST /api/users creates a new user

    expect(received).toHaveLength(expected)

    Expected length: 1
    Received length: 2
    Received array:  [{"email": "[email protected]", "id": "65f8aa44ffca674b0b7d44f3", "username": "newuser"}, {"email": "[email protected]", "id": "65f8aa4411c0e2c7b8438348", "username": "testuser"}]

      31 |
      32 |     const users = await User.find({})
    > 33 |     expect(users).toHaveLength(1)
         |                   ^
      34 |     expect(users[0].username).toBe(newUser.username)
      35 |
      36 |     const passwordMatches = await bcrypt.compare(newUser.password, users[0].passwordHash)

      at Object.toHaveLength (tests/users.test.js:33:19)


  ● Login endpoint › Login with correct credentials should return a token

    expected 200 "OK", got 401 "Unauthorized"

      23 |       .post('/api/login')
      24 |       .send({ username: 'testuser', password: 'password' })
    > 25 |       .expect(200)
         |        ^
      26 |       .expect('Content-Type', /application\/json/);
      27 |
      28 |     expect(response.body.token).toBeDefined();

      at Object.expect (tests/login.test.js:25:8)
      ----
      at Test._assertStatus (node_modules/supertest/lib/test.js:252:14)
      at assertFn (node_modules/supertest/lib/test.js:308:13)
      at Test.fn [as _assertFunction] (node_modules/supertest/lib/test.js:285:13)
      at Test._assertFunction [as assert] (node_modules/supertest/lib/test.js:164:23)
      at Server.assert (node_modules/supertest/lib/test.js:120:14)

Report generated by 🧪jest coverage report action from 1b71b6b

@heystone999
Copy link
Owner

Choose a reason for hiding this comment

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

Coverage report for fronend

Caution

Test run failed

St.
Category Percentage Covered / Total
🔴 Statements 34.14% 269/788
🔴 Branches 22.87% 75/328
🔴 Functions 24.42% 53/217
🔴 Lines 34.53% 259/750

Test suite run failed

Failed tests: 1/13. Failed suites: 1/4.
  ● health and level integration test

    TestingLibraryElementError: Unable to find an element with the text: -. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

    Ignored nodes: comments, script, style
    <body>
      <div>
        <div>
          <div>
            <nav>
              <div
                class="nav-left"
              >
                <a
                  class="logo"
                  href="/"
                >
                  MEMO MINDER
                </a>
                <a
                  class=""
                  href="/"
                >
                  <span>
                    Tasks
                  </span>
                </a>
                <a
                  class=""
                  href="/"
                >
                  <span>
                    Shops
                  </span>
                </a>
                <a
                  class=""
                  href="/"
                >
                  <span>
                    Challenges
                  </span>
                </a>
                <a
                  class=""
                  href="/"
                >
                  <span>
                    Milestones
                  </span>
                </a>
              </div>
              <div
                class="nav-middle"
              />
              <div
                class="nav-right"
              >
                <div
                  class="coin"
                >
                  <img
                    alt=""
                    class="coin-icon"
                    src="/coin.png"
                  />
                  <div
                    class="coin-number"
                  >
                    0
                  </div>
                </div>
                <div
                  class="user"
                >
                  <img
                    alt=""
                    class="user-pic"
                    src="/user-pic.png"
                  />
                  <span
                    class="user-name"
                  >
                    Ray
                  </span>
                </div>
              </div>
              <div
                class="user-menu inactive"
              >
                <ul>
                  <li
                    class="user-menu-item"
                  >
                    <a
                      class="logout-link"
                      href="/login"
                    >
                       
                      Log Out
                       
                    </a>
                  </li>
                </ul>
              </div>
            </nav>
            <div
              style="display: flex; flex-direction: column;"
            >
              <div
                class="header"
              >
                <div
                  class="user"
                >
                  <div
                    class="user-character"
                  >
                    <img
                      alt=""
                      class="user-character-pic"
                      src="/char-pic.png"
                    />
                  </div>
                  <div
                    class="user-character-info"
                  >
                    <div
                      class="username"
                    >
                      Ray
                    </div>
                    <div
                      class="user-data"
                    >
                      <div
                        class="health"
                      >
                        <img
                          alt=""
                          src="/heart.png"
                        />
                        <div
                          class="health-bar"
                        >
                          <div
                            class="health-level"
                            style="width: 100%;"
                          />
                        </div>
                        <span>
                          100
                          /100
                        </span>
                      </div>
                      <div
                        class="level"
                      >
                        <img
                          alt=""
                          src="/star.png"
                        />
                        <div
                          class="level-bar"
                        >
                          <div
                            class="level-level"
                            style="width: 0%;"
                          />
                        </div>
                        <span>
                          Level 
                          1
                          : 
                          0
                          /100
                        </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div
                  class="bag"
                >
                  <div
                    class="bag-name"
                  >
                    Bag
                  </div>
                  <div
                    class="bought-items-images"
                  />
                </div>
              </div>
              <div>
                <div
                  class="taskAreaContainer"
                >
                  <div
                    class="controlButton"
                  >
                    <div
                      class="clearButtonContainer"
                    >
                      <button
                        class="clearButton"
                      >
                        Clear and Reset
                      </button>
                    </div>
                    <div
                      class="task-button-container"
                    >
                      <div
                        class="add-task-button-container"
                      >
                        <button
                          class="add-task-button"
                        >
                          Add Task
                        </button>
                      </div>
                    </div>
                  </div>
                  <div
                    class="taskAreaSections"
                  >
                    <div
                      class="taskAreaSection"
                    >
                      <h2>
                        Habits
                      </h2>
                      <div
                        class="taskAreaNav"
                      >
                        <button>
                          All
                        </button>
                        <button>
                          Good
                        </button>
                        <button>
                          Bad
                        </button>
                      </div>
                      <div
                        class="contentContainer"
                      >
                        <div
                          class="habitInputContainer"
                        >
                          <input
                            class="habitInput"
                            placeholder="Add a habit"
                            type="text"
                            value=""
                          />
                        </div>
                        <div
                          class="taskList"
                        />
                      </div>
                    </div>
                    <div
                      class="taskAreaSection"
                    >
                      <h2>
                        Dailies
                      </h2>
                      <div
                        class="taskAreaNav"
                      >
                        <button>
                          All
                        </button>
                        <button>
                          Due
                        </button>
                        <button>
                          Completed
                        </button>
                      </div>
                      <div
                        class="contentContainer"
                      >
                        <div
                          class="dailyInputContainer"
                        >
                          <input
                            class="dailyInput"
                            placeholder="Add a daily"
                            type="text"
                            value=""
                          />
                        </div>
                        <div
                          class="taskList"
                        >
                          <div
                            class="dailyItem "
                          >
                            <button>
                              +
                            </button>
                            <p>
                              Your default daily
                            </p>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div
                      class="taskAreaSection"
                    >
                      <h2>
                        To Do Lists
                      </h2>
                      <div
                        class="taskAreaNav"
                      >
                        <button>
                          All
                        </button>
                        <button>
                          Scheduled
                        </button>
                        <button>
                          Completed
                        </button>
                      </div>
                      <div
                        class="contentContainer"
                      >
                        <div
                          class="todoInputContainer"
                        >
                          <input
                            class="todoInput"
                            placeholder="Add a To Do"
                            type="text"
                            value=""
                          />
                        </div>
                        <div
                          class="taskList"
                        >
                          <div
                            class="todoItem "
                          >
                            <button>
                              +
                            </button>
                            <p>
                              Your default to-do
                            </p>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div
                      class="taskAreaSection"
                    >
                      <h2>
                        Rewards
                      </h2>
                      <div
                        class="taskAreaNav"
                      >
                        <button>
                          All
                        </button>
                      </div>
                      <div
                        class="contentContainer"
                      >
                        <div
                          class="rewardInputContainer"
                        >
                          <input
                            class="rewardInput"
                            placeholder="Add a Reward"
                            type="text"
                            value=""
                          />
                        </div>
                        <div
                          class="taskList"
                        >
                          <div
                            class="rewardItem"
                          >
                            <button>
                              10
                               coins
                            </button>
                            <p>
                              Your default reward
                            </p>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>

      12 |
      13 |     // Trigger a negative habit click
    > 14 |     fireEvent.click(screen.getByText('-'));
         |                            ^
      15 |
      16 |     // Health should decrease by 10
      17 |     expect(screen.getByText('90/100')).toBeInTheDocument();

      at Object.getElementError (node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/config.js:37:19)
      at node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/query-helpers.js:76:38
      at node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/query-helpers.js:52:17
      at getByText (node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/query-helpers.js:95:19)
      at Object.<anonymous> (src/tests/AppIntegration.test.js:14:28)

Report generated by 🧪jest coverage report action from 1b71b6b

Please sign in to comment.