fix(domains): stop suggesting missing www counterpart domains

Remove buildSuggestedWwwRows from application and service domain
row builders so configured domains no longer auto-surface an
unconfigured www pair. Update ApplicationDomainsTest accordingly.
This commit is contained in:
Andras Bacsai 2026-08-13 08:58:10 +02:00
parent 37ed725dc1
commit 402dcd7783
3 changed files with 7 additions and 127 deletions

View file

@ -293,9 +293,6 @@ protected function buildDomainRows(): array
$configured[] = $row; $configured[] = $row;
} }
foreach ($this->buildSuggestedWwwRows($configured, $stored, $serviceName) as $suggested) {
$rows[] = $suggested;
}
} }
return $this->sortDomainRowsByDnsStatus($rows); return $this->sortDomainRowsByDnsStatus($rows);
@ -305,7 +302,7 @@ protected function buildDomainRows(): array
$rows[] = $this->domainRowFromStored($url, null, $stored); $rows[] = $this->domainRowFromStored($url, null, $stored);
} }
return $this->sortDomainRowsByDnsStatus(array_merge($rows, $this->buildSuggestedWwwRows($rows, $stored))); return $this->sortDomainRowsByDnsStatus($rows);
} }
/** /**

View file

@ -222,9 +222,6 @@ protected function buildDomainRows(): array
$configured[] = $row; $configured[] = $row;
} }
foreach ($this->buildSuggestedWwwRows($configured, $app, $stored) as $suggested) {
$rows[] = $suggested;
}
} }
return collect($rows) return collect($rows)

View file

@ -780,7 +780,7 @@
]); ]);
}); });
it('shows the missing www counterpart as a suggested domain row', function () { it('does not suggest a missing www counterpart', function () {
$this->application->update([ $this->application->update([
'fqdn' => 'https://example.com', 'fqdn' => 'https://example.com',
'redirect' => 'both', 'redirect' => 'both',
@ -789,31 +789,19 @@
Livewire::test(Domains::class, ['application' => $this->application->fresh()]) Livewire::test(Domains::class, ['application' => $this->application->fresh()])
->assertSet('domainRows.0.url', 'https://example.com') ->assertSet('domainRows.0.url', 'https://example.com')
->assertSet('domainRows.0.is_suggested', false) ->assertSet('domainRows.0.is_suggested', false)
->assertSet('domainRows.1.url', 'https://www.example.com') ->assertCount('domainRows', 1)
->assertSet('domainRows.1.is_suggested', true) ->assertDontSee('Not configured yet.')
->assertSet('domainRows.1.suggestion_label', null) ->assertDontSee('https://www.example.com');
->assertSet('domainRows.1.dns_message', 'Not configured yet.')
->assertSee('Add domain')
->assertSee('Not configured yet.')
->assertDontSee('Not added ·')
->assertDontSee('click Add domain')
->assertDontSee('does not add this automatically')
->assertSee('https://www.example.com');
}); });
it('does not change suggested domain role or persist until Set Direction saves', function () { it('does not persist redirect until Set Direction saves', function () {
$this->application->update([ $this->application->update([
'fqdn' => 'https://example.com', 'fqdn' => 'https://example.com',
'redirect' => 'both', 'redirect' => 'both',
]); ]);
$component = Livewire::test(Domains::class, ['application' => $this->application->fresh()]) $component = Livewire::test(Domains::class, ['application' => $this->application->fresh()])
->assertSet('domainRows.1.suggestion_label', null) ->set('redirect', 'www');
->assertSet('domainRows.1.suggestion_role', 'pair')
->set('redirect', 'www')
// Dropdown alone must not rebuild suggestions or persist redirect.
->assertSet('domainRows.1.suggestion_label', null)
->assertSet('domainRows.1.suggestion_role', 'pair');
expect($this->application->fresh()->redirect)->toBe('both'); expect($this->application->fresh()->redirect)->toBe('both');
@ -1058,47 +1046,6 @@
->toContain('https://www.api.example.com'); ->toContain('https://www.api.example.com');
}); });
it('checks dns on suggested www domain rows', function () {
$settings = InstanceSettings::get();
$settings->is_dns_validation_enabled = true;
$settings->save();
$this->application->update([
'fqdn' => 'https://coolify-dns-pair-test.invalid',
'redirect' => 'both',
]);
$component = Livewire::test(Domains::class, ['application' => $this->application->fresh()])
->assertSet('domainRows.1.url', 'https://www.coolify-dns-pair-test.invalid')
->assertSet('domainRows.1.is_suggested', true)
->call('checkDomainDns', 1);
expect(in_array($component->get('domainRows.1.dns_status'), ['failed', 'ok', 'skipped'], true))->toBeTrue()
->and($component->get('domainRows.1.checked_at'))->not->toBeNull();
$this->application->refresh();
$entry = $this->application->domain_dns_statuses['https://www.coolify-dns-pair-test.invalid'] ?? null;
expect($entry)->toBeArray()
->and($entry['status'] ?? null)->toBe($component->get('domainRows.1.dns_status'))
->and($entry['checked_at'] ?? null)->not->toBeNull();
});
it('adds a suggested domain to the application', function () {
$this->application->update([
'fqdn' => 'https://example.com',
'redirect' => 'both',
]);
Livewire::test(Domains::class, ['application' => $this->application->fresh()])
->call('addSuggestedDomain', 1)
->assertDispatched('success');
$this->application->refresh();
expect(explode(',', (string) $this->application->fqdn))
->toContain('https://example.com')
->toContain('https://www.example.com');
});
it('saves after confirming a domain conflict on add', function () { it('saves after confirming a domain conflict on add', function () {
Application::factory()->create([ Application::factory()->create([
'uuid' => (string) Str::uuid(), 'uuid' => (string) Str::uuid(),
@ -1125,39 +1072,6 @@
expect($this->application->fresh()->fqdn)->toBe('https://shared.example.com'); expect($this->application->fresh()->fqdn)->toBe('https://shared.example.com');
}); });
it('saves a suggested domain after confirming a domain conflict', function () {
Application::factory()->create([
'uuid' => (string) Str::uuid(),
'name' => 'WWW Conflicting App',
'environment_id' => $this->environment->id,
'destination_id' => $this->destination->id,
'destination_type' => $this->destination->getMorphClass(),
'fqdn' => 'https://www.example.com',
'build_pack' => 'nixpacks',
]);
$this->application->update([
'fqdn' => 'https://example.com',
'redirect' => 'both',
]);
Livewire::test(Domains::class, ['application' => $this->application->fresh()])
->call('addSuggestedDomain', 1)
->assertSet('showDomainConflictModal', true)
->assertSet('pendingAction', 'suggested')
->assertSet('forceSaveDomains', false)
->call('confirmDomainUsage')
->assertSet('showDomainConflictModal', false)
->assertSet('pendingAction', null)
->assertSet('forceSaveDomains', false)
->assertDispatched('success');
$this->application->refresh();
expect(explode(',', (string) $this->application->fqdn))
->toContain('https://example.com')
->toContain('https://www.example.com');
});
it('saves after confirming a domain conflict on edit', function () { it('saves after confirming a domain conflict on edit', function () {
Application::factory()->create([ Application::factory()->create([
'uuid' => (string) Str::uuid(), 'uuid' => (string) Str::uuid(),
@ -1418,34 +1332,6 @@
->and($webDomains)->toContain('https://www.web.example.com'); ->and($webDomains)->toContain('https://www.web.example.com');
}); });
it('uses compose service redirect for suggested domain messaging when direction is both', function () {
$this->application->update([
'build_pack' => 'dockercompose',
'fqdn' => null,
'docker_compose_raw' => "services:\n web:\n image: nginx:alpine\n",
'docker_compose_domains' => json_encode([
'web' => ['domain' => 'https://web.example.com', 'redirect' => 'both'],
]),
]);
$component = Livewire::test(Domains::class, ['application' => $this->application->fresh()])
->set('isCompose', true)
->set('composeServices', ['web'])
->set('serviceRedirects.web', 'both');
$component->instance()->domainRows = (function () use ($component) {
$method = new ReflectionMethod($component->instance(), 'buildDomainRows');
return $method->invoke($component->instance());
})();
$suggested = collect($component->get('domainRows'))->firstWhere('is_suggested', true);
expect($suggested)->not->toBeNull()
->and($suggested['suggestion_role'] ?? null)->toBe('pair')
->and($suggested['url'] ?? null)->toBe('https://www.web.example.com');
});
it('updates search engine indexing from the domains view', function () { it('updates search engine indexing from the domains view', function () {
$this->application->update(['fqdn' => 'https://app.example.com,https://staging.example.com']); $this->application->update(['fqdn' => 'https://app.example.com,https://staging.example.com']);