Users managing multiple companies need to switch contexts quickly, similar to Slack/Discord workspace switching.
Specific
As a user, I want to switch between companies without logging out.
Also:
AAA Scenarios
Scenario 1 — Basic UI Switch (top-right button)
Arrange
- User is authenticated and belongs to companies A and B.
- Current company context = A.
- User has at least one resource visible (e.g., invoices) scoped to company A.
Act
- User clicks the company name in the top-right corner and selects company B.
Assert
Scenario 2 — Modal Company Picker (many companies)
Arrange
- User belongs to 10 companies.
- Company switcher shows a modal with the list.
- User has permissions on a subset of companies.
Act
- User opens the modal, selects a company the user has access to, and confirms.
Assert
Scenario 3 — Edit / Quick-actions from Picker
Arrange
- User has "manage company" permission for company C.
- Picker shows an edit button next to company C.
Act
- User clicks the edit button in the picker for company C.
Assert
Scenario 4 — URL Slug Switch (direct navigation)
Arrange
- Route format includes company slug:
/companies/{slug}/invoices.
- User is authenticated and belongs to company D.
- Browser address bar currently shows
/companies/company-x/invoices.
Act
- User types
/companies/company-d/invoices into the address bar and navigates.
Assert
Scenario 5 — Attempted Unauthorized Slug Switch
Arrange
- User belongs to companies E and F only.
- The user attempts to access
/companies/company-g/... (company G not in their list).
Act
- User navigates to the URL with company G’s slug.
Assert
Scenario 6 — Persistence Across Tabs & Reloads
Arrange
- User switches to company H in tab A.
- User opens tab B previously at a different company context.
Act
- User reloads tab B after switching in tab A.
Assert
Scenario 7 — Permissions & Feature-Gating After Switch
Arrange
- User has role changes between companies (e.g., admin in I, viewer in J).
- Both companies have resources with different accessible features.
Act
- User switches from company I to company J.
Assert
Scenario 8 — Edge Case: Pending Background Syncs / Long-running Jobs
Arrange
- User triggers a long-running sync job in company K (background).
- User attempts to switch to company L during the job.
Act
- User switches context while background job for company K is still running.
Assert
Notes (non-assertions)
- Ensure server-side authorization is the source-of-truth for all switches (client UI should not be the only guard).
- Log company switch events (user, from → to, timestamp) for audits.
- Consider UX for “default company” and initial onboarding choice.
- Decide and document session vs per-tab persistence strategy and implement consistent behavior.
Users managing multiple companies need to switch contexts quickly, similar to Slack/Discord workspace switching.
Specific
As a user, I want to switch between companies without logging out.
Also:
AAA Scenarios
Scenario 1 — Basic UI Switch (top-right button)
Arrange
Act
Assert
Scenario 2 — Modal Company Picker (many companies)
Arrange
Act
Assert
Scenario 3 — Edit / Quick-actions from Picker
Arrange
Act
Assert
Scenario 4 — URL Slug Switch (direct navigation)
Arrange
/companies/{slug}/invoices./companies/company-x/invoices.Act
/companies/company-d/invoicesinto the address bar and navigates.Assert
Scenario 5 — Attempted Unauthorized Slug Switch
Arrange
/companies/company-g/...(company G not in their list).Act
Assert
Scenario 6 — Persistence Across Tabs & Reloads
Arrange
Act
Assert
Scenario 7 — Permissions & Feature-Gating After Switch
Arrange
Act
Assert
Scenario 8 — Edge Case: Pending Background Syncs / Long-running Jobs
Arrange
Act
Assert
Notes (non-assertions)