Skip to content

Commit 9f5cf43

Browse files
author
Iker Navarro
committed
chore(test): Change api.lyra.com for static.lyra.com
KJS-4690
1 parent c187e89 commit 9f5cf43

File tree

10 files changed

+303
-307
lines changed

10 files changed

+303
-307
lines changed

gulpfile.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ function replaceKeys() {
2323
return stream.pipe(dest('./examples_build/'))
2424
}
2525

26+
function replaceKeysOnViews() {
27+
let reverse
28+
if (~process.argv.indexOf('--restore')) {
29+
reverse = true
30+
}
31+
let stream = src(['./tests/views/**/*.html'], { base: './' })
32+
Object.entries(keyMap).forEach(([key, value]) => {
33+
stream = stream.pipe(reverse ? replace(value, key) : replace(key, value))
34+
})
35+
return stream.pipe(dest('./'))
36+
}
37+
2638
function devReplaceKeys() {
2739
let reverse
2840
if (~process.argv.indexOf('--restore')) {
@@ -47,3 +59,4 @@ function devReplaceKeys() {
4759

4860
exports.replaceKeys = replaceKeys
4961
exports.devReplaceKeys = devReplaceKeys
62+
exports.replaceKeysOnViews = replaceKeysOnViews

tests/e2e/specs/samples.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test.describe(`Sample embedded examples`, () => {
3737
await expect(page.locator('#test-error')).toBeVisible()
3838

3939
await expect(page.locator('#test-error')).toContainText(
40-
'[~~CHANGE_ME_ENDPOINT~~] is not a valid endpoint domain'
40+
'[INVALID_ENDPOINT] is not a valid endpoint domain'
4141
)
4242
})
4343

@@ -59,7 +59,7 @@ test.describe(`Sample embedded examples`, () => {
5959
await expect(page.locator('#test-error')).toBeVisible()
6060

6161
await expect(page.locator('#test-error')).toContainText(
62-
'[api.lyra.com] is not a valid endpoint domain'
62+
'[static.lyra.com] is not a valid endpoint domain'
6363
)
6464
})
6565

@@ -79,7 +79,7 @@ test.describe(`Sample embedded examples`, () => {
7979
)
8080

8181
await page.evaluate(async () => {
82-
await KRGlue.loadLibrary('https://api.lyra.com', 'INVALID_PUBLIC_KEY')
82+
await KRGlue.loadLibrary('~~CHANGE_ME_ENDPOINT~~', 'INVALID_PUBLIC_KEY')
8383
})
8484

8585
const updatedPK = await page.evaluate(async () => {

tests/scripts/prepare_examples.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ echo "Install server dependencies"
77
npm install
88
cd ../..
99
echo "Replace keys"
10-
npx gulp replaceKeys
10+
npx gulp replaceKeys
11+
npx gulp replaceKeysOnViews

tests/views/addFormMinimal.html

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,48 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5-
<meta
6-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
7-
name="viewport"
8-
/>
9-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
10-
<title>Glue testing view</title>
113

12-
<!-- theme and plugins. should be loaded in the HEAD section -->
13-
<link
14-
rel="stylesheet"
15-
href="https://api.lyra.com/static/js/krypton-client/V4.0/ext/neon-reset.css"
16-
/>
17-
<script src="https://api.lyra.com/static/js/krypton-client/V4.0/ext/neon.js"></script>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
8+
<title>Glue testing view</title>
189

19-
<!-- the component we want to test -->
20-
<script src="/dist/js/kr-payment-form-glue.min.js"></script>
10+
<!-- theme and plugins. should be loaded in the HEAD section -->
11+
<link rel="stylesheet" href="~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon-reset.css" />
12+
<script src="~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon.js"></script>
2113

22-
<script>
23-
document.addEventListener('DOMContentLoaded', event => {
24-
const publicKey =
25-
'69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5'
14+
<!-- the component we want to test -->
15+
<script src="/dist/js/kr-payment-form-glue.min.js"></script>
2616

27-
KRGlue.loadLibrary('https://api.lyra.com', publicKey)
28-
.then(({ KR }) =>
29-
KR.setFormConfig({
30-
formToken: 'DEMO-TOKEN-TO-BE-REPLACED',
31-
language: 'en-EN'
32-
})
33-
)
34-
.then(({ KR }) => KR.addForm('#myPaymentForm'))
35-
.then(({ KR, result }) => KR.showForm(result.formId))
36-
.then(() => {
37-
KR.onFormReady(() => {
38-
let el = document.createElement('div')
39-
el.id = 'test-ready'
40-
document.body.appendChild(el)
41-
})
17+
<script>
18+
document.addEventListener('DOMContentLoaded', event => {
19+
const publicKey =
20+
'69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5'
21+
22+
KRGlue.loadLibrary('~~CHANGE_ME_ENDPOINT~~', publicKey)
23+
.then(({ KR }) =>
24+
KR.setFormConfig({
25+
formToken: 'DEMO-TOKEN-TO-BE-REPLACED',
26+
language: 'en-EN'
27+
})
28+
)
29+
.then(({ KR }) => KR.addForm('#myPaymentForm'))
30+
.then(({ KR, result }) => KR.showForm(result.formId))
31+
.then(() => {
32+
KR.onFormReady(() => {
33+
let el = document.createElement('div')
34+
el.id = 'test-ready'
35+
document.body.appendChild(el)
4236
})
43-
})
44-
</script>
45-
</head>
46-
<body>
47-
<div id="myPaymentForm">
48-
<div class="kr-embedded"></div>
49-
</div>
50-
</body>
51-
</html>
37+
})
38+
})
39+
</script>
40+
</head>
41+
42+
<body>
43+
<div id="myPaymentForm">
44+
<div class="kr-embedded"></div>
45+
</div>
46+
</body>
47+
48+
</html>
Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,54 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5-
<meta
6-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
7-
name="viewport"
8-
/>
9-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
10-
<title>Glue testing view</title>
113

12-
<!-- theme and plugins. should be loaded in the HEAD section -->
13-
<link
14-
rel="stylesheet"
15-
href="https://api.lyra.com/static/js/krypton-client/V4.0/ext/neon-reset.css"
16-
/>
17-
<script src="https://api.lyra.com/static/js/krypton-client/V4.0/ext/neon.js"></script>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
8+
<title>Glue testing view</title>
189

19-
<!-- the component we want to test -->
20-
<script src="/dist/js/kr-payment-form-glue.min.js"></script>
10+
<!-- theme and plugins. should be loaded in the HEAD section -->
11+
<link rel="stylesheet" href="~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon-reset.css" />
12+
<script src="~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon.js"></script>
2113

22-
<script>
23-
document.addEventListener('DOMContentLoaded', event => {
24-
const publicKey =
25-
'69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5'
14+
<!-- the component we want to test -->
15+
<script src="/dist/js/kr-payment-form-glue.min.js"></script>
2616

27-
KRGlue.loadLibrary('api.lyra.com', publicKey)
28-
.then(({ KR }) =>
29-
KR.setFormConfig({
30-
formToken: 'DEMO-TOKEN-TO-BE-REPLACED',
31-
language: 'en-EN'
32-
})
33-
)
34-
.then(({ KR }) => KR.attachForm('#myPaymentForm'))
35-
.then(({ KR, result }) => KR.showForm(result.formId))
36-
.then(() => {
37-
KR.onFormReady(() => {
38-
let el = document.createElement('div')
39-
el.id = 'test-ready'
40-
document.body.appendChild(el)
41-
})
17+
<script>
18+
document.addEventListener('DOMContentLoaded', event => {
19+
const publicKey =
20+
'69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5'
21+
22+
KRGlue.loadLibrary('static.lyra.com', publicKey)
23+
.then(({ KR }) =>
24+
KR.setFormConfig({
25+
formToken: 'DEMO-TOKEN-TO-BE-REPLACED',
26+
language: 'en-EN'
4227
})
43-
.catch(err => {
28+
)
29+
.then(({ KR }) => KR.attachForm('#myPaymentForm'))
30+
.then(({ KR, result }) => KR.showForm(result.formId))
31+
.then(() => {
32+
KR.onFormReady(() => {
4433
let el = document.createElement('div')
45-
el.id = 'test-error'
46-
el.innerHTML = err
34+
el.id = 'test-ready'
4735
document.body.appendChild(el)
4836
})
49-
})
50-
</script>
51-
</head>
52-
<body>
53-
<div id="myPaymentForm">
54-
<div class="kr-embedded"></div>
55-
</div>
56-
</body>
57-
</html>
37+
})
38+
.catch(err => {
39+
let el = document.createElement('div')
40+
el.id = 'test-error'
41+
el.innerHTML = err
42+
document.body.appendChild(el)
43+
})
44+
})
45+
</script>
46+
</head>
47+
48+
<body>
49+
<div id="myPaymentForm">
50+
<div class="kr-embedded"></div>
51+
</div>
52+
</body>
53+
54+
</html>

tests/views/attachFormInvalid.html

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,54 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5-
<meta
6-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
7-
name="viewport"
8-
/>
9-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
10-
<title>Glue testing view</title>
113

12-
<!-- theme and plugins. should be loaded in the HEAD section -->
13-
<link
14-
rel="stylesheet"
15-
href="https://api.lyra.com/static/js/krypton-client/V4.0/ext/neon-reset.css"
16-
/>
17-
<script src="https://api.lyra.com/static/js/krypton-client/V4.0/ext/neon.js"></script>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
8+
<title>Glue testing view</title>
189

19-
<!-- the component we want to test -->
20-
<script src="/dist/js/kr-payment-form-glue.min.js"></script>
10+
<!-- theme and plugins. should be loaded in the HEAD section -->
11+
<link rel="stylesheet" href="~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon-reset.css" />
12+
<script src="~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon.js"></script>
2113

22-
<script>
23-
document.addEventListener('DOMContentLoaded', event => {
24-
const endpoint = '~~CHANGE_ME_ENDPOINT~~'
25-
const publicKey = '~~CHANGE_ME_PUBLIC_KEY~~'
14+
<!-- the component we want to test -->
15+
<script src="/dist/js/kr-payment-form-glue.min.js"></script>
2616

27-
KRGlue.loadLibrary(endpoint, publicKey)
28-
.then(({ KR }) =>
29-
KR.setFormConfig({
30-
formToken: 'DEMO-TOKEN-TO-BE-REPLACED',
31-
language: 'en-EN'
32-
})
33-
)
34-
.then(({ KR }) => KR.attachForm('#myPaymentForm'))
35-
.then(({ KR, result }) => KR.showForm(result.formId))
36-
.then(() => {
37-
KR.onFormReady(() => {
38-
let el = document.createElement('div')
39-
el.id = 'test-ready'
40-
document.body.appendChild(el)
41-
})
17+
<script>
18+
document.addEventListener('DOMContentLoaded', event => {
19+
const endpoint = 'INVALID_ENDPOINT'
20+
const publicKey = '~~CHANGE_ME_PUBLIC_KEY~~'
21+
22+
KRGlue.loadLibrary(endpoint, publicKey)
23+
.then(({ KR }) =>
24+
KR.setFormConfig({
25+
formToken: 'DEMO-TOKEN-TO-BE-REPLACED',
26+
language: 'en-EN'
4227
})
43-
.catch(err => {
28+
)
29+
.then(({ KR }) => KR.attachForm('#myPaymentForm'))
30+
.then(({ KR, result }) => KR.showForm(result.formId))
31+
.then(() => {
32+
KR.onFormReady(() => {
4433
let el = document.createElement('div')
45-
el.id = 'test-error'
46-
el.innerHTML = err
34+
el.id = 'test-ready'
4735
document.body.appendChild(el)
4836
})
49-
})
50-
</script>
51-
</head>
52-
<body>
53-
<div id="myPaymentForm">
54-
<div class="kr-embedded"></div>
55-
</div>
56-
</body>
57-
</html>
37+
})
38+
.catch(err => {
39+
let el = document.createElement('div')
40+
el.id = 'test-error'
41+
el.innerHTML = err
42+
document.body.appendChild(el)
43+
})
44+
})
45+
</script>
46+
</head>
47+
48+
<body>
49+
<div id="myPaymentForm">
50+
<div class="kr-embedded"></div>
51+
</div>
52+
</body>
53+
54+
</html>

0 commit comments

Comments
 (0)