feat(whatsapp): QWEN primary AI backend, Hermes fallback, conversation history, vehicle persistence, demo prompts
- Add QWEN (qwen3.6) as primary AI backend with short system prompt - Hermes remains as fallback with 45s timeout - Increase QWEN timeout to 35s, max_tokens to 4000 - Add conversation history loading from whatsapp_messages (last 4 msgs) - Persist detected vehicle in whatsapp_sessions table - Add 'limpiar chat' / 'nuevo chat' / 'reset' commands to clear history - Fix CSS conflict: rename whatsapp chat-panel classes to wa-chat-panel - Fix JS ID conflicts with chat.js widget (waChatPanel, waChatMessages, etc.) - Improve no-stock response: conversational with alternatives - Split search_query by | for multi-part lookups - Add DEMO_PROMPTS.md and DEMO_PROMPTS_V2.md
This commit is contained in:
@@ -1,21 +1,71 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
|
||||
test.describe('Nexus POS — Checkout', () => {
|
||||
test('POS sale page loads with cart', async ({ page }) => {
|
||||
await page.goto('/pos/sale');
|
||||
await expect(page.locator('#cartBody, .cart, #cartTable, .pos-cart')).toBeVisible({ timeout: 10000 });
|
||||
const content = await page.locator('body').textContent();
|
||||
expect(content).toMatch(/venta|carrito|total|pagar/i);
|
||||
const FAKE_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjk5OTk5OTk5OTksIm5hbWUiOiJUZXN0IFVzZXIifQ.signature';
|
||||
|
||||
async function setupAuth(page) {
|
||||
await page.goto('/pos/login');
|
||||
await page.evaluate((token) => {
|
||||
localStorage.setItem('pos_token', token);
|
||||
localStorage.setItem('pos_tenant_id', '11');
|
||||
}, FAKE_TOKEN);
|
||||
}
|
||||
|
||||
async function mockPOSAPIs(page) {
|
||||
await page.route('/pos/api/register/current', async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ register: { register_number: 1 } }),
|
||||
});
|
||||
});
|
||||
|
||||
test('catalog search from POS shows results', async ({ page }) => {
|
||||
await page.route(/\/pos\/api\/inventory\/items\?q=.*&per_page=.*/, async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
data: [
|
||||
{
|
||||
id: 1,
|
||||
part_number: 'TEST-001',
|
||||
name: 'Producto de prueba',
|
||||
brand: 'TestBrand',
|
||||
stock: 10,
|
||||
price_1: 100.0,
|
||||
price_2: 90.0,
|
||||
price_3: 80.0,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test.describe('Nexus POS — Checkout', () => {
|
||||
test('POS page loads with cart', async ({ page }) => {
|
||||
await setupAuth(page);
|
||||
await mockPOSAPIs(page);
|
||||
await page.goto('/pos/sale');
|
||||
const searchInput = page.locator('#productSearch, #searchInput, input[placeholder*="buscar" i]').first();
|
||||
await expect(searchInput).toBeVisible({ timeout: 10000 });
|
||||
await searchInput.fill('freno');
|
||||
|
||||
await expect(page).toHaveTitle(/Nexus Autoparts/i);
|
||||
await expect(page.locator('#cartItems')).toBeVisible();
|
||||
await expect(page.locator('#cartBody')).toBeVisible();
|
||||
await expect(page.locator('#btnCobrar')).toBeVisible();
|
||||
});
|
||||
|
||||
test('catalog search from POS', async ({ page }) => {
|
||||
await setupAuth(page);
|
||||
await mockPOSAPIs(page);
|
||||
await page.goto('/pos/sale');
|
||||
|
||||
const searchInput = page.locator('#itemSearch');
|
||||
await expect(searchInput).toBeVisible();
|
||||
await searchInput.fill('test');
|
||||
await searchInput.press('Enter');
|
||||
await page.waitForTimeout(800);
|
||||
const hasDropdown = await page.locator('.search-dropdown, #searchDropdown, .parts-grid').first().isVisible().catch(() => false);
|
||||
expect(hasDropdown || true).toBe(true);
|
||||
|
||||
// Assert search results dropdown/grid appears
|
||||
const results = page.locator('#searchResults');
|
||||
await expect(results).toBeVisible({ timeout: 5000 });
|
||||
await expect(results).toContainText('Producto de prueba');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user