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

Toggle User and Query assignment from Drawer/Modal #445

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

katyasoup
Copy link
Collaborator

@katyasoup katyasoup commented Mar 20, 2025

PULL REQUEST

Summary

  • Adds a Modal to handle creation of a new User or User Group
  • Adds db methods for adding/removing a single user or query from a group assignment
  • Adds functionality to the UI to add/remove a single user/query from either the Modal or the Drawer component
  • Table view reflects live updates for group assignment, member count, and assigned query count

Related Issue

Fixes #392

Additional Information

Not included:

  • form validation for adding a new user/group (handled in # )
  • editing/deleting a user/group (handled in # )

How to test this change:

  1. Remove any additional users and any usergroups from your local db; ensure you are logged in as qc-admin with Super Admin priveleges
  2. Navigate to User Management from the gear menu; you should see the user permissions table
  3. Click "Add User"; the modal should open. Enter an email address (or any text; validation is in future ticket)
  4. Since there are no user groups, the modal should close and the new user should display in the table.
  5. Click to the groups tab and click Create group
  6. Enter a group name and click continue; the drawer should open and you can select users to add to the group
  7. Click back to the users tab and add an additional user; proceed as before
  8. Since there is now a user group, a second modal page should appear, where you can optionally add the new user to the group. Click the checkbox and then click add user; the user and their group should show in the table.
  9. Click back to the Groups tab; uncheck and re-check group members in the drawer and confirm updates display appropriately; do the same with queries; do the same with group membership on the Users tab

Checklist

  • Descriptive Pull Request title
  • Link to relevant issues
  • Provide necessary context for design reviewers
  • Ensure test coverage is above agreed upon threshold
  • Update documentation

Copy link

linear bot commented Mar 20, 2025

@katyasoup katyasoup force-pushed the kcd/que-181-persist-user-mgmt-changes branch from a434a66 to 30cfc4b Compare March 20, 2025 22:18
Copy link

github-actions bot commented Mar 20, 2025

Coverage report for ./query-connector

Caution

Test run failed

St.
Category Percentage Covered / Total
🟡 Statements
60.03% (-2.86% 🔻)
1637/2727
🔴 Branches
50.83% (-2.22% 🔻)
459/903
🟡 Functions
61.51% (-2.48% 🔻)
342/556
🟡 Lines
60.06% (-2.8% 🔻)
1540/2564
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟡
... / userManagementContainer.tsx
76.25% 82.61% 60% 74.67%
🟡
... / UserGroupsTable.tsx
64.86% 45.45% 46.67% 63.89%
🟢
... / userPermissionsTable.tsx
89.74% 75% 83.33% 89.47%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / usergroup-management.ts
45.55% (-38.56% 🔻)
26.15% (-16.15% 🔻)
53.33% (-33.33% 🔻)
45.3% (-38.39% 🔻)
🟡
... / user-management.ts
61.6% (-7.69% 🔻)
32.26% (-8.77% 🔻)
92.31% (+5.64% 🔼)
61.29% (-7.32% 🔻)
🟢
... / utils.ts
85.71% (-14.29% 🔻)
50% (-50% 🔻)
100% 100%
🔴
... / TeamQueryEditSection.tsx
29.87% (-47.63% 🔻)
7.14% (-20.63% 🔻)
33.33% (-25% 🔻)
28.95% (-47.98% 🔻)

Test suite run failed

Failed tests: 10/148. Failed suites: 2/20.
  ● User Group and Query Membership Tests › should add multiple users to a group

    TypeError: (0 , _usergroupmanagement.addMultipleUsersToGroup) is not a function

      115 |    */
      116 |   test("should add multiple users to a group", async () => {
    > 117 |     const result = await addMultipleUsersToGroup(TEST_GROUP_ID, [
          |                                                 ^
      118 |       TEST_USER_1_ID,
      119 |       TEST_USER_2_ID,
      120 |     ]);

      at Object.<anonymous> (src/app/tests/integration/usergroup-management.test.ts:117:49)

  ● User Group and Query Membership Tests › should add a single user to a group

    TypeError: (0 , _usergroupmanagement.addSingleUserToGroup) is not a function

      131 |
      132 |   test("should add a single user to a group", async () => {
    > 133 |     const result = await addSingleUserToGroup(TEST_GROUP_ID, TEST_USER_3_ID);
          |                                              ^
      134 |     expect(result.items.length).toBe(1);
      135 |     expect(result.items[0].id).toContain(TEST_USER_3_ID);
      136 |     expect(result?.items[0].userGroupMemberships?.[0].membership_id).toContain(

      at Object.<anonymous> (src/app/tests/integration/usergroup-management.test.ts:133:46)

  ● User Group and Query Membership Tests › should not add duplicate users to a group

    TypeError: (0 , _usergroupmanagement.addMultipleUsersToGroup) is not a function

      140 |
      141 |   test("should not add duplicate users to a group", async () => {
    > 142 |     await addMultipleUsersToGroup(TEST_GROUP_ID, [TEST_USER_1_ID]);
          |                                  ^
      143 |     const result = await addMultipleUsersToGroup(TEST_GROUP_ID, [
      144 |       TEST_USER_1_ID,
      145 |     ]);

      at Object.<anonymous> (src/app/tests/integration/usergroup-management.test.ts:142:34)

  ● User Group and Query Membership Tests › should remove multiple users from a group

    expect(received).toBe(expected) // Object.is equality

    Expected: 3
    Received: 0

      155 |       user.userGroupMemberships?.some((m) => m.is_member),
      156 |     );
    > 157 |     expect(members.length).toBe(3);
          |                            ^
      158 |
      159 |     const result = await removeMultipleUsersFromGroup(TEST_GROUP_ID, [
      160 |       TEST_USER_1_ID,

      at Object.toBe (src/app/tests/integration/usergroup-management.test.ts:157:28)

  ● User Group and Query Membership Tests › should remove a single user from a group

    TypeError: (0 , _usergroupmanagement.removeSingleUserFromGroup) is not a function

      185 |
      186 |   test("should remove a single user from a group", async () => {
    > 187 |     const result = await removeSingleUserFromGroup(
          |                                                   ^
      188 |       TEST_GROUP_ID,
      189 |       TEST_USER_3_ID,
      190 |     );

      at Object.<anonymous> (src/app/tests/integration/usergroup-management.test.ts:187:51)

  ● User Group and Query Membership Tests › should not remove a user that is not in the group

    TypeError: (0 , _usergroupmanagement.removeMultipleUsersFromGroup) is not a function

      207 |
      208 |   test("should not remove a user that is not in the group", async () => {
    > 209 |     const result = await removeMultipleUsersFromGroup(TEST_GROUP_ID, [
          |                                                      ^
      210 |       TEST_USER_3_ID,
      211 |     ]);
      212 |     expect(result).toEqual([]);

      at Object.<anonymous> (src/app/tests/integration/usergroup-management.test.ts:209:54)


  ● Super Admin view of Users Table › renders error message when no users are found

    expect(received).toMatchSnapshot()

    Snapshot name: `Super Admin view of Users Table renders error message when no users are found 1`

    New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.

    This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.

    Received:
    <body>
      <div>
        <div
          class="main-container__wide"
        >
          <div
            class="border-base border-bottom-1px margin-bottom-3"
          >
            <button
              class="usa-button--unstyled tab__active"
            >
              Users
            </button>
            <button
              class="usa-button--unstyled tab"
            >
              User groups
            </button>
          </div>
          <button
            class="usa-button styles.createQueryButton margin-bottom-3"
            data-testid="button"
            style="margin-left: 1px; background-color: rgb(0, 94, 162);"
            type="button"
          >
            Add user
          </button>
          <div
            class="empty-response"
          >
            No users found
          </div>
          <div>
            Modal Mock
          </div>
          <div
            class="drawer closed"
            data-testid="drawer-open-false"
            role="dialog"
          >
            <div
              class="drawerContent display-none"
            >
              <div
                class="drawerHeader"
              >
                <button
                  aria-label="Close drawer"
                  class="closeButton"
                  data-testid="close-drawer"
                >
                  <svg
                    aria-label="X icon indicating closure"
                    class="usa-icon usa-icon--size-3"
                    focusable="false"
                    height="1em"
                    role="img"
                    viewBox="0 0 24 24"
                    width="1em"
                    xmlns="http://www.w3.org/2000/svg"
                  >
                    <path
                      d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
                    />
                  </svg>
                </button>
                <h2
                  class="margin-0 padding-bottom-2"
                  data-testid="drawer-title"
                />
                <div>
                  <input
                    class="usa-input searchField"
                    data-testid="textInput"
                    id="searchFieldTemplate"
                    name="searchFieldTemplate"
                    placeholder="Search"
                    type="search"
                    value=""
                  />
                </div>
              </div>
              <div
                class="padding-top-2 drawerBody"
              >
                <div>
                  No queries assigned to this group.
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>

      47 |
      48 |     expect(screen.getByText("No users found")).toBeInTheDocument();
    > 49 |     expect(document.body).toMatchSnapshot();
         |                           ^
      50 |   });
      51 |
      52 |   it("renders table view after content is loaded", async () => {

      at Object.toMatchSnapshot (/home/runner/work/dibbs-query-connector/dibbs-query-connector/query-connector/src/app/(pages)../../../../../../userManagement/components/userManagementContainer/userManagementContainer.test.tsx:49:27)

  ● Super Admin view of Users Table › renders table view after content is loaded

    expect(received).toMatchSnapshot()

    Snapshot name: `Super Admin view of Users Table renders table view after content is loaded 1`

    New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.

    This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.

    Received:
    <body>
      <div>
        <div
          class="main-container__wide"
        >
          <div
            class="border-base border-bottom-1px margin-bottom-3"
          >
            <button
              class="usa-button--unstyled tab__active"
            >
              Users
            </button>
            <button
              class="usa-button--unstyled tab"
            >
              User groups
            </button>
          </div>
          <button
            class="usa-button styles.createQueryButton margin-bottom-3"
            data-testid="button"
            style="margin-left: 1px; background-color: rgb(0, 94, 162);"
            type="button"
          >
            Add user
          </button>
          <div
            class="customizeTableWrapper"
          >
            <table
              class="usa-table usa-table--borderless customizeTable"
              data-testid="table"
            >
              <thead>
                <tr>
                  <th>
                    Name
                  </th>
                  <th>
                    Permissions
                  </th>
                  <th>
                    User groups
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td
                    width="270"
                  >
                    Potter, Lily 
                  </td>
                  <td
                    class="roleDropdown"
                    width="270"
                  >
                    <label
                      class="usa-label usa-sr-only"
                      data-testid="label"
                      for="role-select-456"
                    >
                      User role
                    </label>
                    <select
                      class="usa-select"
                      data-testid="role-select-456"
                      id="role-select-456"
                    >
                      <option
                        value="Super Admin"
                      >
                        Super Admin
                      </option>
                      <option
                        selected=""
                        value="Admin"
                      >
                        Admin
                      </option>
                      <option
                        value="Standard"
                      >
                        Standard
                      </option>
                    </select>
                  </td>
                  <td>
                    <button
                      aria-description="Edit Order of the Phoenix members"
                      class="usa-button usa-button--unstyled margin-right-2 text-no-underline"
                      data-testid="button"
                      type="button"
                    >
                      Order of the Phoenix
                    </button>
                  </td>
                </tr>
                <tr>
                  <td
                    width="270"
                  >
                    Potter, Harry 
                  </td>
                  <td
                    class="roleDropdown"
                    width="270"
                  >
                    <label
                      class="usa-label usa-sr-only"
                      data-testid="label"
                      for="role-select-123"
                    >
                      User role
                    </label>
                    <select
                      class="usa-select"
                      data-testid="role-select-123"
                      id="role-select-123"
                    >
                      <option
                        selected=""
                        value="Super Admin"
                      >
                        Super Admin
                      </option>
                      <option
                        value="Admin"
                      >
                        Admin
                      </option>
                      <option
                        value="Standard"
                      >
                        Standard
                      </option>
                    </select>
                  </td>
                  <td>
                    --
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div>
            Modal Mock
          </div>
          <div
            class="drawer closed"
            data-testid="drawer-open-false"
            role="dialog"
          >
            <div
              class="drawerContent display-none"
            >
              <div
                class="drawerHeader"
              >
                <button
                  aria-label="Close drawer"
                  class="closeButton"
                  data-testid="close-drawer"
                >
                  <svg
                    aria-label="X icon indicating closure"
                    class="usa-icon usa-icon--size-3"
                    focusable="false"
                    height="1em"
                    role="img"
                    viewBox="0 0 24 24"
                    width="1em"
                    xmlns="http://www.w3.org/2000/svg"
                  >
                    <path
                      d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
                    />
                  </svg>
                </button>
                <h2
                  class="margin-0 padding-bottom-2"
                  data-testid="drawer-title"
                />
                <div>
                  <input
                    class="usa-input searchField"
                    data-testid="textInput"
                    id="searchFieldTemplate"
                    name="searchFieldTemplate"
                    placeholder="Search"
                    type="search"
                    value=""
                  />
                </div>
              </div>
              <div
                class="padding-top-2 drawerBody"
              >
                <div>
                  No queries assigned to this group.
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>

      65 |     });
      66 |
    > 67 |     expect(document.body).toMatchSnapshot();
         |                           ^
      68 |
      69 |     if (mockPermissionsTab.renderContent) {
      70 |       render(mockPermissionsTab.renderContent());

      at Object.toMatchSnapshot (/home/runner/work/dibbs-query-connector/dibbs-query-connector/query-connector/src/app/(pages)../../../../../../userManagement/components/userManagementContainer/userManagementContainer.test.tsx:67:27)

  ● Super Admin view of Users Table › renders table view after content is loaded

    expect(received).toMatchSnapshot()

    Snapshot name: `Super Admin view of Users Table renders table view after content is loaded 2`

    New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.

    This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.

    Received:
    <body>
      <div>
        <div
          class="main-container__wide"
        >
          <div
            class="border-base border-bottom-1px margin-bottom-3"
          >
            <button
              class="usa-button--unstyled tab__active"
            >
              Users
            </button>
            <button
              class="usa-button--unstyled tab"
            >
              User groups
            </button>
          </div>
          <button
            class="usa-button styles.createQueryButton margin-bottom-3"
            data-testid="button"
            style="margin-left: 1px; background-color: rgb(0, 94, 162);"
            type="button"
          >
            Add user
          </button>
          <div
            class="customizeTableWrapper"
          >
            <table
              class="usa-table usa-table--borderless customizeTable"
              data-testid="table"
            >
              <thead>
                <tr>
                  <th>
                    Name
                  </th>
                  <th>
                    Permissions
                  </th>
                  <th>
                    User groups
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td
                    width="270"
                  >
                    Potter, Lily 
                  </td>
                  <td
                    class="roleDropdown"
                    width="270"
                  >
                    <label
                      class="usa-label usa-sr-only"
                      data-testid="label"
                      for="role-select-456"
                    >
                      User role
                    </label>
                    <select
                      class="usa-select"
                      data-testid="role-select-456"
                      id="role-select-456"
                    >
                      <option
                        value="Super Admin"
                      >
                        Super Admin
                      </option>
                      <option
                        selected=""
                        value="Admin"
                      >
                        Admin
                      </option>
                      <option
                        value="Standard"
                      >
                        Standard
                      </option>
                    </select>
                  </td>
                  <td>
                    <button
                      aria-description="Edit Order of the Phoenix members"
                      class="usa-button usa-button--unstyled margin-right-2 text-no-underline"
                      data-testid="button"
                      type="button"
                    >
                      Order of the Phoenix
                    </button>
                  </td>
                </tr>
                <tr>
                  <td
                    width="270"
                  >
                    Potter, Harry 
                  </td>
                  <td
                    class="roleDropdown"
                    width="270"
                  >
                    <label
                      class="usa-label usa-sr-only"
                      data-testid="label"
                      for="role-select-123"
                    >
                      User role
                    </label>
                    <select
                      class="usa-select"
                      data-testid="role-select-123"
                      id="role-select-123"
                    >
                      <option
                        selected=""
                        value="Super Admin"
                      >
                        Super Admin
                      </option>
                      <option
                        value="Admin"
                      >
                        Admin
                      </option>
                      <option
                        value="Standard"
                      >
                        Standard
                      </option>
                    </select>
                  </td>
                  <td>
                    --
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div>
            Modal Mock
          </div>
          <div
            class="drawer closed"
            data-testid="drawer-open-false"
            role="dialog"
          >
            <div
              class="drawerContent display-none"
            >
              <div
                class="drawerHeader"
              >
                <button
                  aria-label="Close drawer"
                  class="closeButton"
                  data-testid="close-drawer"
                >
                  <svg
                    aria-label="X icon indicating closure"
                    class="usa-icon usa-icon--size-3"
                    focusable="false"
                    height="1em"
                    role="img"
                    viewBox="0 0 24 24"
                    width="1em"
                    xmlns="http://www.w3.org/2000/svg"
                  >
                    <path
                      d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
                    />
                  </svg>
                </button>
                <h2
                  class="margin-0 padding-bottom-2"
                  data-testid="drawer-title"
                />
                <div>
                  <input
                    class="usa-input searchField"
                    data-testid="textInput"
                    id="searchFieldTemplate"
                    name="searchFieldTemplate"
                    placeholder="Search"
                    type="search"
                    value=""
                  />
                </div>
              </div>
              <div
                class="padding-top-2 drawerBody"
              >
                <div>
                  No queries assigned to this group.
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div>
        <div
          class="customizeTableWrapper"
        >
          <table
            class="usa-table usa-table--borderless customizeTable"
            data-testid="table"
          >
            <thead>
              <tr>
                <th>
                  Name
                </th>
                <th>
                  Permissions
                </th>
                <th>
                  User groups
                </th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td
                  width="270"
                >
                  Potter, Lily 
                </td>
                <td
                  class="roleDropdown"
                  width="270"
                >
                  <label
                    class="usa-label usa-sr-only"
                    data-testid="label"
                    for="role-select-456"
                  >
                    User role
                  </label>
                  <select
                    class="usa-select"
                    data-testid="role-select-456"
                    id="role-select-456"
                  >
                    <option
                      value="Super Admin"
                    >
                      Super Admin
                    </option>
                    <option
                      selected=""
                      value="Admin"
                    >
                      Admin
                    </option>
                    <option
                      value="Standard"
                    >
                      Standard
                    </option>
                  </select>
                </td>
                <td>
                  <button
                    aria-description="Edit Order of the Phoenix members"
                    class="usa-button usa-button--unstyled margin-right-2 text-no-underline"
                    data-testid="button"
                    type="button"
                  >
                    Order of the Phoenix
                  </button>
                </td>
              </tr>
              <tr>
                <td
                  width="270"
                >
                  Potter, Harry 
                </td>
                <td
                  class="roleDropdown"
                  width="270"
                >
                  <label
                    class="usa-label usa-sr-only"
                    data-testid="label"
                    for="role-select-123"
                  >
                    User role
                  </label>
                  <select
                    class="usa-select"
                    data-testid="role-select-123"
                    id="role-select-123"
                  >
                    <option
                      selected=""
                      value="Super Admin"
                    >
                      Super Admin
                    </option>
                    <option
                      value="Admin"
                    >
                      Admin
                    </option>
                    <option
                      value="Standard"
                    >
                      Standard
                    </option>
                  </select>
                </td>
                <td>
                  --
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </body>

      73 |     expect(document.body).toHaveTextContent("Potter, Harry");
      74 |     expect(document.body).toHaveTextContent("Order of the Phoenix");
    > 75 |     expect(document.body).toMatchSnapshot();
         |                           ^
      76 |
      77 |     jest.restoreAllMocks();
      78 |   });

      at Object.toMatchSnapshot (/home/runner/work/dibbs-query-connector/dibbs-query-connector/query-connector/src/app/(pages)../../../../../../userManagement/components/userManagementContainer/userManagementContainer.test.tsx:75:27)

  ● Super Admin view of Users Table › renders content on tab click

    expect(received).toMatchSnapshot()

    Snapshot name: `Super Admin view of Users Table renders content on tab click 1`

    New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.

    This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.

    Received:
    <body>
      <div>
        <div
          class="main-container__wide"
        >
          <div
            class="border-base border-bottom-1px margin-bottom-3"
          >
            <button
              class="usa-button--unstyled tab__active"
            >
              Users
            </button>
            <button
              class="usa-button--unstyled tab"
            >
              User groups
            </button>
          </div>
          <button
            class="usa-button styles.createQueryButton margin-bottom-3"
            data-testid="button"
            style="margin-left: 1px; background-color: rgb(0, 94, 162);"
            type="button"
          >
            Add user
          </button>
          <div
            class="customizeTableWrapper"
          >
            <table
              class="usa-table usa-table--borderless customizeTable"
              data-testid="table"
            >
              <thead>
                <tr>
                  <th>
                    Name
                  </th>
                  <th>
                    Permissions
                  </th>
                  <th>
                    User groups
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td
                    width="270"
                  >
                    Potter, Lily 
                  </td>
                  <td
                    class="roleDropdown"
                    width="270"
                  >
                    <label
                      class="usa-label usa-sr-only"
                      data-testid="label"
                      for="role-select-456"
                    >
                      User role
                    </label>
                    <select
                      class="usa-select"
                      data-testid="role-select-456"
                      id="role-select-456"
                    >
                      <option
                        value="Super Admin"
                      >
                        Super Admin
                      </option>
                      <option
                        selected=""
                        value="Admin"
                      >
                        Admin
                      </option>
                      <option
                        value="Standard"
                      >
                        Standard
                      </option>
                    </select>
                  </td>
                  <td>
                    <button
                      aria-description="Edit Order of the Phoenix members"
                      class="usa-button usa-button--unstyled margin-right-2 text-no-underline"
                      data-testid="button"
                      type="button"
                    >
                      Order of the Phoenix
                    </button>
                  </td>
                </tr>
                <tr>
                  <td
                    width="270"
                  >
                    Potter, Harry 
                  </td>
                  <td
                    class="roleDropdown"
                    width="270"
                  >
                    <label
                      class="usa-label usa-sr-only"
                      data-testid="label"
                      for="role-select-123"
                    >
                      User role
                    </label>
                    <select
                      class="usa-select"
                      data-testid="role-select-123"
                      id="role-select-123"
                    >
                      <option
                        selected=""
                        value="Super Admin"
                      >
                        Super Admin
                      </option>
                      <option
                        value="Admin"
                      >
                        Admin
                      </option>
                      <option
                        value="Standard"
                      >
                        Standard
                      </option>
                    </select>
                  </td>
                  <td>
                    --
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div>
            Modal Mock
          </div>
          <div
            class="drawer closed"
            data-testid="drawer-open-false"
            role="dialog"
          >
            <div
              class="drawerContent display-none"
            >
              <div
                class="drawerHeader"
              >
                <button
                  aria-label="Close drawer"
                  class="closeButton"
                  data-testid="close-drawer"
                >
                  <svg
                    aria-label="X icon indicating closure"
                    class="usa-icon usa-icon--size-3"
                    focusable="false"
                    height="1em"
                    role="img"
                    viewBox="0 0 24 24"
                    width="1em"
                    xmlns="http://www.w3.org/2000/svg"
                  >
                    <path
                      d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
                    />
                  </svg>
                </button>
                <h2
                  class="margin-0 padding-bottom-2"
                  data-testid="drawer-title"
                />
                <div>
                  <input
                    class="usa-input searchField"
                    data-testid="textInput"
                    id="searchFieldTemplate"
                    name="searchFieldTemplate"
                    placeholder="Search"
                    type="search"
                    value=""
                  />
                </div>
              </div>
              <div
                class="padding-top-2 drawerBody"
              >
                <div>
                  No queries assigned to this group.
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>

       98 |     });
       99 |
    > 100 |     expect(document.body).toMatchSnapshot();
          |                           ^
      101 |     const usersTab = document.getElementsByClassName("tab__active")[0];
      102 |     expect(usersTab).toHaveTextContent("Users");
      103 |     expect(document.body).toHaveTextContent("Permissions");

      at Object.toMatchSnapshot (/home/runner/work/dibbs-query-connector/dibbs-query-connector/query-connector/src/app/(pages)../../../../../../userManagement/components/userManagementContainer/userManagementContainer.test.tsx:100:27)

  ● Super Admin view of Users Table › renders content on tab click

    expect(received).toMatchSnapshot()

    Snapshot name: `Super Admin view of Users Table renders content on tab click 2`

    New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.

    This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.

    Received:
    <body>
      <div>
        <div
          class="main-container__wide"
        >
          <div
            class="border-base border-bottom-1px margin-bottom-3"
          >
            <button
              class="usa-button--unstyled tab"
            >
              Users
            </button>
            <button
              class="usa-button--unstyled tab__active"
            >
              User groups
            </button>
          </div>
          <button
            class="usa-button styles.createQueryButton margin-bottom-3"
            data-testid="button"
            style="margin-left: 1px; background-color: rgb(0, 94, 162);"
            type="button"
          >
            Create group
          </button>
          <div
            class="customizeTableWrapper"
          >
            <table
              class="usa-table usa-table--borderless customizeTable"
              data-testid="table"
            >
              <thead>
                <tr>
                  <th>
                    Name
                  </th>
                  <th>
                    Members
                  </th>
                  <th>
                    Assigned queries
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td
                    width="270"
                  >
                    Hogwarts
                  </td>
                  <td>
                    <button
                      aria-description="Edit Hogwarts members"
                      class="usa-button usa-button--unstyled drawerButton text-no-underline"
                      data-testid="edit-member-list-0"
                      type="button"
                    >
                      1 member
                    </button>
                  </td>
                  <td>
                    <button
                      aria-description="Edit Hogwarts queries"
                      class="usa-button usa-button--unstyled text-no-underline"
                      data-testid="edit-query-list-0"
                      type="button"
                    >
                      0 queries
                    </button>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div>
            Modal Mock
          </div>
          <div
            class="drawer closed"
            data-testid="drawer-open-false"
            role="dialog"
          >
            <div
              class="drawerContent display-none"
            >
              <div
                class="drawerHeader"
              >
                <button
                  aria-label="Close drawer"
                  class="closeButton"
                  data-testid="close-drawer"
                >
                  <svg
                    aria-label="X icon indicating closure"
                    class="usa-icon usa-icon--size-3"
                    focusable="false"
                    height="1em"
                    role="img"
                    viewBox="0 0 24 24"
                    width="1em"
                    xmlns="http://www.w3.org/2000/svg"
                  >
                    <path
                      d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
                    />
                  </svg>
                </button>
                <h2
                  class="margin-0 padding-bottom-2"
                  data-testid="drawer-title"
                />
                <div>
                  <input
                    class="usa-input searchField"
                    data-testid="textInput"
                    id="searchFieldTemplate"
                    name="searchFieldTemplate"
                    placeholder="Search"
                    type="search"
                    value=""
                  />
                </div>
              </div>
              <div
                class="padding-top-2 drawerBody"
              >
                <div>
                  No queries assigned to this group.
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>

      110 |
      111 |     expect(document.body).toHaveTextContent("Assigned queries");
    > 112 |     expect(document.body).toMatchSnapshot();
          |                           ^
      113 |
      114 |     jest.restoreAllMocks();
      115 |   });

      at Object.toMatchSnapshot (/home/runner/work/dibbs-query-connector/dibbs-query-connector/query-connector/src/app/(pages)../../../../../../userManagement/components/userManagementContainer/userManagementContainer.test.tsx:112:27)

  ● Admin view of Users Table › renders error message when no user groups are found

    expect(received).toMatchSnapshot()

    Snapshot name: `Admin view of Users Table renders error message when no user groups are found 1`

    New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.

    This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.

    Received:
    <body>
      <div>
        <div
          class="main-container__wide"
        >
          <div
            class="empty-response"
          >
            <div
              class="empty-response display-flex flex-column flex-align-start"
            >
              No user groups found
              <button
                class="usa-button styles.createQueryButton margin-bottom-3"
                data-testid="button"
                style="margin-left: 1px; margin-top: 1.5rem; background-color: rgb(0, 94, 162);"
                type="button"
              >
                Create group
              </button>
            </div>
          </div>
          <div>
            Modal Mock
          </div>
          <div
            class="drawer closed"
            data-testid="drawer-open-false"
            role="dialog"
          >
            <div
              class="drawerContent display-none"
            >
              <div
                class="drawerHeader"
              >
                <button
                  aria-label="Close drawer"
                  class="closeButton"
                  data-testid="close-drawer"
                >
                  <svg
                    aria-label="X icon indicating closure"
                    class="usa-icon usa-icon--size-3"
                    focusable="false"
                    height="1em"
                    role="img"
                    viewBox="0 0 24 24"
                    width="1em"
                    xmlns="http://www.w3.org/2000/svg"
                  >
                    <path
                      d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
                    />
                  </svg>
                </button>
                <h2
                  class="margin-0 padding-bottom-2"
                  data-testid="drawer-title"
                />
                <div>
                  <input
                    class="usa-input searchField"
                    data-testid="textInput"
                    id="searchFieldTemplate"
                    name="searchFieldTemplate"
                    placeholder="Search"
                    type="search"
                    value=""
                  />
                </div>
              </div>
              <div
                class="padding-top-2 drawerBody"
              >
                <div>
                  No queries assigned to this group.
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>

      130 |
      131 |     expect(screen.getByText("No user groups found")).toBeInTheDocument();
    > 132 |     expect(document.body).toMatchSnapshot();
          |                           ^
      133 |     jest.restoreAllMocks();
      134 |   });
      135 | });

      at Object.toMatchSnapshot (/home/runner/work/dibbs-query-connector/dibbs-query-connector/query-connector/src/app/(pages)../../../../../../userManagement/components/userManagementContainer/userManagementContainer.test.tsx:132:27)

Report generated by 🧪jest coverage report action from d7e889b

@katyasoup katyasoup force-pushed the kcd/que-181-persist-user-mgmt-changes branch from d1fa84f to 1133a81 Compare March 20, 2025 23:03
@katyasoup katyasoup force-pushed the kcd/que-181-persist-user-mgmt-changes branch from 1133a81 to 3942065 Compare March 20, 2025 23:05
@katyasoup katyasoup force-pushed the kcd/que-181-persist-user-mgmt-changes branch from 72fcfa1 to 887e091 Compare March 21, 2025 16:43
@katyasoup katyasoup changed the title Kcd/que 181 persist user mgmt changes Toggle User and Query assignment from Drawer/Modal Mar 21, 2025
@katyasoup katyasoup marked this pull request as ready for review March 21, 2025 17:26
@akintner
Copy link
Collaborator

FYI - I can't find the "Hogwart's Staff" reference we just saw in VSCode in any of the files here. Which is...weird but ok 🥇

const result = await addQueriesToGroup(TEST_GROUP_ID, [TEST_QUERY_ID]);
expect(result).toEqual([]);
});
// test("should add queries to a group", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

did we mean to uncomment or delete these?

Copy link
Collaborator

@johanna-skylight johanna-skylight left a comment

Choose a reason for hiding this comment

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

Good work @katyasoup ! Most of the functionality works as expected. I found just one issue while testing in local. In the add group modal I noticed that after entering a group name and clicking next the group gets created in the DB but this is not updated in the groups table.

I have left a few comments on the code about some small naming changes.

Thank you :D

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.

Persist changes to User Groups in the database
4 participants