diff --git a/package.json b/package.json index 0df86e20..b5432874 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "from-exponential": "^1.1.1", "i18next": "^20.2.1", "moment": "^2.29.1", + "node-fetch": "^2.6.1", "puppeteer": "^13.6.0", "qrcode": "^1.4.4", "query-string": "^7.0.0", diff --git a/tests/e2e/send-tokens.test.js b/tests/e2e/send-tokens.test.js index 10ff922e..0cfdfe17 100644 --- a/tests/e2e/send-tokens.test.js +++ b/tests/e2e/send-tokens.test.js @@ -1,3 +1,4 @@ +const fetch = require('node-fetch'); const { formatTokenAmount } = require('../utils/string'); const AMOUNT_TO_SEND = 0.0001; @@ -215,6 +216,27 @@ async function fillSendingInfoAndSend(page, name, recipient, previousAmounts) { await sendViewButtonClick(page); } +async function addSonicUser() { + + try { + const body = { + principal: secrets.mainPrincipalId, + } + + const res = await fetch('https://testnet.sonic.ooo/service-http/add-user', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + }); + + if (res.ok) { + console.log('💻 Successfully created added the principal ID to the Sonic testnet.') + } + } catch (error) { + console.error(error); + } +} + describe('Send View', () => { let browser; let page; @@ -223,6 +245,8 @@ describe('Send View', () => { beforeAll(async () => { browser = await setupChrome(); + await addSonicUser(); + // Importing and unlocking the account page = await utils.createNewPage(browser); diff --git a/yarn.lock b/yarn.lock index 4956ce90..bcd7de9b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9183,7 +9183,7 @@ node-addon-api@^2.0.0: resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== -node-fetch@2.6.7: +node-fetch@2.6.7, node-fetch@^2.6.1: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==