Skip to content

Commit

Permalink
add Date.now to version script url
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbents committed Oct 25, 2023
1 parent 56026bc commit b7b26a4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test(`should load embed script for 'dev'`, async () => {
const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
'https://merchant.revolut.codes/version.js'
expect.stringMatching(/https\:\/\/merchant.revolut.codes\/version.js\?version=\d+/)

Check failure on line 78 in src/index.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `/https\:\/\/merchant.revolut.codes\/version.js\?version=\d+/` with `⏎······/https\:\/\/merchant.revolut.codes\/version.js\?version=\d+/⏎····`

Check failure on line 78 in src/index.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary escape character: \:
)

await TriggerSuccessVersion('abc12345')
Expand Down Expand Up @@ -110,7 +110,7 @@ test(`should load embed script for 'prod'`, async () => {
const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
'https://merchant.revolut.com/version.js'
expect.stringMatching(/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/)

Check failure on line 113 in src/index.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/` with `⏎······/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/⏎····`

Check failure on line 113 in src/index.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary escape character: \:
)

await TriggerSuccessVersion('abc12345')
Expand Down Expand Up @@ -146,7 +146,7 @@ test(`should load embed script for 'sandbox'`, async () => {
const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
'https://sandbox-merchant.revolut.com/version.js'
expect.stringMatching(/https\:\/\/sandbox-merchant.revolut.com\/version.js\?version=\d+/)

Check failure on line 149 in src/index.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `/https\:\/\/sandbox-merchant.revolut.com\/version.js\?version=\d+/` with `⏎······/https\:\/\/sandbox-merchant.revolut.com\/version.js\?version=\d+/⏎····`

Check failure on line 149 in src/index.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary escape character: \:
)

await TriggerSuccessVersion('abc12345')
Expand Down
8 changes: 4 additions & 4 deletions src/payments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test(`should load embed script for 'dev'`, async () => {
const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
'https://merchant.revolut.codes/version.js'
expect.stringMatching(/https\:\/\/merchant.revolut.codes\/version.js\?version=\d+/)

Check failure on line 88 in src/payments.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `/https\:\/\/merchant.revolut.codes\/version.js\?version=\d+/` with `⏎······/https\:\/\/merchant.revolut.codes\/version.js\?version=\d+/⏎····`

Check failure on line 88 in src/payments.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary escape character: \:
)

await TriggerSuccessVersion('abc12345')
Expand Down Expand Up @@ -128,7 +128,7 @@ test(`should load embed script for 'prod'`, async () => {
const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
'https://merchant.revolut.com/version.js'
expect.stringMatching(/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/)

Check failure on line 131 in src/payments.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/` with `⏎······/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/⏎····`

Check failure on line 131 in src/payments.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary escape character: \:
)

await TriggerSuccessVersion('abc12345')
Expand Down Expand Up @@ -171,7 +171,7 @@ test(`should load embed script for 'sandbox'`, async () => {
const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
'https://sandbox-merchant.revolut.com/version.js'
expect.stringMatching(/https\:\/\/sandbox-merchant.revolut.com\/version.js\?version=\d+/)
)

await TriggerSuccessVersion('abc12345')
Expand Down Expand Up @@ -236,7 +236,7 @@ test(`should use 'prod' by default`, async () => {
const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
'https://merchant.revolut.com/version.js'
expect.stringMatching(/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/)
)

await TriggerSuccessVersion('')
Expand Down
18 changes: 18 additions & 0 deletions src/upsell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ test(`should load embed script for 'dev'`, async () => {
mode: 'dev',
publicToken: 'MERCHANT_PUBLIC_TOKEN_DEV_XXX',
})

const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
expect.stringMatching(/https\:\/\/merchant.revolut.codes\/version.js\?version=\d+/)
)

await TriggerSuccessVersion('abc12345')

Expand Down Expand Up @@ -102,6 +108,12 @@ test(`should load embed script for 'prod'`, async () => {
publicToken: 'MERCHANT_PUBLIC_TOKEN_PROD_XXX',
})

const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
expect.stringMatching(/https\:\/\/merchant.revolut.com\/version.js\?version=\d+/)
)

await TriggerSuccessVersion('abc12345')

const embedScript = document.querySelector('script#revolut-upsell')
Expand Down Expand Up @@ -137,6 +149,12 @@ test(`should load embed script for 'sandbox'`, async () => {
publicToken: 'MERCHANT_PUBLIC_TOKEN_SANDBOX_XXX',
})

const versionScript = document.querySelector('script#revolut-pay-version')
expect(versionScript).toHaveAttribute(
'src',
expect.stringMatching(/https\:\/\/sandbox-merchant.revolut.com\/version.js\?version=\d+/)
)

await TriggerSuccessVersion('abc12345')

const embedScript = document.querySelector('script#revolut-upsell')
Expand Down
4 changes: 2 additions & 2 deletions src/versionLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MODE, URLS } from './constants'
import { Mode } from './types'
import { loadModule } from './utils'
import { getVersionedUrl, loadModule } from './utils'

let loadedVersion: string = null

Expand All @@ -12,7 +12,7 @@ export function RevolutPaymentsVersionLoader(
}

return loadModule({
src: URLS[mode].version,
src: getVersionedUrl(URLS[mode].version, `${Date.now()}`),
id: 'revolut-pay-version',
name: 'RevolutPayVersion',
})
Expand Down

0 comments on commit b7b26a4

Please sign in to comment.