# Instructions

- Following Playwright test failed.
- Explain why, be concise, respect Playwright best practices.
- Provide a snippet of code with the fix, if possible.

# Test info

- Name: admin.spec.js >> Single-admin counter POS >> admin can sign in and lands on the counter (New Sale)
- Location: tests\e2e\admin.spec.js:15:3

# Error details

```
Error: expect(page).toHaveURL(expected) failed

Expected pattern: /\/admin\/pos/
Received string:  "http://localhost:3002/login"
Timeout: 15000ms

Call log:
  - Expect "toHaveURL" with timeout 15000ms
    33 × locator resolved to <html lang="en">…</html>
       - unexpected value "http://localhost:3002/login"

```

```yaml
- heading "Kathmandu Momo" [level=3]
- paragraph: Administrator sign in
- text: Username
- textbox "Username":
  - /placeholder: admin
  - text: admin
- text: PIN or password
- textbox "PIN or password":
  - /placeholder: ••••
- alert: Invalid username or password
- button "1"
- button "2"
- button "3"
- button "4"
- button "5"
- button "6"
- button "7"
- button "8"
- button "9"
- button "Clear"
- button "0"
- button "Delete last digit"
- button "Sign in" [disabled]
- alert
```

# Test source

```ts
  1  | import { test, expect } from '@playwright/test';
  2  | 
  3  | const ADMIN_USER = process.env.E2E_ADMIN_USER || 'admin';
  4  | const ADMIN_PIN = process.env.E2E_ADMIN_PIN || '1234';
  5  | 
  6  | async function loginAsAdmin(page) {
  7  |   await page.goto('/login');
  8  |   await page.fill('#admin-username', ADMIN_USER);
  9  |   await page.fill('#admin-pin', ADMIN_PIN);
  10 |   await page.getByRole('button', { name: /^Sign in$/i }).click();
> 11 |   await expect(page).toHaveURL(/\/admin\/pos/, { timeout: 15_000 });
     |                      ^ Error: expect(page).toHaveURL(expected) failed
  12 | }
  13 | 
  14 | test.describe('Single-admin counter POS', () => {
  15 |   test('admin can sign in and lands on the counter (New Sale)', async ({ page }) => {
  16 |     await loginAsAdmin(page);
  17 |     await expect(page.getByRole('heading', { name: /Point of Sale/i })).toBeVisible();
  18 |   });
  19 | 
  20 |   test('counter shows the imported menu with prices', async ({ page }) => {
  21 |     await loginAsAdmin(page);
  22 |     await expect(page.getByText('Americano').first()).toBeVisible();
  23 |     await expect(page.getByText(/Rs\.?\s?120/).first()).toBeVisible();
  24 |   });
  25 | 
  26 |   test('variant item is present with its base price', async ({ page }) => {
  27 |     await loginAsAdmin(page);
  28 |     // Search narrows the grid; Mutton Shadeko is a variant item (Boiled 300 / Fried 320).
  29 |     await page.fill('input[placeholder="Search menu…"]', 'Mutton Shadeko');
  30 |     await expect(page.getByText('Mutton Shadeko').first()).toBeVisible();
  31 |     await expect(page.getByText(/Rs\.?\s?300/).first()).toBeVisible();
  32 |   });
  33 | 
  34 |   test('key admin pages have no horizontal overflow on mobile', async ({ page }) => {
  35 |     await loginAsAdmin(page);
  36 |     const routes = [
  37 |       '/admin/pos', '/admin/dashboard', '/admin/orders', '/admin/products',
  38 |       '/admin/inventory', '/admin/reports', '/admin/general-ledger',
  39 |       '/admin/chart-of-accounts', '/admin/expenses', '/admin/settings',
  40 |     ];
  41 |     for (const route of routes) {
  42 |       await page.goto(route, { waitUntil: 'networkidle' });
  43 |       await page.waitForTimeout(300);
  44 |       const overflow = await page.evaluate(() =>
  45 |         document.documentElement.scrollWidth > document.documentElement.clientWidth + 1
  46 |       );
  47 |       expect(overflow, `horizontal overflow on ${route}`).toBe(false);
  48 |     }
  49 |   });
  50 | 
  51 |   test('wrong password is rejected', async ({ page }) => {
  52 |     await page.goto('/login');
  53 |     await page.fill('#admin-username', ADMIN_USER);
  54 |     await page.fill('#admin-pin', 'definitely-wrong-pw');
  55 |     await page.getByRole('button', { name: /^Sign in$/i }).click();
  56 |     await expect(page.getByRole('alert')).toBeVisible();
  57 |     await expect(page).toHaveURL(/\/login/);
  58 |   });
  59 | });
  60 | 
```