Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tests e2e #220

Merged
merged 27 commits into from
Sep 13, 2023
Merged

fix: tests e2e #220

merged 27 commits into from
Sep 13, 2023

Conversation

wisley7l
Copy link
Member

No description provided.

@wisley7l wisley7l changed the title fix(btw): Fix tests e2e [WIP] fix(btw): Fix tests e2e Aug 24, 2023
Copy link
Member

@leomp12 leomp12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O que comentei com você no Slack, até tem um lugar aqui setando env

- shell: bash
env:
ECOM_STORE_ID: ${{ secrets.ECOM_STORE_ID }}
ECOM_AUTHENTICATION_ID: ${{ secrets.ECOM_AUTHENTICATION_ID }}
ECOM_API_KEY: ${{ secrets.ECOM_API_KEY }}
MERCADOPAGO_TOKEN: ${{ secrets.MERCADOPAGO_TOKEN }}
FRENET_TOKEN: ${{ secrets.FRENET_TOKEN }}
GALAXPAY_ID: ${{ secrets.GALAXPAY_ID }}
GALAXPAY_HASH: ${{ secrets.GALAXPAY_HASH }}
INFINITEPAY_ID: ${{ secrets.INFINITEPAY_ID }}
INFINITEPAY_SECRET: ${{ secrets.INFINITEPAY_SECRET }}
run: pnpm build
mas no build (acho que nem precisava de envs dos apps aí inclusive).

Me parece válido criar um build só pros apps inclusive (talvez só sem packages/storefront e stores) e usar aqui, ex:

"test:apps": "turbo run test --filter='./packages/{apps/**,modules}'",

No teste em si não tá setando env vars:

- name: Run tests
shell: bash
run: |
sleep 20
pnpm test:e2e

Então vai emular as functions sem as variáveis de ambiente. Adicionalmente, também não sei se setar elas em env da sessão do bash (como você fez pra build) seria suficiente, o que sabemos é que firebase-tools lê .env, acho que não pega todas as variáveis da sessão não por isso crio o .env aqui por exemplo
" > functions/.env

sleep 10
sleep 20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isso aqui não é bom não...
Precisa mesmo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não precisa não, coloquei so pra verificar umas coisas. Mas já vou voltar.

Comment on lines 15 to 28
try {
req = await fetch(`${modulesUrl}/calculate_shipping?app_id=${appId}`, {
method: 'POST',
body: JSON.stringify(bodyCalculateShipping),
headers: {
'Content-Type': 'application/json',
},
});

data = (await req.json()).result;
} catch (err) {
console.error(err);
}
console.log('>> ', req, ' ', data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try catch em teste ? 🤔

@leomp12
Copy link
Member

leomp12 commented Aug 24, 2023

O que comentei na outra PR é que o scope do commit é test, btw não é o subject 😄
btw é "by the way", o que eu disse foi tipo "a propósito, escopo de commit sobre testes é test", tipo test: Adding first apps e2e tests

@wisley7l wisley7l changed the title [WIP] fix(btw): Fix tests e2e [WIP] fix: tests e2e Aug 25, 2023
Comment on lines 127 to 129
cp functions/.env functions/many/.env
cp functions/.env functions/with-apps/.env
cp functions/.env functions/ssr/.env
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isso daqui não deve ser necessário, se estiver sendo necessário outro comando (do @cloudcommerce/cli) deve rolar antes do teste

Copy link
Member

@leomp12 leomp12 Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const filesToCopy = ['.env', 'config.json', 'ssr/content/settings.json'];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (argv._.includes('deploy')) {
return $firebase('deploy');
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 if (argv._.includes('prepare')) { 
   // prepareCodebase
   // return
 }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloudcommerce prepare && test...

@wisley7l
Copy link
Member Author

@leomp12 estava observando o pipeline do workflow dos teste, os secrets estão mesmo setados?
Pq nos steps que busca os secrets, quando setados eles ficam com ** mas não está aparecendo assim. Digo isso pq fiz outros teste em um fork do cloudcommerce e lá aparece assim.

Comment on lines 182 to 183
await prepareCodebases(true);
return $`echo 'prepare'`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await prepareCodebases(true);
return $`echo 'prepare'`;
return prepareCodebases(false);

Tem nada de echo 😄
Esse argumento booleano aí é o isDev, ele faz preparar o codebase SSR pra dev server, acho que não precisa aqui (e faria o setup dos testes demorar mais)

@leomp12
Copy link
Member

leomp12 commented Aug 28, 2023

@leomp12 estava observando o pipeline do workflow dos teste, os secrets estão mesmo setados?

Tão não, só no https://github.com/ecomplus/store 🤡

@leomp12
Copy link
Member

leomp12 commented Aug 28, 2023

Vou colocar os ECOM_* , mas esses específicos de apps aí ainda não temos...

@leomp12
Copy link
Member

leomp12 commented Aug 29, 2023

mas esses específicos de apps aí ainda não temos

Vamos convencionar um console.warn (== um alerta em stdout em bash) quando não houver a variável de ambiente do app sendo testado, sem quebrar a execução (exit 1) ou falhar o teste.

@wisley7l
Copy link
Member Author

Acabei adicionando o teste para FRENET aqui também, depois que me toquei que deveria ser outra PR.

@wisley7l wisley7l changed the title [WIP] fix: tests e2e fix: tests e2e Sep 13, 2023
Copy link
Member

@leomp12 leomp12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valeu @wisley7l 👍🏾

@leomp12 leomp12 merged commit 1759f0e into main Sep 13, 2023
@leomp12 leomp12 deleted the fix/tests-e2e branch September 13, 2023 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants