Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8eae37e11d | ||
|
|
92ccf40312 | ||
|
|
6d8f1d6692 | ||
|
|
abf0e9004b | ||
|
|
3a0bb6e40f |
No files matched your search
+45
-88
@@ -1,105 +1,62 @@
|
||||
# Tests on every push; deployment to Strato for tags "v*" or by hand (Gitea › Actions › Deploy › Run workflow).
|
||||
# Needs a Gitea act_runner (e.g. on the private server) and these repository secrets:
|
||||
# DEPLOY_SSH_KEY private key whose public key is stored at Strato (SFTP & SSH)
|
||||
# DEPLOY_HOST package-specific SSH server, e.g. 51539426.ssh.w1.strato.hosting (not ssh.strato.de)
|
||||
# DEPLOY_USER SSH user from the Strato customer login
|
||||
# DEPLOY_PATH e.g. fewo-production
|
||||
# DEPLOY_PHP e.g. /opt/RZphp84/bin/php-cli
|
||||
# DEPLOY_URL e.g. https://www.fewo-stommer.de
|
||||
name: Deploy
|
||||
|
||||
name: Deploy FeWo mit PipelineManager
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
branches: [develop, main]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: Ziel
|
||||
type: choice
|
||||
options: [production, staging]
|
||||
default: production
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11.8
|
||||
env:
|
||||
MARIADB_DATABASE: fewo_test
|
||||
MARIADB_ROOT_PASSWORD: test
|
||||
ports: ['3306:3306']
|
||||
options: >-
|
||||
--health-cmd="healthcheck.sh --connect --innodb_initialized"
|
||||
--health-interval=5s --health-timeout=5s --health-retries=20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: mbstring, intl, gd, exif, zip, pdo_sqlite, sqlite3, pdo_mysql, fileinfo, openssl
|
||||
tools: composer:v2
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: npm
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
composer install --no-interaction --no-progress --prefer-dist
|
||||
npm ci --no-audit --no-fund
|
||||
npm run build
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
|
||||
- name: Tests (SQLite)
|
||||
run: php artisan test --compact
|
||||
|
||||
- name: Tests (MariaDB 11.8, wie auf Strato)
|
||||
env:
|
||||
DB_CONNECTION: mariadb
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_PORT: '3306'
|
||||
DB_DATABASE: fewo_test
|
||||
DB_USERNAME: root
|
||||
DB_PASSWORD: test
|
||||
run: php artisan test --compact
|
||||
|
||||
deploy:
|
||||
needs: test
|
||||
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
|
||||
# Raspi5-Paperless: existing host runner; all PHP/Node work happens inside the image.
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PIPELINE_IMAGE: pipeline-manager:0.1.0
|
||||
PIPELINE_HOME: /home/lars/docker/pipeline-manager
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: mbstring, intl, gd, exif, zip, fileinfo, openssl
|
||||
tools: composer:v2
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: npm
|
||||
|
||||
- name: SSH key
|
||||
- name: Anwendung im Manager-Container vorbereiten und testen
|
||||
id: build
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s\n' "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keyscan -H "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/known_hosts
|
||||
set -eu
|
||||
case "$GITHUB_REF" in
|
||||
refs/heads/develop) TARGET=staging ;;
|
||||
refs/heads/main) TARGET=production ;;
|
||||
*) echo 'Unzulässiger Branch'; exit 1 ;;
|
||||
esac
|
||||
docker image inspect "$PIPELINE_IMAGE" >/dev/null
|
||||
STATUS=0
|
||||
docker run --rm --user "$(id -u):$(id -g)" \
|
||||
-v "$(pwd -P):/workspace:ro" "$PIPELINE_IMAGE" \
|
||||
pipeline-manager check --environment "$TARGET" || STATUS=$?
|
||||
if [ "$STATUS" = 3 ]; then
|
||||
echo 'enabled=false' >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
test "$STATUS" = 0
|
||||
umask 077
|
||||
mkdir -p "$PIPELINE_HOME/cache/composer" "$PIPELINE_HOME/cache/npm" "$PIPELINE_HOME/backups" .pipeline
|
||||
docker run --rm --user "$(id -u):$(id -g)" --cpus=2 --memory=2g --pids-limit=512 \
|
||||
-e HOME=/tmp \
|
||||
-v "$(pwd -P):/workspace" \
|
||||
-v "$PIPELINE_HOME/cache:/cache" "$PIPELINE_IMAGE" \
|
||||
pipeline-manager prepare
|
||||
echo "target=$TARGET" >> "$GITHUB_OUTPUT"
|
||||
echo 'enabled=true' >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Deploy
|
||||
- name: Sichern und nach Strato übertragen
|
||||
if: steps.build.outputs.enabled == 'true'
|
||||
env:
|
||||
TARGET: ${{ steps.build.outputs.target }}
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||
DEPLOY_PHP: ${{ secrets.DEPLOY_PHP }}
|
||||
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
||||
run: |
|
||||
export DEPLOY_SSH_KEY="$HOME/.ssh/deploy_key"
|
||||
bash scripts/deploy.sh "${{ inputs.environment || 'production' }}" deploy
|
||||
set -eu
|
||||
docker run --rm --user "$(id -u):$(id -g)" --cpus=1 --memory=512m --pids-limit=128 \
|
||||
-e GITHUB_REF -e GITHUB_SHA -e DEPLOY_HOST -e DEPLOY_USER -e DEPLOY_SSH_KEY -e DEPLOY_KNOWN_HOSTS \
|
||||
-v "$(pwd -P):/workspace:ro" \
|
||||
-v "$PIPELINE_HOME/backups:/backups" "$PIPELINE_IMAGE" \
|
||||
pipeline-manager deploy --environment "$TARGET" --backup-root /backups
|
||||
@@ -24,6 +24,7 @@
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
/.pipeline/
|
||||
_ide_helper.php
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
|
||||
@@ -28,7 +28,7 @@ public static function configure(Schema $schema): Schema
|
||||
->schema([
|
||||
Builder::make('sections')
|
||||
->hiddenLabel()
|
||||
->blocks(fn (): array => app(SectionRegistry::class)->blocks())
|
||||
->blocks(fn (callable $get): array => app(SectionRegistry::class)->blocks($get('site_id')))
|
||||
->addActionLabel('Baustein hinzufügen')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
|
||||
@@ -3,18 +3,19 @@
|
||||
namespace App\Themes;
|
||||
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Property;
|
||||
use App\Themes\Sections\Section;
|
||||
use Filament\Forms\Components\Builder\Block;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\View as ViewFactory;
|
||||
|
||||
/**
|
||||
* The section catalogue from config/themes.php: builder blocks for the admin and rendering for the website.
|
||||
*
|
||||
* Every placed section carries data.id (a stable UUID, see Page::assignSectionIds) so appearances can
|
||||
* address it, and data.appearances (appearance ids; empty = always shown).
|
||||
* address it, data.appearances (appearance ids; empty = always shown), and an optional data.property_id
|
||||
* (an active property of this website; empty = primary property).
|
||||
*/
|
||||
class SectionRegistry
|
||||
{
|
||||
@@ -38,7 +39,7 @@ public function get(string $key): ?Section
|
||||
/**
|
||||
* @return list<Block>
|
||||
*/
|
||||
public function blocks(): array
|
||||
public function blocks(?int $siteId = null): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
fn (string $class): Block => Block::make($class::key())
|
||||
@@ -47,6 +48,17 @@ public function blocks(): array
|
||||
->schema([
|
||||
Hidden::make('id'),
|
||||
...$class::schema(),
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->placeholder('Hauptwohnung')
|
||||
->helperText('Leer = Hauptwohnung dieser Website.')
|
||||
->options(fn (): array => Property::query()
|
||||
->where('site_id', $siteId)
|
||||
->whereNotNull('site_id')
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->pluck('name', 'id')
|
||||
->all()),
|
||||
Select::make('appearances')
|
||||
->label('Nur anzeigen im Erscheinungsbild')
|
||||
->helperText('Leer = immer anzeigen. Z. B. ein Weihnachts-Baustein nur im Erscheinungsbild „Weihnachten“.')
|
||||
@@ -70,11 +82,11 @@ public function isVisible(Theme $theme, array $data): bool
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the stored sections of a page; unknown or failing types are skipped (and reported),
|
||||
* so a page never breaks because of one section.
|
||||
* Prepares the stored sections for deferred rendering. Unknown types, missing views, hidden sections
|
||||
* and unavailable property assignments are skipped.
|
||||
*
|
||||
* @param list<array{type: string, data?: array<string, mixed>}>|null $sections
|
||||
* @return list<View>
|
||||
* @return list<SectionView>
|
||||
*/
|
||||
public function render(Theme $theme, ?array $sections): array
|
||||
{
|
||||
@@ -85,11 +97,24 @@ public function render(Theme $theme, ?array $sections): array
|
||||
continue;
|
||||
}
|
||||
|
||||
$views[] = ViewFactory::make($section->view(), [
|
||||
...$section->data($theme, $stored['data'] ?? []),
|
||||
'theme' => $theme,
|
||||
'sectionId' => $section::key().'-'.$index,
|
||||
]);
|
||||
$data = $stored['data'] ?? [];
|
||||
$property = filled($data['property_id'] ?? null)
|
||||
? $theme->site->properties()->where('is_active', true)->whereKey($data['property_id'])->first()
|
||||
: $theme->property();
|
||||
|
||||
if (filled($data['property_id'] ?? null) && $property === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$views[] = $theme->runForProperty($property, fn (): SectionView => new SectionView(
|
||||
$theme,
|
||||
$property,
|
||||
ViewFactory::make($section->view(), [
|
||||
...$section->data($theme, $data),
|
||||
'theme' => $theme,
|
||||
'sectionId' => $section::key().'-'.$index,
|
||||
]),
|
||||
));
|
||||
}
|
||||
|
||||
return $views;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Themes;
|
||||
|
||||
use App\Models\Property;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
/**
|
||||
* Keeps the section's property active when the page eventually renders its Blade view and partials.
|
||||
*/
|
||||
class SectionView implements Renderable
|
||||
{
|
||||
public function __construct(
|
||||
private Theme $theme,
|
||||
private ?Property $property,
|
||||
private View $view,
|
||||
) {}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
return $this->theme->runForProperty($this->property, fn (): string => $this->view->render());
|
||||
}
|
||||
}
|
||||
@@ -174,6 +174,29 @@ public function property(): ?Property
|
||||
return $this->property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a section with its property, restoring the previous cache even when rendering fails.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param callable(): T $callback
|
||||
* @return T
|
||||
*/
|
||||
public function runForProperty(?Property $property, callable $callback): mixed
|
||||
{
|
||||
$previousProperty = $this->property;
|
||||
$previousResolved = $this->propertyResolved;
|
||||
$this->property = $property;
|
||||
$this->propertyResolved = true;
|
||||
|
||||
try {
|
||||
return $callback();
|
||||
} finally {
|
||||
$this->property = $previousProperty;
|
||||
$this->propertyResolved = $previousResolved;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Published pages of a menu location ("main" or "footer").
|
||||
*
|
||||
|
||||
+14
-5
@@ -1,11 +1,12 @@
|
||||
# Deployment auf Strato
|
||||
|
||||
Stand: 22.10.2026 · Skript: `scripts/deploy.sh` · CI: `.gitea/workflows/deploy.yml`
|
||||
Stand: 26.10.2026 · Gemeinsamer Manager: [PipelineManager](https://gitea.stommer.de/Lars/PipelineManager) · Pilotkonfiguration: `pipeline.toml` · CI: `.gitea/workflows/deploy.yml`
|
||||
|
||||
## 1. Prinzip
|
||||
|
||||
```
|
||||
Gitea (main/Tag) ──► Build (CI oder lokal): git-Stand · composer --no-dev · npm run build
|
||||
Gitea (develop/main) ──► PipelineManager-Container auf Raspi5-Paperless
|
||||
│ exakter Git-Commit · Abhängigkeiten · Tests · fertige Assets
|
||||
│ tar.gz
|
||||
▼ SSH
|
||||
Strato <DEPLOY_PATH>/
|
||||
@@ -20,6 +21,10 @@ ## 1. Prinzip
|
||||
|
||||
Auf dem Server werden nur **bash, tar und PHP-CLI** gebraucht – kein Composer, kein Node, kein Git, kein rsync.
|
||||
|
||||
Die Werkzeugumgebung wird im eigenen Repository `C:\dev\pipelinemanager` entwickelt und als lokales Image `pipeline-manager:0.1.0` auf dem Pi freigegeben. Das Image bleibt nach dem Entfernen eines Job-Containers erhalten. Der Ablauf folgt Tsumugus Docker-Aufträgen auf dem vorhandenen Host-Runner (`ubuntu-latest`), führt Tests jedoch am exakten Commit vor dem Upload aus. Keine PHP-/Node-Installation auf dem Host und kein Build auf dem Entwicklungsrechner für automatische Deployments.
|
||||
|
||||
FeWo definiert nur seine prepare/test/finalize-Befehle, erforderlichen Dateien, Laravel-Hooks, persistenten Pfade und Ziele in `pipeline.toml`. Gemeinsame Paket-, Sicherungs-, Upload- und Rückfalllogik liegt im PipelineManager. Der bisherige manuelle Weg über `scripts/deploy.sh` bleibt als bestehender Wartungsweg erhalten, bis die neue Anbindung vollständig auf Test bestätigt ist.
|
||||
|
||||
## 2. SSH oder SFTP?
|
||||
|
||||
**Empfehlung: SSH.** Das Skript führt nach dem Hochladen Befehle auf dem Server aus (Archiv entpacken, Datenbank migrieren, Caches erzeugen, Version umschalten, ggf. zurückschalten). Das geht nur mit SSH.
|
||||
@@ -77,9 +82,13 @@ ## 4. Tägliche Nutzung
|
||||
|
||||
## 5. Automatisch über Gitea Actions
|
||||
|
||||
- Workflow `.gitea/workflows/deploy.yml`: **Tests bei jedem Push**; **Deployment** bei Tags `v*` (z. B. `git tag v1.0.0 && git push --tags`) oder per Knopfdruck (Actions › Deploy › Run workflow, Ziel production/staging).
|
||||
- Voraussetzung: Gitea Actions aktiviert und ein **act_runner** registriert – passt gut auf den privaten Server (Docker). Anleitung: Gitea-Doku „Act Runner“.
|
||||
- Repository-Secrets: `DEPLOY_SSH_KEY` (privater Schlüssel, dessen öffentlicher Teil bei Strato hinterlegt ist), `DEPLOY_HOST`, `DEPLOY_USER`, `DEPLOY_PATH`, `DEPLOY_PHP`, `DEPLOY_URL`.
|
||||
- Push auf `develop`: Manager-Image prüfen, FeWo vorbereiten und die Feature-Suite im Container ausführen, danach nach `test.fewo-stommer.de/` unter https://stommer.info deployen. Merge-Commit von `develop` nach `main`: derselbe Ablauf für `prod.fewo-stommer.de/`, sobald dieses Ziel ausdrücklich in `pipeline.toml` aktiviert ist.
|
||||
- Produktion ist derzeit `enabled=false`: Der Workflow überspringt Vorbereitung und Deployment. Eigenständige Produktionsdatenbank, `.env` und Domain-Zuordnung müssen vor Freigabe eingerichtet werden. Das bestehende WordPress-Verzeichnis `www.fewo-stommer.de/` bleibt unangetastet.
|
||||
- Die 18 Manager-Tests liegen im separaten Repository; die Anwendung behält ihre 285 Feature-Tests. Kein `setup-php`, kein `setup-node`, keine Toolinstallation auf dem Pi-Host. Der bisherige Node-24-/PHP-Setup-Fehler entfällt damit.
|
||||
- Build und Deployment laufen in getrennten Containeraufrufen mit UID/GID des Runners und Ressourcenlimits. Nur der Deployment-Container erhält die Strato-Zugänge. Er bekommt weder den Docker-Socket noch Verzeichnisse anderer Anwendungen.
|
||||
- Persistente Verzeichnisse auf dem Pi: `/home/lars/docker/pipeline-manager/cache` (Composer/npm) und `backups/<project>/<environment>` (Datenbank, Medien und Server-Konfiguration). Backups werden vor dem Upload geprüft; ein Fehler verhindert die Auslieferung. Eine Sperre auf Strato verhindert parallele Umschaltungen desselben Ziels.
|
||||
- Repository-Secrets vor dem ersten Deployment einrichten: `DEPLOY_HOST`, `DEPLOY_USER`, `DEPLOY_SSH_KEY` (Schlüsselinhalt), `DEPLOY_KNOWN_HOSTS` (geprüfter Hostschlüssel). Geheimnisse bleiben außerhalb von Image und Repository. Der Manager schreibt sie nur vorübergehend in geschützte Dateien. Im Repository waren bei Prüfung noch keine Secrets vorhanden.
|
||||
- Die auf dem Pi freigegebene Image-Version muss vor dem FeWo-Workflow vorhanden sein. Für weitere Runner mit anderer Architektur ist eine entsprechende Imagebereitstellung erforderlich. Erst nach erfolgreichem Pilotlauf wird der alte manuelle Deploy-Weg ersetzt.
|
||||
|
||||
## 6. Getestet / offen
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ ## 9. Betrieb und Abgrenzung
|
||||
|
||||
## 10. Freigabe
|
||||
|
||||
**Phasen 1 bis 5 sind umgesetzt und ausgeliefert**, von Phase 6 die Anwendungsseite (auf `main`, noch nicht ausgeliefert). Der Grundumbau ist damit fertig: Daten, Rollen, Einstellungen, Domains, Hintergrundläufe, Export und Kündigung, dazu Bildwelten und die Marke je Website. **Phase 7 schließt eine eigene Sitzung ab**; die Übergabe dafür steht in [STATUS.md](STATUS.md) Abschnitt 7. Die bisherigen Daten gehören zum Mandanten Stommer, `lars@stommer.com` ist Betreiber. Ausgelieferter Stand und Übergabe: [STATUS.md](STATUS.md) Abschnitt 7.
|
||||
**Phasen 1 bis 5 und die Anwendungsseite von Phase 6 sind umgesetzt und ausgeliefert** (Release `20261026065920`). Der Grundumbau ist damit fertig: Daten, Rollen, Einstellungen, Domains, Hintergrundläufe, Export und Kündigung, dazu Bildwelten und die Marke je Website. **Phase 7 schließt eine eigene Sitzung ab**; die Übergabe dafür steht in [STATUS.md](STATUS.md) Abschnitt 7. Die bisherigen Daten gehören zum Mandanten Stommer, `lars@stommer.com` ist Betreiber. Ausgelieferter Stand und Übergabe: [STATUS.md](STATUS.md) Abschnitt 7.
|
||||
|
||||
Offen und **nicht** Teil dieses Plans: Subscription und Abrechnung (§9 schließt sie aus; `service_usages` liegt als Grundlage bereit) sowie die Frage, ob Strato für die Domain eines Mandanten ein Zertifikat ausstellt – davon hängt ab, ob das Modell „Mandant bringt seine Domain mit" auf diesem Hosting trägt. Phase 6 und 7 warten auf eine eigene Freigabe und einen Eintrag in [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6.
|
||||
|
||||
|
||||
+21
-14
@@ -1,6 +1,6 @@
|
||||
# Projektstand
|
||||
|
||||
Stand: 24.10.2026 · ausgelieferter Stand: `deploy/staging/20261024152057` · `main` ist voraus (Phase 6 noch nicht ausgeliefert) · 272 Feature-Tests grün
|
||||
Stand: 26.10.2026 · ausgelieferter Stand: `deploy/staging/20261026072521` (`abf0e90`) · 285 Feature-Tests grün
|
||||
|
||||
> Dieses Dokument ist der Einstieg für jede neue Arbeitssitzung. Bitte bei größeren Änderungen fortschreiben (Abschnitte „Fertig“, „Offen“, „Nächste Schritte“).
|
||||
|
||||
@@ -70,7 +70,7 @@ ## 3. Offen
|
||||
**Technik**
|
||||
- Cronjob auf Strato einrichten (BETRIEB.md §6).
|
||||
- Design-Theme Seebad 0.3 ist auf `main` und auf stommer.info aktiv (Abschnitt 6).
|
||||
- Mandantenfähigkeit: **Phasen 1 bis 5 sind umgesetzt** – der Grundumbau ist fertig. Stand, Bausteine und Fallen stehen in Abschnitt 7. Plan: `docs/MANDANTEN-PLAN.md`.
|
||||
- Mandantenfähigkeit: **Phasen 1 bis 5, die Anwendungsseite von Phase 6 und der Kern von Phase 7 sind ausgeliefert**. Bausteine können eine aktive Wohnung ihrer Website wählen; leer = Hauptwohnung. Stand, Bausteine und Fallen stehen in Abschnitt 7. Plan: `docs/MANDANTEN-PLAN.md`.
|
||||
- Logo in E-Mails und im Vertrags-PDF (`public/brand/logo-600.png` liegt bereit).
|
||||
- Content-Security-Policy: braucht wegen Livewire/Filament Nonces und einen sorgfältigen Test.
|
||||
- Produktion `www.fewo-stommer.de` vorbereiten:
|
||||
@@ -135,25 +135,31 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
|
||||
|
||||
## 7. Mandanten – Übergabe an die nächste Sitzung
|
||||
|
||||
Stand: 24.10.2026, abends · Branch `main` (`c459f7f`) · Plan: [MANDANTEN-PLAN.md](MANDANTEN-PLAN.md) · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md)
|
||||
Stand: 26.10.2026 · Phase-7-Kern auf `main` und Strato · Plan: [MANDANTEN-PLAN.md](MANDANTEN-PLAN.md) · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md)
|
||||
|
||||
> **`main` ist dem Server voraus.** Ausgeliefert ist `20261024152057` (Commit `2c5b5fc`, Phasen 1–5). Phase 6 (Bildwelten, Marke) liegt seit `4e66add` auf `main` und ist **nicht** ausgeliefert; sie bringt eine Migration mit (`image_world` an `sites` und `properties`). Vor dem nächsten Deploy also sichern wie immer: `bash scripts/backup-pull.sh staging /c/Dev/fewo-backups/staging`, dann `bash scripts/deploy.sh staging deploy`.
|
||||
> **Ausgeliefert:** `20261026072521`, Commit `abf0e90`, aus aktuellem `main` nach `test.fewo-stommer.de/` (https://stommer.info). Sicherung davor: `C:\Dev\fewo-backups\staging\20261026-082223` (Datenbank und Dateien, 29 MB). Aktiven Pfad und `REVISION` per SSH geprüft; `/up`, `/`, `/wohnung`, `/buchen` und `/admin/login` liefern HTTP 200. Vor jedem weiteren Deploy sichern: `bash scripts/backup-pull.sh staging /c/Dev/fewo-backups/staging`, dann `bash scripts/deploy.sh staging deploy` (nur aus aktuellem `main`).
|
||||
|
||||
**Der Grundumbau (Phasen 1–5) ist fertig.** Von Phase 6 ist die **Anwendungsseite gebaut** (Bildwelten, Marke je Website) – ohne eine einzige Theme-Datei zu ändern; der Rest ist ein Vertragsfall und steht als Aufgabe für die Theme-Sitzung in ZUSAMMENARBEIT.md §6: Favicon und die fest verdrahteten Grafiken in `ostsee-licht` auf `$theme->brand()` bzw. Plätze umstellen. Offen bleibt Phase 7 (mehrere Wohnungen je Website). Nicht im Plan und offen: Subscription/Abrechnung und die Zertifikatsfrage bei Strato.
|
||||
**Der Grundumbau (Phasen 1–5) ist fertig.** Von Phase 6 ist die **Anwendungsseite gebaut** (Bildwelten, Marke je Website) – ohne eine einzige Theme-Datei zu ändern; der Rest ist ein Vertragsfall und steht als Aufgabe für die Theme-Sitzung in ZUSAMMENARBEIT.md §6: Favicon und die fest verdrahteten Grafiken in `ostsee-licht` auf `$theme->brand()` bzw. Plätze umstellen. Der Kern von Phase 7 ist ebenfalls umgesetzt und ausgeliefert. Nicht im Plan und offen: Subscription/Abrechnung und die Zertifikatsfrage bei Strato.
|
||||
|
||||
### Hier weitermachen: Phase 7
|
||||
### Phase 7: Kern umgesetzt und ausgeliefert
|
||||
|
||||
Ziel (A21): Ein Baustein kann eine Wohnung **dieser Website** wählen; ohne Wahl gilt wie heute die Hauptwohnung. Voraussetzung für die Bergwohnung unter `fewo-stommer.de`.
|
||||
|
||||
**Der Kern braucht keine Theme-Änderung.** Bestehende Vorlagen rufen `$theme->property()`; wenn der Renderer vor dem Baustein die gewählte Wohnung setzt, bleiben sie unverändert gültig. Ein Eintrag in [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6 wird erst fällig, wenn **neue** Bausteine dazukommen (Übersicht aller Wohnungen, Suche über mehrere) – die brauchen eine Pflicht-Vorlage im Basis-Theme.
|
||||
**Ohne Theme-Änderung umgesetzt.** Alle Bausteine haben im Seiten-Baukasten das gemeinsame Feld „Wohnung“ (`data.property_id`). Die Auswahl und ihre Validierung erlauben nur aktive Wohnungen der Website der bearbeiteten Seite. Leer bleibt die Hauptwohnung. Ein Eintrag in [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md) §6 wird erst fällig, wenn **neue** Bausteine dazukommen (Übersicht aller Wohnungen, Suche über mehrere) – diese gehören nicht zum Kern und brauchen eine Pflicht-Vorlage im Basis-Theme.
|
||||
|
||||
Anzufassen wären vermutlich:
|
||||
Die Umsetzung:
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `app/Themes/Theme.php` | `property()` merkt sich die Wohnung (`$this->property`, `$this->propertyResolved`). Für Phase 7 braucht es einen Weg, sie je Baustein zu setzen und danach zurückzusetzen – am ehesten ein `runForProperty(Property $p, Closure $c)` nach dem Vorbild von `TenantContext::run()`. **Achtung:** eine solche Methode gibt es heute nicht – ein Test, der sie voraussetzt, schlägt fehl. |
|
||||
| `app/Themes/Sections/*` | Gemeinsames Feld „Wohnung" im Admin-Formular der Bausteine, leer = Hauptwohnung. |
|
||||
| Seiten-Renderer | Setzt die Wohnung, bevor der Baustein läuft. |
|
||||
| `app/Themes/Theme.php` | `runForProperty(?Property, callable)` setzt die Wohnung für einen Callback und stellt im `finally` beide bisherigen Cache-Werte wieder her, auch bei Verschachtelung oder Fehlern. |
|
||||
| `app/Themes/SectionRegistry.php`, `PageForm` | Gemeinsames Auswahlfeld für jeden Baustein. Der Renderer prüft Website-Zugehörigkeit und Aktivität erneut; fremde, inaktive oder gelöschte Zuordnungen werden übersprungen, ohne auf eine andere Wohnung umzulenken. |
|
||||
| `app/Themes/SectionView.php` | Die Ausgabe bleibt verzögert (`render()` wie bisher). Auch während Blade, Partials und Livewire laufen, ist die gewählte Wohnung aktiv; das gilt ebenso für die Bildwelt über den Theme-Kontext. Danach gilt wieder der vorherige Zustand. |
|
||||
|
||||
Tests: `tests/Feature/SectionPropertyTest.php` prüft in 13 Fällen gemischte Wohnungen auf einer Seite, Hauptwohnungs-Fallback, das Buchungsformular, verzögerte Ausgabe, verschachtelte Kontexte und Fehler sowie Speichern und Ablehnen im Admin über Website- und Mandantengrenzen. Gesamte Feature-Suite: **285 Tests, 1289 Assertions grün**; Pint ausgeführt. Keine neue Tabelle, Migration oder Abhängigkeit. Deployment erfolgreich, keine Migration offen.
|
||||
|
||||
**Gemeinsamer PipelineManager (26.10., Pilotanbindung auf `feature/pipeline-manager-integration`):** Eigenes Repository [Lars/PipelineManager](https://gitea.stommer.de/Lars/PipelineManager), lokal `C:\dev\pipelinemanager`. Werkzeug-Image mit PHP/Composer/Node/Python/Git/SSH und gemeinsame Tests, Paketprüfung, Sicherung, Upload, Umschaltung und Rückfall. Nach dem Vorbild von Tsumugu baut der vorhandene Runner `Raspi5-Paperless` das Image im Docker; Anwendungen starten daraus ihre Aufträge. Image und Download-Caches werden wiederverwendet. FeWo liefert nur `pipeline.toml` mit Laravel-Befehlen und Zielen. Push `develop` → `test.fewo-stommer.de/`, Merge nach `main` → `prod.fewo-stommer.de/`; Produktion bleibt ausdrücklich gesperrt. Das leere Produktionsverzeichnis ist bereits angelegt, ohne `.env` oder Datenbank-Anbindung. Keine PHP-/Node-Installation mehr auf dem Host vorgesehen.
|
||||
|
||||
Der frühere lokale Paket-/Registry-Ansatz bleibt unveröffentlicht auf `feature/artifact-pipeline` und ist nicht Bestandteil der Pilotanbindung. Anwendung und Theme-Dateien unverändert. Manager-Stand `0e44a42`: **18 Manager-Tests lokal grün, Docker-Build und Werkzeugprüfungen auf Raspi5-Paperless grün** ([Gitea-Lauf 4648](https://gitea.stommer.de/Lars/PipelineManager/actions/runs/4648)). Version `v0.1.0` ist zur Image-Freigabe markiert. Die Verzeichnisse für Cache und Backups liegen unter `/home/lars/docker/pipeline-manager/`; der Manager veröffentlicht keine Ports. Vor dem ersten automatischen FeWo-Deployment fehlen noch die Strato-Zugänge als Gitea-Secrets. Der aktuelle Strato-Release steht oben; Tsumugu wurde ausschließlich gelesen.
|
||||
|
||||
**Nicht vergessen:** Jede neue Tabelle bekommt `tenant_id` von Anfang an und gehört in `TenantArchive::DELETE_ORDER`, sonst überlebt sie die Kündigung ihres Mandanten. `tests/Feature/TenantSeparationTest.php` merkt das – aber nur, wenn der Testaufbau dort die neue Tabelle auch füllt.
|
||||
|
||||
@@ -179,13 +185,14 @@ ### Ausgeliefert
|
||||
| | |
|
||||
|---|---|
|
||||
| Server | nur **stommer.info** (Staging). `www.fewo-stommer.de` ist unberührt und bleibt WordPress. |
|
||||
| Release | `20261024152057`, Git-Tag `deploy/staging/20261024152057`, Commit `2c5b5fc` (**Phasen 1–5 vollständig**). Der Tag `20261024151841` zeigt auf denselben Commit – ein Deploy wurde wiederholt, weil die erste Ausgabe durch einen Absturz verloren ging. |
|
||||
| Code danach | Commits auf `main` nach `2c5b5fc` sind Dokumentation. Sie sind nicht erneut ausgeliefert. Ein Deploy nur wegen dieser Texte ist unnötig: das Skript nimmt `docs/` nicht mit. |
|
||||
| Release | `20261026065920` (**Phasen 1–5 plus Anwendungsseite von Phase 6**). Frühere Tags desselben Tages: `20261024151841` und `20261024152057` zeigen auf denselben Commit – ein Deploy wurde wiederholt, weil die erste Ausgabe durch einen Absturz verloren ging. |
|
||||
| Code danach | Commits auf `main` nach `361acfa` sind Dokumentation. Sie sind nicht erneut ausgeliefert. Ein Deploy nur wegen dieser Texte ist unnötig: das Skript nimmt `docs/` nicht mit. |
|
||||
| Migration | fünf Migrationen vom 23.10. sind auf der MariaDB von stommer.info durch. Vorhandene Zeilen gehören zum Mandanten **Stommer** (`slug` `stommer`); die Betriebsdaten stehen an dessen Spalten, `settings` ist weg. Ein zweites Migrieren legt keinen zweiten Stommer an, solange keine Zeile ohne Mandant übrig ist. |
|
||||
| Sicherung davor | `C:\Dev\fewo-backups\staging\20261024-171534`; davor `…\20261024-102031`, `…\20261024-092543` und `…\20261023-215553` (die letzte mit noch vorhandener `settings`-Tabelle). Erstellt mit `scripts/backup-pull.sh staging`. Ein Rollback der Version nimmt die Migration **nicht** zurück. |
|
||||
| Sicherung davor | `C:\Dev\fewo-backups\staging\20261026-075730`; davor `…\20261024-171534`, `…\20261024-102031`, `…\20261024-092543` und `…\20261023-215553` (die letzte mit noch vorhandener `settings`-Tabelle). Erstellt mit `scripts/backup-pull.sh staging`. Ein Rollback der Version nimmt die Migration **nicht** zurück. |
|
||||
| Konto | `php artisan users:promote-operator lars@stommer.com` ist auf dem Server gelaufen. Passwort und 2FA sind gleich geblieben. |
|
||||
| Prüfung | `https://stommer.info/`, `/wohnung` und `/buchen` antworten 200 und zeigen weiter Seebad und Stommer samt Vermieterdaten aus den Mandanten-Spalten. `/admin` und `/betreiber` leiten ohne Anmeldung auf die Login-Seite um (302). Betriebsart Testbetrieb, Umleitung an `lars@stommer.com`. **Noch nicht angemeldet geprüft:** die Seite System › Betrieb mit den neuen Abschnitten. |
|
||||
| Prüfung (24.10., nach Phase 4/5) | `/`, `/wohnung`, `/buchen` auf beiden Hosts 200; `/admin` und `/betreiber` 302. `bookings:expire-holds` läuft nachweislich **je Mandant** („Stommer: 0 …“, „Testmandant (Probe): 0 …“). `tenants:export testmandant` einmal auf dem Server ausgeführt; Exporte landen über den Symlink in `shared/storage/app/private/exports` (überleben jeden Deploy) und sind aus dem Web mit 403 gesperrt. **Nicht geprüft:** `tenants:delete` auf echten Daten – es löscht Dateien. |
|
||||
| Prüfung (26.10., nach Phase 6) | `/`, `/wohnung`, `/buchen` auf beiden Hosts 200 und weiter Inhalte von Stommer; `/admin` und `/betreiber` 302. `image-worlds:check` meldet die Bildwelt `ostsee` mit 11 Plätzen. Spalten `image_world` sind leer, also greift die Vorgabe der Installation: `$theme->imageWorld()` liefert `ostsee`, `$theme->motif(‚divider‘)` ein SVG von 1897 Zeichen mit `aria-hidden`. `$theme->brand(‘logo‘)` ist null – es wurde noch kein Logo hochgeladen, der Vertrag bleibt dadurch wie bisher. |
|
||||
|
||||
Die lokale Datei `database/database.sqlite` (`.env`: `DB_CONNECTION=sqlite`, `APP_URL=http://localhost:8000`) ist **nicht** vollständig migriert (die zwei Migrationen von Phase 3 stehen dort auf „Pending“). `php artisan serve` auf diesem Rechner trifft das alte Schema und läuft mit dem neuen Code nicht. Testinstanz ist stommer.info. Die lokale Datei nur migrieren, wenn jemand bewusst lokal arbeiten will (`php artisan migrate`, danach `users:promote-operator` für das lokale Konto). Die `.env` nicht auf die Datenbank von stommer.info zeigen lassen.
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ # … arbeiten (docs/THEME-ERSTELLUNG.md) …
|
||||
|
||||
## 3. Ausliefern (Deployment)
|
||||
|
||||
- **Nur aus `main`, nur nach `git pull`, nur mit grünen Tests.** Das Skript baut den letzten Commit des **lokalen** Stands. Wer aus einem Feature- oder Theme-Branch ausliefert, nimmt alle Änderungen der anderen Session vom Server.
|
||||
- **Zielablauf mit PipelineManager:** Feature- und Theme-Branches gehen nach `develop`; dessen Push startet Tests und Deployment auf das Testsystem. Produktion entsteht durch Merge-Commit `develop` → `main` und ist bis zur Einrichtung gesperrt. Gemeinsame Deployment-Werkzeuge werden im separaten Repository PipelineManager gepflegt. Details und Freigabestand: `docs/DEPLOYMENT.md`, `docs/STATUS.md`. Bis der Pilot bestätigt ist, bleibt der bestehende manuelle Weg aus aktuellem `main` verfügbar.
|
||||
- Theme-Vorschau auf stommer.info: erst nach dem Zusammenführen in `main`, dann `bash scripts/deploy.sh staging deploy` und `bash scripts/deploy.sh staging artisan themes:preview <key>` (gibt die Vorschau-Links aus).
|
||||
- Das neue Theme aktivieren (Admin › System › Websites › Theme) entscheidet Lars, nach Sichtung der Vorschau.
|
||||
- `shared/.env` auf dem Server ändert nur Lars (Passwörter); Sessions ändern dort höchstens nicht geheime Werte und dokumentieren das in BETRIEB.md.
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
schema = 1
|
||||
project = "fewo-stommer"
|
||||
manager = "0.1.0"
|
||||
|
||||
[build]
|
||||
prepare = [
|
||||
["composer", "install", "--prefer-dist", "--no-interaction", "--no-progress"],
|
||||
["npm", "ci", "--no-audit", "--no-fund"],
|
||||
["npm", "run", "build"],
|
||||
["php", "-r", "copy('.env.example', '.env');"],
|
||||
["php", "artisan", "key:generate", "--no-interaction"],
|
||||
]
|
||||
test = [["php", "artisan", "test", "--compact", "--testsuite=Feature"]]
|
||||
finalize = [
|
||||
["composer", "install", "--no-dev", "--prefer-dist", "--optimize-autoloader", "--no-interaction", "--no-progress"],
|
||||
["php", "artisan", "optimize:clear", "--no-interaction"],
|
||||
]
|
||||
exclude = [
|
||||
"node_modules", "tests", "docs", "styles", "scripts", "storage", ".gitea", ".github",
|
||||
".claude", ".codex", ".ai", ".cursor", "AGENTS.md", "CLAUDE.md", "phpunit.xml",
|
||||
"pipeline.toml", "boost.json", "vendor/laravel/boost", "vendor/laravel/pao",
|
||||
]
|
||||
required = ["artisan", "vendor/autoload.php", "public/index.php", "public/build/manifest.json"]
|
||||
|
||||
[build.environment]
|
||||
APP_ENV = "testing"
|
||||
DB_CONNECTION = "sqlite"
|
||||
DB_DATABASE = ":memory:"
|
||||
DB_URL = ""
|
||||
MAIL_MAILER = "array"
|
||||
CACHE_STORE = "array"
|
||||
SESSION_DRIVER = "array"
|
||||
QUEUE_CONNECTION = "sync"
|
||||
|
||||
[remote]
|
||||
public = "public"
|
||||
backup = [["@php", "artisan", "backup:database", "--no-interaction"]]
|
||||
activate = [
|
||||
["@php", "artisan", "migrate", "--force", "--no-interaction"],
|
||||
["@php", "artisan", "optimize", "--no-interaction"],
|
||||
["@php", "artisan", "filament:optimize", "--no-interaction"],
|
||||
]
|
||||
|
||||
[remote.shared]
|
||||
".env" = ".env"
|
||||
storage = "storage"
|
||||
"public/storage" = "storage/app/public"
|
||||
|
||||
[targets.staging]
|
||||
branch = "develop"
|
||||
path = "test.fewo-stommer.de"
|
||||
url = "https://stommer.info"
|
||||
php = "/opt/RZphp84/bin/php-cli"
|
||||
enabled = true
|
||||
|
||||
[targets.production]
|
||||
branch = "main"
|
||||
require_merge = true
|
||||
source_branch = "develop"
|
||||
path = "prod.fewo-stommer.de"
|
||||
url = "https://www.fewo-stommer.de"
|
||||
php = "/opt/RZphp84/bin/php-cli"
|
||||
enabled = false
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
use App\Models\Page;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Themes\SectionRegistry;
|
||||
use App\Themes\Theme;
|
||||
use App\Themes\ThemeFactory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Livewire\Livewire;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use RuntimeException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SectionPropertyTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_sections_use_the_selected_property_and_return_to_the_primary_property(): void
|
||||
{
|
||||
$this->withoutVite();
|
||||
$site = Site::factory()->create(['domain' => 'wohnungen.test', 'is_default' => true]);
|
||||
Property::factory()->for($site)->create(['name' => 'Hauptwohnung', 'size_sqm' => 53]);
|
||||
$second = Property::factory()->for($site)->create(['name' => 'Bergwohnung', 'size_sqm' => 87]);
|
||||
Page::factory()->for($site)->create([
|
||||
'slug' => Page::HOME,
|
||||
'sections' => [
|
||||
['type' => 'facts', 'data' => ['heading' => 'Erste Wohnung']],
|
||||
['type' => 'facts', 'data' => ['heading' => 'Zweite Wohnung', 'property_id' => (string) $second->id]],
|
||||
['type' => 'facts', 'data' => ['heading' => 'Wieder Hauptwohnung', 'property_id' => null]],
|
||||
['type' => 'booking', 'data' => ['property_id' => $second->id]],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->get('http://wohnungen.test/')
|
||||
->assertOk()
|
||||
->assertSeeInOrder(['Erste Wohnung', '53 m²', 'Zweite Wohnung', '87 m²', 'Wieder Hauptwohnung', '53 m²'])
|
||||
->assertSee('"propertyId":'.$second->id, false);
|
||||
|
||||
$this->assertSame('Hauptwohnung', app(Theme::class)->property()->name);
|
||||
}
|
||||
|
||||
public function test_deferred_views_and_partials_see_the_selected_theme_property(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$primary = Property::factory()->for($site)->create(['name' => 'Hauptwohnung']);
|
||||
$second = Property::factory()->for($site)->create(['name' => 'Bergwohnung']);
|
||||
$theme = app(ThemeFactory::class)->forSite($site)->activate();
|
||||
app()->instance(Theme::class, $theme);
|
||||
View::composer('theme::sections.facts', function ($view): void {
|
||||
$view->with('heading', $view->getData()['theme']->property()->name.' / '.app(Theme::class)->property()->name);
|
||||
});
|
||||
|
||||
$sections = app(SectionRegistry::class)->render($theme, [
|
||||
['type' => 'facts', 'data' => ['property_id' => $second->id]],
|
||||
['type' => 'facts', 'data' => []],
|
||||
]);
|
||||
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
$this->assertStringContainsString('Bergwohnung / Bergwohnung', $sections[0]->render());
|
||||
$this->assertStringContainsString('Hauptwohnung / Hauptwohnung', $sections[1]->render());
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
}
|
||||
|
||||
public function test_nested_property_contexts_restore_the_unresolved_primary_cache_after_an_exception(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$primary = Property::factory()->for($site)->create();
|
||||
$second = Property::factory()->for($site)->create();
|
||||
$theme = app(ThemeFactory::class)->forSite($site);
|
||||
|
||||
try {
|
||||
$theme->runForProperty($second, function () use ($theme, $primary, $second): void {
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
$theme->runForProperty($primary, function () use ($theme, $primary): void {
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
});
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
|
||||
throw new RuntimeException('Abbruch');
|
||||
});
|
||||
$this->fail('The callback must throw.');
|
||||
} catch (RuntimeException $exception) {
|
||||
$this->assertSame('Abbruch', $exception->getMessage());
|
||||
}
|
||||
|
||||
$primary->update(['is_active' => false]);
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
}
|
||||
|
||||
public function test_a_failing_deferred_view_restores_the_primary_property(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$primary = Property::factory()->for($site)->create();
|
||||
$second = Property::factory()->for($site)->create();
|
||||
$theme = app(ThemeFactory::class)->forSite($site)->activate();
|
||||
$sections = app(SectionRegistry::class)->render($theme, [
|
||||
['type' => 'facts', 'data' => ['property_id' => $second->id]],
|
||||
]);
|
||||
View::composer('theme::sections.facts', function () use ($theme, $second): void {
|
||||
$this->assertSame($second->id, $theme->property()->id);
|
||||
|
||||
throw new RuntimeException('Vorlage abgebrochen');
|
||||
});
|
||||
|
||||
try {
|
||||
$sections[0]->render();
|
||||
$this->fail('The view must throw.');
|
||||
} catch (RuntimeException $exception) {
|
||||
$this->assertSame('Vorlage abgebrochen', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame($primary->id, $theme->property()->id);
|
||||
}
|
||||
|
||||
/** @return array<string, array{string}> */
|
||||
public static function invalidPropertyProvider(): array
|
||||
{
|
||||
return [
|
||||
'other website of same tenant' => ['other_site'],
|
||||
'other tenant' => ['other_tenant'],
|
||||
'inactive property' => ['inactive'],
|
||||
'deleted property' => ['deleted'],
|
||||
];
|
||||
}
|
||||
|
||||
#[DataProvider('invalidPropertyProvider')]
|
||||
public function test_invalid_property_assignments_are_skipped(string $kind): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
Property::factory()->for($site)->create();
|
||||
$otherSite = Site::factory()->create(['tenant_id' => $site->tenant_id]);
|
||||
$property = match ($kind) {
|
||||
'other_site' => Property::factory()->for($otherSite)->create(),
|
||||
'other_tenant' => Property::factory()->for(Site::factory())->create(),
|
||||
default => Property::factory()->for($site)->create(['is_active' => false]),
|
||||
};
|
||||
if ($kind === 'deleted') {
|
||||
$property->delete();
|
||||
}
|
||||
app(TenantContext::class)->set($site->tenant);
|
||||
$theme = app(ThemeFactory::class)->forSite($site)->activate();
|
||||
|
||||
$sections = app(SectionRegistry::class)->render($theme, [
|
||||
['type' => 'facts', 'data' => ['property_id' => $property->id]],
|
||||
['type' => 'facts', 'data' => ['heading' => 'Hauptwohnung bleibt sichtbar']],
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $sections);
|
||||
$this->assertStringContainsString('Hauptwohnung bleibt sichtbar', $sections[0]->render());
|
||||
}
|
||||
|
||||
public function test_editor_saves_a_property_of_the_pages_website(): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$property = Property::factory()->for($site)->create();
|
||||
$page = Page::factory()->for($site)->create();
|
||||
$user = User::factory()->role(UserRole::Content)->create();
|
||||
$user->tenants()->syncWithoutDetaching([$site->tenant_id => ['role' => UserRole::Content->value]]);
|
||||
app(TenantContext::class)->set($site->tenant);
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test(EditPage::class, ['record' => $page->getRouteKey()])
|
||||
->fillForm(['sections' => [['type' => 'facts', 'data' => ['property_id' => $property->id]]]])
|
||||
->call('save')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$this->assertSame($property->id, (int) $page->fresh()->sections[0]['data']['property_id']);
|
||||
}
|
||||
|
||||
#[DataProvider('invalidPropertyProvider')]
|
||||
public function test_editor_rejects_properties_outside_the_available_selection(string $kind): void
|
||||
{
|
||||
$site = Site::factory()->create();
|
||||
$page = Page::factory()->for($site)->create(['sections' => []]);
|
||||
$otherSite = Site::factory()->create(['tenant_id' => $site->tenant_id]);
|
||||
$property = match ($kind) {
|
||||
'other_site' => Property::factory()->for($otherSite)->create(),
|
||||
'other_tenant' => Property::factory()->for(Site::factory())->create(),
|
||||
default => Property::factory()->for($site)->create(['is_active' => false]),
|
||||
};
|
||||
if ($kind === 'deleted') {
|
||||
$property->delete();
|
||||
}
|
||||
$user = User::factory()->role(UserRole::Content)->create();
|
||||
$user->tenants()->syncWithoutDetaching([$site->tenant_id => ['role' => UserRole::Content->value]]);
|
||||
app(TenantContext::class)->set($site->tenant);
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test(EditPage::class, ['record' => $page->getRouteKey()])
|
||||
->fillForm(['sections' => [['type' => 'facts', 'data' => ['property_id' => $property->id]]]])
|
||||
->call('save')
|
||||
->assertHasFormErrors();
|
||||
|
||||
$this->assertSame([], $page->fresh()->sections);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user