diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index d63f722..89372c1 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -29,6 +29,8 @@ jobs: run: npm run build - name: No legacy files run: npm run test:files + - name: Footer services + run: npm run test:footer - name: Canonical routes run: npm run test:routes - name: Apache configuration diff --git a/assets/app.js b/assets/app.js index 65983fb..8201c46 100644 --- a/assets/app.js +++ b/assets/app.js @@ -177,7 +177,7 @@ return ` ${ICON.whatsapp}WhatsApp`; diff --git a/package.json b/package.json index 79a1bfd..be52ebd 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,10 @@ }, "scripts": { "test:files": "node tests/clean-files.mjs", + "test:footer": "node tests/footer-services.mjs", "test:routes": "node tests/routes.mjs", "test:server": "node tests/server-config.mjs", - "test": "npm run test:files && npm run test:routes && npm run test:server", + "test": "npm run test:files && npm run test:footer && npm run test:routes && npm run test:server", "build": "node scripts/build-hostinger.mjs" } } diff --git a/tests/footer-services.mjs b/tests/footer-services.mjs new file mode 100644 index 0000000..e2d9d11 --- /dev/null +++ b/tests/footer-services.mjs @@ -0,0 +1,25 @@ +import assert from 'node:assert/strict'; +import fs from 'node:fs'; + +const source = fs.readFileSync('assets/app.js', 'utf8'); +const footerStart = source.indexOf('function footer()'); +const footerEnd = source.indexOf('function trustRail()', footerStart); + +assert.notEqual(footerStart, -1, 'função footer não encontrada'); +assert.notEqual(footerEnd, -1, 'fim da função footer não encontrado'); + +const footerSource = source.slice(footerStart, footerEnd); + +assert.doesNotMatch( + footerSource, + /SERVICES\.slice\s*\(/, + 'o rodapé não pode limitar a quantidade de serviços com slice()' +); + +assert.match( + footerSource, + /SERVICES\.map\s*\(service\s*=>/, + 'o rodapé deve renderizar todos os serviços cadastrados em SERVICES' +); + +console.log('OK: rodapé renderiza todos os serviços cadastrados.');