mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-18 14:23:15 +00:00
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:
@@ -293,9 +293,6 @@ class Domains extends Component
|
||||
$configured[] = $row;
|
||||
}
|
||||
|
||||
foreach ($this->buildSuggestedWwwRows($configured, $stored, $serviceName) as $suggested) {
|
||||
$rows[] = $suggested;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->sortDomainRowsByDnsStatus($rows);
|
||||
@@ -305,7 +302,7 @@ class Domains extends Component
|
||||
$rows[] = $this->domainRowFromStored($url, null, $stored);
|
||||
}
|
||||
|
||||
return $this->sortDomainRowsByDnsStatus(array_merge($rows, $this->buildSuggestedWwwRows($rows, $stored)));
|
||||
return $this->sortDomainRowsByDnsStatus($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -222,9 +222,6 @@ class Domains extends Component
|
||||
$configured[] = $row;
|
||||
}
|
||||
|
||||
foreach ($this->buildSuggestedWwwRows($configured, $app, $stored) as $suggested) {
|
||||
$rows[] = $suggested;
|
||||
}
|
||||
}
|
||||
|
||||
return collect($rows)
|
||||
|
||||
@@ -780,7 +780,7 @@ it('normalizes domains before saving', function () {
|
||||
]);
|
||||
});
|
||||
|
||||
it('shows the missing www counterpart as a suggested domain row', function () {
|
||||
it('does not suggest a missing www counterpart', function () {
|
||||
$this->application->update([
|
||||
'fqdn' => 'https://example.com',
|
||||
'redirect' => 'both',
|
||||
@@ -789,31 +789,19 @@ it('shows the missing www counterpart as a suggested domain row', function () {
|
||||
Livewire::test(Domains::class, ['application' => $this->application->fresh()])
|
||||
->assertSet('domainRows.0.url', 'https://example.com')
|
||||
->assertSet('domainRows.0.is_suggested', false)
|
||||
->assertSet('domainRows.1.url', 'https://www.example.com')
|
||||
->assertSet('domainRows.1.is_suggested', true)
|
||||
->assertSet('domainRows.1.suggestion_label', null)
|
||||
->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');
|
||||
->assertCount('domainRows', 1)
|
||||
->assertDontSee('Not configured yet.')
|
||||
->assertDontSee('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([
|
||||
'fqdn' => 'https://example.com',
|
||||
'redirect' => 'both',
|
||||
]);
|
||||
|
||||
$component = Livewire::test(Domains::class, ['application' => $this->application->fresh()])
|
||||
->assertSet('domainRows.1.suggestion_label', null)
|
||||
->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');
|
||||
->set('redirect', 'www');
|
||||
|
||||
expect($this->application->fresh()->redirect)->toBe('both');
|
||||
|
||||
@@ -1058,47 +1046,6 @@ it('recovers when serviceRedirects.api is corrupted to a nested array by dotted
|
||||
->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 () {
|
||||
Application::factory()->create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
@@ -1125,39 +1072,6 @@ it('saves after confirming a domain conflict on add', function () {
|
||||
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 () {
|
||||
Application::factory()->create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
@@ -1418,34 +1332,6 @@ it('auto-adds missing www pair for a single compose service redirect', function
|
||||
->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 () {
|
||||
$this->application->update(['fqdn' => 'https://app.example.com,https://staging.example.com']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user