tenancies
25 requirements and 119 scenarios in openspec/specs/tenancies/spec.md. A scenario’s test is test('<scenario>') inside describe('<requirement>'), in Vitest or Playwright.
Adding a tenant
Section titled “Adding a tenant”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Adding an open-ended tenancy | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Adding a fixed-term tenancy | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Contract made defaults to the start date | Vitest src/features/tenancies/TenancyForm.test.tsx |
| Adding an earlier tenancy with its ending | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| The ending of an earlier tenancy follows the notice rules | Vitest src/features/tenancies/tenancies.server.test.ts |
| The ending can’t be recorded for a tenancy that hasn’t started | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t add a tenant | Vitest src/features/tenancies/tenancies.server.test.ts |
Tenancy dates and details
Section titled “Tenancy dates and details”No Playwright test: these are server-side rules and pure date calculations; Vitest covers them, and “Adding a tenant” and “Ending a tenancy” show reasons in the browser.
The rent of a new tenancy
Section titled “The rent of a new tenancy”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| The form suggests the previous tenancy’s rent | Vitest src/features/tenancies/TenancyForm.test.tsx |
| The first tenancy’s rent field is empty | Vitest src/features/tenancies/TenancyForm.test.tsx |
| The rent starts on the tenancy’s start day | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| The rent is required | Vitest src/features/tenancies/TenancyForm.test.tsx |
| An earlier tenancy gets its own rent | Vitest src/features/tenancies/tenancies.server.test.ts |
The tenancy page
Section titled “The tenancy page”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Opening the tenancy page from the details page | Playwright e2e/tenancies.spec.ts |
| The rent card with its changes | Vitest src/features/tenancies/TenancyPage.test.tsx |
| The occupants and the fees with the month’s total | Playwright e2e/tenancies.spec.ts |
| A tenancy without fees | Playwright e2e/tenancies.spec.ts |
| Other tenancies show their latest rent | Vitest src/features/tenancies/TenancyPage.test.tsx |
| A vacant flat offers to add a tenant | Playwright e2e/tenancies.spec.ts |
| Adding an earlier tenancy from the tenancy page | Playwright e2e/tenancies.spec.ts |
| Correcting an earlier tenancy from the list | Playwright e2e/tenancies.spec.ts |
| A tenancy that hasn’t started can’t be ended | Playwright e2e/tenancies.spec.ts |
| A member sees the tenancy but can’t change it | Playwright e2e/tenancies.spec.ts |
Tenancy statuses
Section titled “Tenancy statuses”No Playwright test: a pure calculation from a tenancy’s dates and today; Vitest covers it, and the tenancy page and the flats list show it in the browser tests of “The tenancy page”, “Ending a tenancy” and “Listing flats”.
| Scenario | Tests |
|---|---|
| Statuses through an ended tenancy | Vitest src/features/tenancies/status.test.ts |
| A fixed-term tenancy shows when it ends | Vitest src/features/tenancies/status.test.ts |
Notice periods
Section titled “Notice periods”No Playwright test: a pure calculation; Vitest covers it, and “Ending a tenancy” shows the suggested date in the browser.
| Scenario | Tests |
|---|---|
| The tenant’s notice ends at the end of the next month | Vitest src/features/tenancies/notice.test.ts |
| Landlord’s notice under an older contract after a year | Vitest src/features/tenancies/notice.test.ts |
| Landlord’s notice under an older contract within the first year | Vitest src/features/tenancies/notice.test.ts |
| Landlord’s notice under a newer contract within two years | Vitest src/features/tenancies/notice.test.ts |
| Landlord’s notice under a newer contract after two years | Vitest src/features/tenancies/notice.test.ts |
Ending a tenancy
Section titled “Ending a tenancy”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| The tenant gives notice | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| A mid-month last rent day is accepted for the tenant’s notice | Vitest src/features/tenancies/notice.test.ts |
| The landlord’s notice can’t be shorter than the law allows | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/notice.test.ts |
| An agreed ending can be on any day after the notice | Vitest src/features/tenancies/notice.test.ts |
| A notice date in the future is refused | Vitest src/features/tenancies/notice.test.ts |
| A member can’t end a tenancy | Vitest src/features/tenancies/tenancies.server.test.ts |
Ending a fixed-term tenancy early
Section titled “Ending a fixed-term tenancy early”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Ending a fixed term by agreement | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Another legal ground ends a fixed term early | Vitest src/features/tenancies/notice.test.ts |
| Notice on a fixed term is refused | Vitest src/features/tenancies/notice.test.ts |
Cancelling an ending
Section titled “Cancelling an ending”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Cancelling the tenant’s notice | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Cancelling after the last rent day is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| Cancelling is refused when a new tenancy follows | Vitest src/features/tenancies/tenancies.server.test.ts |
| A later tenancy after the original term doesn’t prevent cancelling | Vitest src/features/tenancies/tenancies.server.test.ts |
Correcting a tenancy
Section titled “Correcting a tenancy”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Correcting the tenant’s phone number | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Changing an earlier tenancy’s rent from its correction form | Playwright e2e/tenancies.spec.ts |
| A correction can’t make tenancies overlap | Vitest src/features/tenancies/tenancies.server.test.ts |
| A correction must fit a recorded ending | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t correct a tenancy | Vitest src/features/tenancies/tenancies.server.test.ts |
Removing a tenancy that hasn’t started
Section titled “Removing a tenancy that hasn’t started”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Removing a tenancy whose tenant withdrew | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| A started tenancy can’t be removed | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t remove a tenancy | Vitest src/features/tenancies/tenancies.server.test.ts |
The rent of a tenancy
Section titled “The rent of a tenancy”No Playwright test: these are rules for stored periods and pure calculations; Vitest covers them with the functions and the repository, and the browser tests of “Changing a tenancy’s rent” and “The tenancy page” use them.
| Scenario | Tests |
|---|---|
| The first rent starts on the tenancy’s start day | Vitest src/features/tenancies/rent.test.ts |
| A change ends the previous rent period the day before | Vitest src/features/tenancies/tenancy.repository.server.test.ts |
| Each tenancy has its own rent | Vitest src/features/tenancies/rent.test.ts |
Changing a tenancy’s rent
Section titled “Changing a tenancy’s rent”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Raising the rent from March | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| The form shows the difference | Vitest src/features/tenancies/TenancyRentForm.test.tsx |
| Correcting the first rent on the tenancy’s start | Vitest src/features/tenancies/tenancies.server.test.ts |
| A mid-month date other than the start is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| A date before the tenancy is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| A date after the tenancy is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| A rent date before the latest change is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| Filling the first months of a migrated tenancy | Vitest src/features/tenancies/tenancies.server.test.ts |
| Correcting an earlier rent period | Vitest src/features/tenancies/tenancies.server.test.ts |
| Another flat’s tenancy is not found | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t change the rent | Vitest src/features/tenancies/tenancies.server.test.ts |
Undoing a tenancy’s rent change
Section titled “Undoing a tenancy’s rent change”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Undoing a rent increase | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| The first rent can’t be undone | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t undo a rent change | Vitest src/features/tenancies/tenancies.server.test.ts |
Rent changes stay inside their tenancy
Section titled “Rent changes stay inside their tenancy”No Playwright test: server-side checks with the same forms and reason display as the tenancy forms’ browser tests; Vitest covers them.
| Scenario | Tests |
|---|---|
| Ending before a rent change is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| Ending after the latest rent change is allowed | Vitest src/features/tenancies/tenancies.server.test.ts |
| Moving the start moves the first rent | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/rent.test.ts |
| Moving the start earlier moves the first rent | Vitest src/features/tenancies/rent.test.ts |
| A start after a rent change is refused | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/rent.test.ts |
Existing rents move to their tenancies
Section titled “Existing rents move to their tenancies”No Playwright test: a one-time database migration; a Workers test applies it to data stored in the previous schema.
| Scenario | Tests |
|---|---|
| A rent spanning a tenant change is split | Vitest src/features/tenancies/tenancy-rents-migration.server.test.ts |
| Rent outside every tenancy is left out | Vitest src/features/tenancies/tenancy-rents-migration.server.test.ts |
| A tenancy that started before the rent was set | Vitest src/features/tenancies/tenancy-rents-migration.server.test.ts |
Occupants of a tenancy
Section titled “Occupants of a tenancy”No Playwright test: rules for stored periods and pure calculations; Vitest covers them with the functions and the repository, and the browser tests of “Changing the occupants” and “The tenancy page” use them.
| Scenario | Tests |
|---|---|
| The first occupants start on the tenancy’s start day | Vitest src/features/tenancies/rent.test.ts |
| A change of occupants ends the previous period the day before | Vitest src/features/tenancies/rent.test.ts |
| Zero occupants is refused | Vitest src/features/tenancies/schemas.test.ts |
Changing the occupants
Section titled “Changing the occupants”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| A second occupant moves in | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Correcting the occupants on the tenancy’s start | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Undoing an occupants change | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| The only occupants period can’t be undone | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t change the occupants | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
Tenant fees are recorded as periods
Section titled “Tenant fees are recorded as periods”No Playwright test: rules for stored periods and pure calculations; Vitest covers them with the functions and the repository, and the browser tests of the fee forms and the Tenancy page use them.
| Scenario | Tests |
|---|---|
| A per-occupant water fee | Vitest src/features/tenancies/fees.test.ts |
| A parking fee taken mid-tenancy | Vitest src/features/tenancies/fees.test.ts |
Adding a tenant fee
Section titled “Adding a tenant fee”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Adding a parking fee | Vitest src/features/tenancies/TenantFeeForm.test.tsxVitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Other fee with a description | Vitest src/features/tenancies/TenantFeeForm.test.tsxVitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Tenant water charge entries are warned about | Vitest src/features/tenancies/TenantFeeForm.test.tsxPlaywright e2e/tenancies.spec.ts |
| A fee before the tenancy is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t add a tenant fee | Vitest src/features/tenancies/tenancies.server.test.ts |
Changing a tenant fee
Section titled “Changing a tenant fee”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| The tenant gives up the parking space | Vitest src/features/tenancies/TenantFeeForm.test.tsxVitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| An ended fee is listed apart | Playwright e2e/tenancies.spec.ts |
| A fee date after the tenancy is refused | Vitest src/features/tenancies/tenancies.server.test.ts |
| Another tenancy’s fee is not found | Vitest src/features/tenancies/tenancies.server.test.ts |
| A member can’t change a tenant fee | Vitest src/features/tenancies/tenancies.server.test.ts |
Undoing a tenant fee change
Section titled “Undoing a tenant fee change”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| Undoing a fee’s ending | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| Undoing a fee’s only amount removes it | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| A member can’t undo a tenant fee change | Vitest src/features/tenancies/tenancies.server.test.ts |
Occupants and fees of a new tenancy
Section titled “Occupants and fees of a new tenancy”Playwright: e2e/tenancies.spec.ts
| Scenario | Tests |
|---|---|
| The occupants of a new tenancy | Vitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| The previous tenancy’s fees are offered unchecked | Vitest src/features/tenancies/TenancyForm.test.tsxVitest src/features/tenancies/tenancies.server.test.ts |
| A checked fee is copied to the new tenancy | Vitest src/features/tenancies/TenancyForm.test.tsxVitest src/features/tenancies/tenancies.server.test.tsPlaywright e2e/tenancies.spec.ts |
| No fees are offered for the first tenancy | Vitest src/features/tenancies/TenancyForm.test.tsxVitest src/features/tenancies/fees.test.ts |
Occupants and fees stay inside their tenancy
Section titled “Occupants and fees stay inside their tenancy”No Playwright test: server-side checks with the same forms and reason display as the tenancy forms’ browser tests; Vitest covers them.
| Scenario | Tests |
|---|---|
| Ending before a fee change is refused | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/rent.test.ts |
| A fee ended after the last day doesn’t block ending | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/rent.test.ts |
| Ending before an occupants change is refused | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/rent.test.ts |
| Moving the start moves the first occupants and fees | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/rent.test.ts |
| A start after an occupants change is refused | Vitest src/features/tenancies/tenancies.server.test.tsVitest src/features/tenancies/rent.test.ts |
| Removing a tenancy removes its fees | Vitest src/features/tenancies/tenancies.server.test.ts |
Existing tenancies get one occupant
Section titled “Existing tenancies get one occupant”No Playwright test: a one-time database migration; a Workers test applies it to data stored in the previous schema.
| Scenario | Tests |
|---|---|
| An existing tenancy gets one occupant | Vitest src/features/tenancies/tenancy-occupants-migration.server.test.ts |