diff --git a/src/services/configuration-service.ts b/src/services/configuration-service.ts index eb1b7c39..9ac7bc33 100644 --- a/src/services/configuration-service.ts +++ b/src/services/configuration-service.ts @@ -40,7 +40,8 @@ export default class ConfigurationService { } if (flags['allowed-hostname']) { - this.configuration.agent['asset-discovery']['allowed-hostnames'] = flags['allowed-hostname'] + this.configuration.agent['asset-discovery']['allowed-hostnames'] = + flags['allowed-hostname'].concat(this.configuration.agent['asset-discovery']['allowed-hostnames']) } if (flags['network-idle-timeout']) { diff --git a/test/services/configuration-service.test.ts b/test/services/configuration-service.test.ts index b1ddbac6..7f9c04ee 100644 --- a/test/services/configuration-service.test.ts +++ b/test/services/configuration-service.test.ts @@ -38,7 +38,7 @@ describe('ConfigurationService', () => { }) describe('#applyFlags', () => { - it('applies flags', () => { + it('applies flags with a .percy.yml', () => { const flags = { 'network-idle-timeout': 51, 'base-url': '/flag/', @@ -52,9 +52,25 @@ describe('ConfigurationService', () => { expect(subject['static-snapshots']['snapshot-files']).to.eql('flags/*.html') expect(subject['static-snapshots']['ignore-files']).to.eql('ignore-flags/*.html') expect(subject.agent['asset-discovery']['network-idle-timeout']).to.eql(51) - expect(subject.agent['asset-discovery']['allowed-hostnames']).to.eql( - ['additional-hostname.local'], - ) + expect(subject.agent['asset-discovery']['allowed-hostnames'][1]).to.eql('localassets.dev') + expect(subject.agent['asset-discovery']['allowed-hostnames'][0]).to.eql('additional-hostname.local') + }) + + it('applies flags without a .percy.yml', () => { + const flags = { + 'network-idle-timeout': 51, + 'base-url': '/flag/', + 'snapshot-files': 'flags/*.html', + 'ignore-files': 'ignore-flags/*.html', + 'allowed-hostname': ['additional-hostname.local'], + } + const subject = new ConfigurationService('test/support/doesnt-exist/.percy.yml').applyFlags(flags) + + expect(subject['static-snapshots']['base-url']).to.eql('/flag/') + expect(subject['static-snapshots']['snapshot-files']).to.eql('flags/*.html') + expect(subject['static-snapshots']['ignore-files']).to.eql('ignore-flags/*.html') + expect(subject.agent['asset-discovery']['network-idle-timeout']).to.eql(51) + expect(subject.agent['asset-discovery']['allowed-hostnames'][0]).to.eql('additional-hostname.local') }) })