All files / components/CATME CATMEAuditResults.jsx

100% Statements 7/7
100% Branches 9/9
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120              9x 9x   9x 4x             5x                                             7x                                                                                               7x                                                            
import React from "react";
import { Alert, Table } from "react-bootstrap";
 
export default function CATMEAuditResults({
  results,
  testIdPrefix = "CATMEAuditResults",
}) {
  const studentsToUpdate = results.studentsToUpdate;
  const studentsToDrop = results.studentsToDrop;
 
  if (studentsToUpdate.length === 0 && studentsToDrop.length === 0) {
    return (
      <Alert variant="success" data-testid={`${testIdPrefix}-up-to-date`}>
        CATME is up to date with the Frontiers roster. No changes are needed.
      </Alert>
    );
  }
 
  return (
    <div data-testid={`${testIdPrefix}-results`}>
      <h6 className="mt-3" data-testid={`${testIdPrefix}-drop-header`}>
        Remove from CATME ({studentsToDrop.length})
      </h6>
      <p className="text-muted mb-1">
        These students are in the CATME file but are not currently enrolled in
        Frontiers.
      </p>
      {studentsToDrop.length === 0 ? (
        <p data-testid={`${testIdPrefix}-drop-none`}>No students to remove.</p>
      ) : (
        <Table striped bordered size="sm" data-testid={`${testIdPrefix}-drop`}>
          <thead>
            <tr>
              <th>Student ID</th>
              <th>Name</th>
              <th>Email</th>
              <th>Section</th>
            </tr>
          </thead>
          <tbody>
            {studentsToDrop.map((student, index) => (
              <tr key={index}>
                <td data-testid={`${testIdPrefix}-drop-row-${index}-studentId`}>
                  {student.studentId}
                </td>
                <td data-testid={`${testIdPrefix}-drop-row-${index}-name`}>
                  {student.name}
                </td>
                <td data-testid={`${testIdPrefix}-drop-row-${index}-email`}>
                  {student.email}
                </td>
                <td data-testid={`${testIdPrefix}-drop-row-${index}-section`}>
                  {student.section}
                </td>
              </tr>
            ))}
          </tbody>
        </Table>
      )}
 
      <h6 className="mt-3" data-testid={`${testIdPrefix}-update-header`}>
        Update in CATME ({studentsToUpdate.length})
      </h6>
      <p className="text-muted mb-1">
        These students are in CATME, but their name or section does not match
        Frontiers.
      </p>
      {studentsToUpdate.length === 0 ? (
        <p data-testid={`${testIdPrefix}-update-none`}>
          No students to update.
        </p>
      ) : (
        <Table
          striped
          bordered
          size="sm"
          data-testid={`${testIdPrefix}-update`}
        >
          <thead>
            <tr>
              <th>Student ID</th>
              <th>Name</th>
              <th>Field</th>
              <th>Currently in CATME</th>
              <th>Should be</th>
            </tr>
          </thead>
          <tbody>
            {studentsToUpdate.map((update, index) => (
              <tr key={index}>
                <td
                  data-testid={`${testIdPrefix}-update-row-${index}-studentId`}
                >
                  {update.studentId}
                </td>
                <td data-testid={`${testIdPrefix}-update-row-${index}-name`}>
                  {update.name}
                </td>
                <td data-testid={`${testIdPrefix}-update-row-${index}-field`}>
                  {update.field}
                </td>
                <td
                  data-testid={`${testIdPrefix}-update-row-${index}-oldValue`}
                >
                  {update.oldValue}
                </td>
                <td
                  data-testid={`${testIdPrefix}-update-row-${index}-newValue`}
                >
                  {update.newValue}
                </td>
              </tr>
            ))}
          </tbody>
        </Table>
      )}
    </div>
  );
}