Skip to main content

Units — Test Cases

Manual acceptance test cases for the unit flows. See Units concept, QR Codes concept, and the unit guides for context.


TC-UNIT-001 — Add a unit and assign it to a customer

Verifies: Add a Unit

Preconditions:

  • Logged in as Office.
  • A test customer exists (use the one from TC-CUST-001).
  • At least one device model exists.

Steps:

  1. Navigate to Units -> Add Unit.
  2. Pick the test customer in Customer.
  3. Pick a device model in Model.
  4. Enter Serial Number: TC-UNIT-001-SN.
  5. Enter Friendly Name: Test AC #1.
  6. Set Installed Date to today.
  7. Set Warranty (months) to 60.
  8. Set Maintenance Frequency to Quarterly.
  9. Select Save.

Expected:

  • Unit is created and appears in the units list.
  • Editing the unit shows the warranty expires 60 months after the install date.
  • The customer's edit page lists this unit in its units section.

TC-UNIT-002 — Warranty expiry recomputes when install date changes

Verifies: Units concept

Preconditions:

  • The unit from TC-UNIT-001 exists with install date today and 60-month warranty.

Steps:

  1. Open the unit's edit page.
  2. Change Installed Date to one year ago.
  3. Select Save.
  4. Reopen the unit's edit page.

Expected:

  • Displayed warranty expiry is now ~48 months in the future (60 months minus 1 year).
  • No DB column was directly updated; the value is computed from installed_at + warranty_months.

TC-UNIT-003 — Maintenance frequency none excludes from due list

Verifies: Units concept

Preconditions:

  • Logged in as Office.

Steps:

  1. Create a new unit with Maintenance Frequency left at the default (the -- Select -- empty state).
  2. Note the unit's ID.
  3. Navigate to the maintenance-due report (or filter the units list by "due for maintenance").

Expected:

  • The unit does not appear in the due list, regardless of maintained_at value.
  • A unit with frequency set (e.g. Every month) and a stale maintained_at does appear.

TC-UNIT-004 — Generate a QR code for an existing unit

Verifies: Generate a QR Code, QR Codes concept

Preconditions:

  • The unit from TC-UNIT-001 exists without a QR code yet.

Steps:

  1. Open the unit's edit page.
  2. Select the Generate QR Code action.

Expected:

  • The unit gets a qr_code_guid (a UUID).
  • The QR image renders on the page.
  • Visiting /u/<guid> in an incognito browser opens the public unit page (no login required) and shows the friendly name and customer.
  • The public page exposes no costs, history, or technician info.

TC-UNIT-005 — Print a batch of blank QR labels

Verifies: Print Blank QR Labels

Preconditions:

  • Logged in as Office.

Steps:

  1. Navigate to Units -> Print Blank QR Codes.
  2. Set quantity to 5.
  3. Generate the print sheet.

Expected:

  • A printable sheet renders with 5 distinct QR codes.
  • Each code's URL (/u/<guid>) returns a not-found response if opened directly in a browser before assignment.
  • The codes do not appear on any unit until a tech scans them from inside TuffOps and assigns them to a unit.

TC-UNIT-006 — Link two units belonging to the same customer

Verifies: Link Related Units, Units concept

Preconditions:

  • Two units exist, both belonging to the same customer. Call them A and B.
  • Logged in as Office (with units.edit).

Steps:

  1. Open unit A's edit page.
  2. Scroll to the Linked Units section.
  3. In the dropdown, pick unit B.
  4. Select Link.

Expected:

  • Page reloads. Unit B appears in unit A's Linked Units list.
  • Open unit B's edit page — unit A appears in unit B's Linked Units list.
  • The units index shows a link group icon next to each.

TC-UNIT-007 — Linking units across customers is rejected (server-side)

Verifies: Link Related Units, commit d5e4a8e and 0a1a2dd

Preconditions:

  • Two units exist, each belonging to a different customer. Call them A and B.
  • Logged in as Office (with units.edit).

Steps:

  1. Open unit A's edit page.
  2. Even though B should not appear in the dropdown, attempt the request directly (browser dev tools, or via a proxy) by POSTing to /units/<A-id>/tie with tied_unit_id=<B-id>.

Expected:

  • Response is a redirect with a danger flash message: "Linked units must belong to the same customer."
  • No row is created in unit_ties.
  • Neither unit's edit page shows the other in Linked Units.

TC-UNIT-008 — Tying a unit to itself is rejected

Verifies: Link Related Units

Preconditions:

  • Unit A exists.
  • Logged in as Office.

Steps:

  1. Submit the tie form for unit A with tied_unit_id equal to A's own ID.

Expected:

  • Response is a redirect with a danger flash message: "A unit cannot be linked to itself."
  • No row is created in unit_ties.

TC-UNIT-009 — Tech without units.edit cannot tie units

Verifies: Permission gate added in commit 0a1a2dd

Preconditions:

  • Two units exist, same customer. Call them A and B.
  • Logged in as a Tech (no units.edit permission).

Steps:

  1. Attempt to POST /units/<A-id>/tie with tied_unit_id=<B-id>.
  2. Attempt to DELETE /units/<A-id>/untie/<B-id>.

Expected:

  • Both requests return HTTP 403.
  • No unit_ties row is added or removed.

TC-UNIT-010 — Transitive linking propagates within the same customer

Verifies: Units concept

Preconditions:

  • Three units exist, all belonging to the same customer. Call them A, B, C.
  • Logged in as Office.

Steps:

  1. Tie A to B.
  2. Tie B to C.

Expected:

  • A's Linked Units shows both B and C.
  • B's Linked Units shows both A and C.
  • C's Linked Units shows both A and B.
  • The units index shows a group of size 3 for each.