Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/quality-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Quality Gate

on:
pull_request:
push:
branches:
- main

jobs:
quality-gate:
name: quality-gate
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit

- name: Run integration tests
run: npm run test:integration

- name: Build app
run: npm run build

- name: Install Playwright (Chromium)
run: npx playwright install --with-deps chromium

- name: Run E2E smoke tests
run: npm run test:e2e:smoke

known-issues:
name: known-issues
runs-on: ubuntu-latest
continue-on-error: true

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

- name: Run known issues suite
run: |
mkdir -p test-results
set -o pipefail
npm run test:known-issues 2>&1 | tee test-results/known-issues.log

- name: Upload known-issues artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: known-issues-report
path: |
test-results/known-issues.log
test-results/known-issues-junit.xml
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store
.env
.env
playwright-report
test-results
34 changes: 34 additions & 0 deletions BRANCH_IMPLEMENTATION_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Branch implementation notes

## Context
This branch consolidates the test contract stabilization work for the admin catalog flow and the full test gate setup used by this project.

## What was implemented
- Standardized admin mutator return contract in CatalogProvider with explicit `ok`/`error` responses.
- Fixed false negative responses in product mutators caused by state updater timing.
- Updated product mutation actions to validate existence using `productMap` before scheduling state updates:
- `updateProduct`
- `removeProduct`
- `toggleProductVisibility`
- `toggleProductAvailability`
- Preserved existing state update behavior while making API responses deterministic for UI and tests.
- Added/updated automated test layers for gate execution:
- unit tests (Vitest)
- integration tests (provider contracts)
- smoke e2e tests (Playwright)
- Added test configuration files and test documentation used by CI/local gate execution.

## Why this change
- The UI/admin layer expects stable return objects from provider actions.
- Previous implementation could return `{"ok":false,"error":"Produto nao encontrado."}` even when state updates were actually applied.

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

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

Correção de acentuação em documentação: "nao" → "não".

Suggested change
- Previous implementation could return `{"ok":false,"error":"Produto nao encontrado."}` even when state updates were actually applied.
- Previous implementation could return `{"ok":false,"error":"Produto não encontrado."}` even when state updates were actually applied.

Copilot uses AI. Check for mistakes.
- This mismatch was breaking integration tests and could create unreliable feedback in admin screens.

## Validation performed
- `npm run test:unit` passed.
- `npm run test:integration` passed.
- `npm test` (unit + integration + build + smoke e2e) passed.

## Impact
- Deterministic contract for admin product mutations.
- Integration suite no longer fails on false negatives.
- Full test gate is green with the current implementation.
26 changes: 26 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Testing and Deployment Gate

## Stack
- Unit/Integration: Vitest + Testing Library
- E2E smoke: Playwright (Chromium)
- CI pipeline: GitHub Actions (`.github/workflows/quality-gate.yml`)

## Commands
- `npm run test:unit`
- `npm run test:integration`
- `npm run test:e2e:smoke`
- `npm run test:known-issues`
- `npm run test:gate` (unit + integration + build + e2e smoke)

## Gate policy
`test:gate` is the blocking suite for important deploys (push/merge to `main`).

## Known issues policy
`test:known-issues` intentionally tracks unresolved risks and may fail.
In CI it runs in a non-blocking job (`known-issues`) and uploads artifacts.

## Suite layout
- `tests/unit`: deterministic domain/server tests
- `tests/integration`: provider behavior with jsdom
- `tests/e2e/smoke`: user journey smoke coverage
- `tests/known-issues`: regression risks tracked outside gate
9 changes: 5 additions & 4 deletions app/carrinho/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useCart } from "@/components/providers/cart-provider";
import { useToast } from "@/components/providers/toast-provider";
import TransitionLink from "@/components/transition-link";
import WhatsAppAttendantPicker from "@/components/whatsapp-attendant-picker";
import { defaultAttendants, resolveAttendantFlow } from "@/lib/attendants-data";
import { resolveAttendantFlow } from "@/lib/attendants-data";
import { buildAttendantWhatsAppLink, buildWhatsAppMessage, formatCurrency } from "@/lib/store-utils";
import { openWhatsAppLink, resolveWhatsAppAttendantAction } from "@/lib/whatsapp-attendant-flow";

Expand All @@ -17,7 +17,8 @@ export default function CartPage() {
const { showToast } = useToast();
const [isPickerOpen, setIsPickerOpen] = useState(false);
const [pendingMessage, setPendingMessage] = useState("");
const attendantFlow = resolveAttendantFlow(defaultAttendants);
const attendantFlow = resolveAttendantFlow();
const attendants = attendantFlow.attendants;

const message = buildWhatsAppMessage(items, siteSettings);

Expand Down Expand Up @@ -78,7 +79,7 @@ export default function CartPage() {
}

const checkoutMessage = buildWhatsAppMessage(items, siteSettings);
const action = resolveWhatsAppAttendantAction(defaultAttendants, checkoutMessage);
const action = resolveWhatsAppAttendantAction(attendants, checkoutMessage);

if (action.mode === "blocked") {
showToast({
Expand Down Expand Up @@ -221,7 +222,7 @@ export default function CartPage() {

<WhatsAppAttendantPicker
isOpen={isPickerOpen}
attendants={attendantFlow.attendants}
attendants={attendants}
onClose={handleClosePicker}
onSelect={handleSelectAttendant}
/>
Expand Down
4 changes: 2 additions & 2 deletions app/contato/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import WhatsAppAttendantPicker from "@/components/whatsapp-attendant-picker";
import { useCatalog } from "@/components/providers/catalog-provider";
import { useCart } from "@/components/providers/cart-provider";
import { useToast } from "@/components/providers/toast-provider";
import { defaultAttendants, resolveAttendantFlow } from "@/lib/attendants-data";
import { resolveAttendantFlow } from "@/lib/attendants-data";
import { buildAttendantWhatsAppLink, buildWhatsAppMessage } from "@/lib/store-utils";
import { openWhatsAppLink, resolveWhatsAppAttendantAction } from "@/lib/whatsapp-attendant-flow";

Expand All @@ -16,7 +16,7 @@ export default function ContactPage() {
const { showToast } = useToast();
const [isPickerOpen, setIsPickerOpen] = useState(false);
const [pendingMessage, setPendingMessage] = useState("");
const attendantFlow = resolveAttendantFlow(defaultAttendants);
const attendantFlow = resolveAttendantFlow();
const attendants = attendantFlow.attendants;
const message = buildWhatsAppMessage(items, siteSettings);

Expand Down
Loading
Loading