-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for Custom URLs (#2262)
* feat: supporting custom urls * fix: reverting safety checks * feat: using url when resolving * feat: changeset + change in the environments + test
- Loading branch information
1 parent
ea00111
commit 1532d70
Showing
9 changed files
with
134 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@adyen/adyen-web': minor | ||
--- | ||
|
||
Added environmentUrls parameter to Core, which allows PBL to use custom URLs for the API and assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
import { resolveEnvironment } from './Environment'; | ||
import { resolveCDNEnvironment, resolveEnvironment } from './Environment'; | ||
|
||
describe('Environment', () => { | ||
test('resolves set environments', () => { | ||
describe('Resolving API environment', () => { | ||
test('should return the proper URL according to the environment type', () => { | ||
expect(resolveEnvironment('test')).toBe('https://checkoutshopper-test.adyen.com/checkoutshopper/'); | ||
expect(resolveEnvironment('TEST')).toBe('https://checkoutshopper-test.adyen.com/checkoutshopper/'); | ||
expect(resolveEnvironment('live')).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
expect(resolveEnvironment('LIVE')).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
}); | ||
|
||
test('resolves a URL environment', () => { | ||
expect(resolveEnvironment('https://example.com/')).toBe('https://example.com/'); | ||
test('should return environmentUrl if provided', () => { | ||
expect(resolveEnvironment('devl', 'http://localhost:8080/checkoutshopper/')).toBe('http://localhost:8080/checkoutshopper/'); | ||
expect(resolveEnvironment('test', 'https://checkout-zeta.com/checkoutshopper/')).toBe('https://checkout-zeta.com/checkoutshopper/'); | ||
}); | ||
|
||
test('resolves to the live environment as a fallback', () => { | ||
test('should return the live environment URL if environment type is not valid', () => { | ||
expect(resolveEnvironment('invalid-environment')).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
}); | ||
|
||
test('should return the live environment URL if environment type is not provided', () => { | ||
// @ts-ignore It can happen that 'environment' property is not be passed by the merchant | ||
expect(resolveEnvironment()).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
}); | ||
}); | ||
|
||
describe('Resolving CDN Environment', () => { | ||
test('should return the proper URL according to the environment type', () => { | ||
expect(resolveCDNEnvironment('beta')).toBe('https://cdf6519016.cdn.adyen.com/checkoutshopper/'); | ||
expect(resolveCDNEnvironment('BETA')).toBe('https://cdf6519016.cdn.adyen.com/checkoutshopper/'); | ||
expect(resolveCDNEnvironment('live')).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
expect(resolveCDNEnvironment('LIVE')).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
}); | ||
|
||
test('should return environmentUrl if provided', () => { | ||
expect(resolveCDNEnvironment('devl', 'http://localhost:8080/checkoutshopper/')).toBe('http://localhost:8080/checkoutshopper/'); | ||
expect(resolveCDNEnvironment('beta', 'https://testing-beta-cdn.com/')).toBe('https://testing-beta-cdn.com/'); | ||
}); | ||
|
||
test('should return the live environment URL if environment type is not valid', () => { | ||
expect(resolveCDNEnvironment('invalid-environment')).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
}); | ||
|
||
test('should return the live environment URL if environment type is not provided', () => { | ||
// @ts-ignore It can happen that 'environment' property is not be passed by the merchant | ||
expect(resolveCDNEnvironment()).toBe('https://checkoutshopper-live.adyen.com/checkoutshopper/'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.