From 51dcb49f493f940b67a005832ddb414fd8c8003a Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 12 Jul 2024 14:48:06 -0300 Subject: [PATCH 01/20] chore(get-resource): Get resource in API for real testing --- .../test-base/src/get-resource-to-tests.ts | 37 +++++++++++++++++++ packages/test-base/src/index.ts | 2 + 2 files changed, 39 insertions(+) create mode 100644 packages/test-base/src/get-resource-to-tests.ts diff --git a/packages/test-base/src/get-resource-to-tests.ts b/packages/test-base/src/get-resource-to-tests.ts new file mode 100644 index 000000000..f5318630f --- /dev/null +++ b/packages/test-base/src/get-resource-to-tests.ts @@ -0,0 +1,37 @@ +import logger from 'firebase-functions/logger'; +import api from '@cloudcommerce/api'; + +const getProductApi = async (productName?: string) => { + const product = await api.get(`products?limit=1${productName ? `&name=${productName}` : ''}`).then(async ({ data }) => { + if (data.result.length) { + const projectId = data.result[0]._id; + return api.get(`products/${projectId}`).then(({ data: productFound }) => productFound); + } + return null; + }).catch((e) => { + logger.error(e); + throw e; + }); + + return product; +}; + +const getCustomerApi = async (email: string) => { + const customer = await api.get(`customers?main_email=${email}`).then(async ({ data }) => { + if (data.result.length) { + const customerId = data.result[0]._id; + return api.get(`customers/${customerId}`).then(({ data: customerFound }) => customerFound); + } + return null; + }).catch((e) => { + logger.error(e); + throw e; + }); + + return customer; +}; + +export { + getProductApi, + getCustomerApi, +}; diff --git a/packages/test-base/src/index.ts b/packages/test-base/src/index.ts index 3b7cb04a6..34dff8bdd 100644 --- a/packages/test-base/src/index.ts +++ b/packages/test-base/src/index.ts @@ -1,3 +1,5 @@ export * from './endpoints'; export * from './playloads'; + +export * from './get-resource-to-tests'; From e18a1ac16cd274435853040166e225c66fb51701 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 12 Jul 2024 17:20:39 -0300 Subject: [PATCH 02/20] chore(modules): Add more tests --- packages/modules/tests/1-modules.test.ts | 125 ++++++++++++++++++++++- 1 file changed, 123 insertions(+), 2 deletions(-) diff --git a/packages/modules/tests/1-modules.test.ts b/packages/modules/tests/1-modules.test.ts index a043fc4bb..4c38072f4 100644 --- a/packages/modules/tests/1-modules.test.ts +++ b/packages/modules/tests/1-modules.test.ts @@ -1,5 +1,25 @@ -import { describe, test, expect } from 'vitest'; -import { modulesUrl } from '@cloudcommerce/test-base'; +import type { Customers, Products } from '@cloudcommerce/api/types'; +import { + describe, + test, + expect, + beforeAll, +} from 'vitest'; +import { + modulesUrl, + getCustomerApi, + getProductApi, +} from '@cloudcommerce/test-base'; + +const requestApiModule = (moduleName: string, body: {[x:string]: any}) => { + return fetch(`${modulesUrl}/${moduleName}`, { + method: 'POST', + body: JSON.stringify(body), + headers: { + 'Content-Type': 'application/json', + }, + }); +}; describe('Test GET Schemas', async () => { test('@checkout', async () => { @@ -23,3 +43,104 @@ describe('Test GET Schemas', async () => { expect(req.status).toBe(200); }); }); + +describe('Test POST', async () => { + let product: Products | null = null; + let customer: Customers | null = null; + let item; + let to; + let appShipping; + let appPayment; + let shipping; + let transaction; + + beforeAll(async () => { + product = await getProductApi(); + customer = await getCustomerApi('test@test.com'); + }); + + test('calculate_shipping (App Custon shipping)', async () => { + item = { + ...product, + product_id: product?._id, + quantity: 1, + }; + + to = customer?.addresses?.length && { ...customer?.addresses[0] }; + const bodyCalculateShipping = { + to, + items: [item], + }; + const req = await requestApiModule('calculate_shipping', bodyCalculateShipping); + const data = await req.json(); + appShipping = data?.result.find((app) => app.app_id === 1253 + && !app.errors + && app?.response?.shipping_services?.length); + + expect(appShipping).toBeDefined(); + if (to) { + shipping = { + app_id: appShipping.app_id, + to, + service_code: appShipping.response.shipping_services[0].service_code, + }; + } + }); + + test('list_payments (App Custon payment)', async () => { + const bodyListPayments = { + items: [item], + }; + const req = await requestApiModule('list_payments', bodyListPayments); + const data = await req.json(); + appPayment = data?.result.find((app) => app.app_id === 108091 + && !app.errors + && app?.response?.payment_gateways?.length); + + expect(appPayment).toBeDefined(); + const { + label, + payment_method: paymentMethod, + type, + } = appPayment.response.payment_gateways[0]; + transaction = { + app_id: appPayment.app_id, + label, + payment_method: paymentMethod, + type, + buyer: { + email: 'test@test.com', + fullname: 'Usuário Teste', + birth_date: { + day: 1, + month: 1, + year: 1990, + }, + phone: { + number: '999999999', + country_code: 55, + }, + registry_type: 'p', + doc_number: '12345678912', + }, + to, + }; + }); + + test('@checkout', async () => { + const bodyCheckout = { + items: [item], + customer: { + name: { + given_name: 'Teste', + }, + main_email: 'test@test.com', + }, + shipping, + transaction, + }; + const req = await requestApiModule('@checkout', bodyCheckout); + + expect(req.status).toBe(200); + }); +}); From 00dc6510d209f610082dcd4865f9439bd468c171 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 11:30:43 -0300 Subject: [PATCH 03/20] fix(modules): Fix checkout url for test and update test --- packages/modules/src/firebase/checkout.ts | 2 +- packages/modules/tests/1-modules.test.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/modules/src/firebase/checkout.ts b/packages/modules/src/firebase/checkout.ts index c1ac5e89f..b72eef5b9 100644 --- a/packages/modules/src/firebase/checkout.ts +++ b/packages/modules/src/firebase/checkout.ts @@ -27,7 +27,7 @@ type Item = Exclude[number] export default async (req: Request, res: Response) => { const host = req.hostname !== 'localhost' && req.hostname !== '127.0.0.1' ? `https://${req.hostname}` - : 'http://127.0.0.1:5000'; + : 'http://127.0.0.1:5000/_api/modules'; const modulesBaseURL = `${host}${req.url.replace(/\/@?checkout[^/]*$/i, '')}`; const validate = ajv.compile(checkoutSchema.params); diff --git a/packages/modules/tests/1-modules.test.ts b/packages/modules/tests/1-modules.test.ts index 4c38072f4..ec4bc0a2e 100644 --- a/packages/modules/tests/1-modules.test.ts +++ b/packages/modules/tests/1-modules.test.ts @@ -1,4 +1,5 @@ import type { Customers, Products } from '@cloudcommerce/api/types'; +import * as dotenv from 'dotenv'; import { describe, test, @@ -11,7 +12,7 @@ import { getProductApi, } from '@cloudcommerce/test-base'; -const requestApiModule = (moduleName: string, body: {[x:string]: any}) => { +const requestApiModule = (moduleName: string, body) => { return fetch(`${modulesUrl}/${moduleName}`, { method: 'POST', body: JSON.stringify(body), @@ -45,6 +46,7 @@ describe('Test GET Schemas', async () => { }); describe('Test POST', async () => { + dotenv.config(); let product: Products | null = null; let customer: Customers | null = null; let item; @@ -142,5 +144,5 @@ describe('Test POST', async () => { const req = await requestApiModule('@checkout', bodyCheckout); expect(req.status).toBe(200); - }); + }, 10000); }); From ff0de8f17d9edddae83e6e0d5b9e52272f64bb00 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 14:26:36 -0300 Subject: [PATCH 04/20] chore(workflow): check store_id env var --- .github/workflows/test-apps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 8ac9e536a..9b8d040c2 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -137,5 +137,6 @@ jobs: GALAXPAY_ID: ${{ secrets.GALAXPAY_ID }} GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | + echo $ECOM_STORE_ID sleep 10 pnpm test:apps From 2b14f2b63ce13b8f91c6e440d6264ea732c54c93 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 14:45:59 -0300 Subject: [PATCH 05/20] chore(workflow): debug env var --- .github/workflows/test-apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 9b8d040c2..b83167ef3 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -137,6 +137,6 @@ jobs: GALAXPAY_ID: ${{ secrets.GALAXPAY_ID }} GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | - echo $ECOM_STORE_ID + echo "ECOM_STORE_ID is $ECOM_STORE_ID" sleep 10 pnpm test:apps From 593f22a8f6921cf8fdf46545262eb75aaa8139ae Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 14:47:06 -0300 Subject: [PATCH 06/20] chore(workflow): debug env var --- .github/workflows/test-apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index b83167ef3..23dd858f4 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -137,6 +137,6 @@ jobs: GALAXPAY_ID: ${{ secrets.GALAXPAY_ID }} GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | - echo "ECOM_STORE_ID is $ECOM_STORE_ID" + echo "ECOM_STORE_ID is $ECOM_STORE_ID" sleep 10 pnpm test:apps From 1bce688a986518525b5f8b54aa64acf5aadee9a3 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 14:54:24 -0300 Subject: [PATCH 07/20] chore(workflow): remove debug env var --- .github/workflows/test-apps.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 23dd858f4..8ac9e536a 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -137,6 +137,5 @@ jobs: GALAXPAY_ID: ${{ secrets.GALAXPAY_ID }} GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | - echo "ECOM_STORE_ID is $ECOM_STORE_ID" sleep 10 pnpm test:apps From f9ebe9303687312f4c1b1ef22bd5df97633f13f4 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 15:39:39 -0300 Subject: [PATCH 08/20] chore(workflow): set env var in workflow --- .github/workflows/test-apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 8ac9e536a..7bf216496 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -138,4 +138,4 @@ jobs: GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | sleep 10 - pnpm test:apps + ECOM_STORE_ID=$ECOM_STORE_ID ECOM_API_KEY=$ECOM_API_KEY ECOM_AUTHENTICATION_ID=$ECOM_AUTHENTICATION_ID pnpm test:apps From a1d7a8a9dc221562e768c860da39650df0f0fd0f Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 15:45:42 -0300 Subject: [PATCH 09/20] chore(workflow): set env var in workflow --- .github/workflows/test-apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 7bf216496..1eab5283f 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -138,4 +138,4 @@ jobs: GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | sleep 10 - ECOM_STORE_ID=$ECOM_STORE_ID ECOM_API_KEY=$ECOM_API_KEY ECOM_AUTHENTICATION_ID=$ECOM_AUTHENTICATION_ID pnpm test:apps + ECOM_STORE_ID="$ECOM_STORE_ID" ECOM_API_KEY="$ECOM_API_KEY" ECOM_AUTHENTICATION_ID="$ECOM_AUTHENTICATION_ID" pnpm test:apps From 306aec7eb75635cf4853bc96f74e864988f9a3b5 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 1 Aug 2024 15:57:54 -0300 Subject: [PATCH 10/20] chore(workflow): back worflow --- .github/workflows/test-apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 1eab5283f..8ac9e536a 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -138,4 +138,4 @@ jobs: GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | sleep 10 - ECOM_STORE_ID="$ECOM_STORE_ID" ECOM_API_KEY="$ECOM_API_KEY" ECOM_AUTHENTICATION_ID="$ECOM_AUTHENTICATION_ID" pnpm test:apps + pnpm test:apps From c4a5ca0ad21689b99a62cc3750241dcbee121535 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 09:32:40 -0300 Subject: [PATCH 11/20] chore(test-base): check env vars --- packages/test-base/src/get-resource-to-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/test-base/src/get-resource-to-tests.ts b/packages/test-base/src/get-resource-to-tests.ts index f5318630f..9cb1fef19 100644 --- a/packages/test-base/src/get-resource-to-tests.ts +++ b/packages/test-base/src/get-resource-to-tests.ts @@ -2,6 +2,7 @@ import logger from 'firebase-functions/logger'; import api from '@cloudcommerce/api'; const getProductApi = async (productName?: string) => { + console.log('>> env', process.env); const product = await api.get(`products?limit=1${productName ? `&name=${productName}` : ''}`).then(async ({ data }) => { if (data.result.length) { const projectId = data.result[0]._id; From ade38a44a1e4b95821e2d6b771e7fdf134645a09 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 10:00:36 -0300 Subject: [PATCH 12/20] fix(modules): Fix tests --- .github/workflows/test-apps.yml | 4 ++++ packages/modules/tests/1-modules.test.ts | 3 ++- packages/test-base/src/get-resource-to-tests.ts | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 8ac9e536a..3860d6f0b 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -137,5 +137,9 @@ jobs: GALAXPAY_ID: ${{ secrets.GALAXPAY_ID }} GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }} run: | + printf "ECOM_AUTHENTICATION_ID=$ECOM_AUTHENTICATION_ID + ECOM_API_KEY=$ECOM_API_KEY + ECOM_STORE_ID=$ECOM_STORE_ID + " > .env sleep 10 pnpm test:apps diff --git a/packages/modules/tests/1-modules.test.ts b/packages/modules/tests/1-modules.test.ts index ec4bc0a2e..323c91cea 100644 --- a/packages/modules/tests/1-modules.test.ts +++ b/packages/modules/tests/1-modules.test.ts @@ -46,7 +46,8 @@ describe('Test GET Schemas', async () => { }); describe('Test POST', async () => { - dotenv.config(); + dotenv.config({ path: '../../.env' }); + let product: Products | null = null; let customer: Customers | null = null; let item; diff --git a/packages/test-base/src/get-resource-to-tests.ts b/packages/test-base/src/get-resource-to-tests.ts index 9cb1fef19..f5318630f 100644 --- a/packages/test-base/src/get-resource-to-tests.ts +++ b/packages/test-base/src/get-resource-to-tests.ts @@ -2,7 +2,6 @@ import logger from 'firebase-functions/logger'; import api from '@cloudcommerce/api'; const getProductApi = async (productName?: string) => { - console.log('>> env', process.env); const product = await api.get(`products?limit=1${productName ? `&name=${productName}` : ''}`).then(async ({ data }) => { if (data.result.length) { const projectId = data.result[0]._id; From a46d208bcd61f7bbe5901a4f0901e59638e7ede6 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 14:47:33 -0300 Subject: [PATCH 13/20] fix(modules): Fix tests --- packages/modules/tests/1-modules.test.ts | 141 ++++++++++++----------- 1 file changed, 75 insertions(+), 66 deletions(-) diff --git a/packages/modules/tests/1-modules.test.ts b/packages/modules/tests/1-modules.test.ts index 323c91cea..ba0c20efd 100644 --- a/packages/modules/tests/1-modules.test.ts +++ b/packages/modules/tests/1-modules.test.ts @@ -52,98 +52,107 @@ describe('Test POST', async () => { let customer: Customers | null = null; let item; let to; - let appShipping; - let appPayment; + let appShippingCustom; + let appPaymentCustom; let shipping; let transaction; beforeAll(async () => { product = await getProductApi(); customer = await getCustomerApi('test@test.com'); - }); - - test('calculate_shipping (App Custon shipping)', async () => { item = { ...product, product_id: product?._id, quantity: 1, }; - to = customer?.addresses?.length && { ...customer?.addresses[0] }; const bodyCalculateShipping = { to, items: [item], }; - const req = await requestApiModule('calculate_shipping', bodyCalculateShipping); - const data = await req.json(); - appShipping = data?.result.find((app) => app.app_id === 1253 - && !app.errors - && app?.response?.shipping_services?.length); - expect(appShipping).toBeDefined(); - if (to) { - shipping = { - app_id: appShipping.app_id, - to, - service_code: appShipping.response.shipping_services[0].service_code, - }; - } - }); + let req = await requestApiModule('calculate_shipping', bodyCalculateShipping); + let data = await req.json(); + appShippingCustom = data?.result?.find((app) => app.app_id === 1253); - test('list_payments (App Custon payment)', async () => { const bodyListPayments = { items: [item], }; - const req = await requestApiModule('list_payments', bodyListPayments); - const data = await req.json(); - appPayment = data?.result.find((app) => app.app_id === 108091 - && !app.errors - && app?.response?.payment_gateways?.length); - expect(appPayment).toBeDefined(); - const { - label, - payment_method: paymentMethod, - type, - } = appPayment.response.payment_gateways[0]; - transaction = { - app_id: appPayment.app_id, - label, - payment_method: paymentMethod, - type, - buyer: { - email: 'test@test.com', - fullname: 'Usuário Teste', - birth_date: { - day: 1, - month: 1, - year: 1990, - }, - phone: { - number: '999999999', - country_code: 55, + req = await requestApiModule('list_payments', bodyListPayments); + data = await req.json(); + + appPaymentCustom = data?.result.find((app) => app.app_id === 108091); + }); + + // test only if the application is configured + test('calculate_shipping (App Custon shipping)', async () => { + if (appShippingCustom) { + const appShipping = appShippingCustom; + expect(appShipping).toBeDefined(); + if (to) { + shipping = { + app_id: appShipping.app_id, + to, + service_code: appShipping.response.shipping_services[0].service_code, + }; + } + } + }); + + // test only if the application is configured + test('list_payments (App Custon payment)', async () => { + if (appPaymentCustom) { + const appPayment = appPaymentCustom; + + expect(appPayment).toBeDefined(); + const { + label, + payment_method: paymentMethod, + type, + } = appPayment.response.payment_gateways[0]; + transaction = { + app_id: appPayment.app_id, + label, + payment_method: paymentMethod, + type, + buyer: { + email: 'test@test.com', + fullname: 'Usuário Teste', + birth_date: { + day: 1, + month: 1, + year: 1990, + }, + phone: { + number: '999999999', + country_code: 55, + }, + registry_type: 'p', + doc_number: '12345678912', }, - registry_type: 'p', - doc_number: '12345678912', - }, - to, - }; + to, + }; + } }); + /// test only if transaction and delivery are defined test('@checkout', async () => { - const bodyCheckout = { - items: [item], - customer: { - name: { - given_name: 'Teste', + if (shipping && transaction) { + const bodyCheckout = { + items: [item], + customer: { + name: { + given_name: 'Teste', + }, + main_email: 'test@test.com', }, - main_email: 'test@test.com', - }, - shipping, - transaction, - }; - const req = await requestApiModule('@checkout', bodyCheckout); + shipping, + transaction, + }; + const req = await requestApiModule('@checkout', bodyCheckout); - expect(req.status).toBe(200); - }, 10000); + expect(req.status).toBe(200); + } + }); }); From 24c63d111f1a9e8ca16d47823f6eb5bb68576268 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 14:50:55 -0300 Subject: [PATCH 14/20] fix(modules): Fix tests, set timeout in checkout test --- packages/modules/tests/1-modules.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/modules/tests/1-modules.test.ts b/packages/modules/tests/1-modules.test.ts index ba0c20efd..1c6cffe07 100644 --- a/packages/modules/tests/1-modules.test.ts +++ b/packages/modules/tests/1-modules.test.ts @@ -154,5 +154,5 @@ describe('Test POST', async () => { expect(req.status).toBe(200); } - }); + }, 3000); }); From 0be8004c72dea314dff33d0c1f6b7939b4c0c79d Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 14:54:48 -0300 Subject: [PATCH 15/20] fix(modules): Fix tests, set timeout 10000ms --- packages/modules/tests/1-modules.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/modules/tests/1-modules.test.ts b/packages/modules/tests/1-modules.test.ts index 1c6cffe07..93983c952 100644 --- a/packages/modules/tests/1-modules.test.ts +++ b/packages/modules/tests/1-modules.test.ts @@ -154,5 +154,5 @@ describe('Test POST', async () => { expect(req.status).toBe(200); } - }, 3000); + }, 10000); }); From d658c3a162a0adeed24420f5ca28f28ff1a64e80 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 14:59:18 -0300 Subject: [PATCH 16/20] fix(modules): Add debug --- packages/modules/tests/1-modules.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/modules/tests/1-modules.test.ts b/packages/modules/tests/1-modules.test.ts index 93983c952..9a23b3a80 100644 --- a/packages/modules/tests/1-modules.test.ts +++ b/packages/modules/tests/1-modules.test.ts @@ -151,6 +151,7 @@ describe('Test POST', async () => { transaction, }; const req = await requestApiModule('@checkout', bodyCheckout); + console.log('debug ', await req.json()); expect(req.status).toBe(200); } From 54969ae8b00cf8496557e79abfe8cd14fa205e6f Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 15:11:35 -0300 Subject: [PATCH 17/20] chore(modules): Add debug in checkout --- packages/modules/src/firebase/checkout.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/modules/src/firebase/checkout.ts b/packages/modules/src/firebase/checkout.ts index b72eef5b9..8ce9397bf 100644 --- a/packages/modules/src/firebase/checkout.ts +++ b/packages/modules/src/firebase/checkout.ts @@ -28,6 +28,7 @@ export default async (req: Request, res: Response) => { const host = req.hostname !== 'localhost' && req.hostname !== '127.0.0.1' ? `https://${req.hostname}` : 'http://127.0.0.1:5000/_api/modules'; + console.log('>> debug ', host); const modulesBaseURL = `${host}${req.url.replace(/\/@?checkout[^/]*$/i, '')}`; const validate = ajv.compile(checkoutSchema.params); From e00cf7defa36be6375c647d2fcb3c69af9c48487 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 15:21:39 -0300 Subject: [PATCH 18/20] chore(modules): Read firebase-debug --- .github/workflows/test-apps.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 3860d6f0b..9afd07890 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -143,3 +143,8 @@ jobs: " > .env sleep 10 pnpm test:apps + - name: check debug + shell: bash + working-directory: store + run: | + cat firebase-debug.log From dd7f07c7dcb8d220973bbe98cc9692b3db84ddfc Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 15:27:05 -0300 Subject: [PATCH 19/20] chore(modules): Read firebase-debug --- .github/workflows/test-apps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 9afd07890..c3a59235e 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -144,6 +144,7 @@ jobs: sleep 10 pnpm test:apps - name: check debug + if: always() shell: bash working-directory: store run: | From 848db50e6e49e1e2c7580e1a3aee0e5a43bcd7f7 Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 15:35:43 -0300 Subject: [PATCH 20/20] chore(modules): Emulator hosting --- .github/workflows/test-apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index c3a59235e..7d0ac1e18 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -124,7 +124,7 @@ jobs: ECOM_STORE_ID=$ECOM_STORE_ID " > functions/.env npx cloudcommerce prepare - firebase --project=ecom2-demo emulators:start --only functions & + firebase --project=ecom2-demo emulators:start --only functions,hosting & - name: Run tests shell: bash