import { test, expect } from '@playwright/test';

test('Login page', async ({ page }) => {
   // Navigate to the login page
   await page.goto('http://185.100.212.76:8200');
  
   await page.getByPlaceholder('Email').fill('ramkumar@testdomain.local');
   await page.getByPlaceholder('Password').fill('123456');
   await page.waitForTimeout(3000);
   await page.getByRole('button', { name: 'Continue', exact: true }).click();
   await page.waitForTimeout(3000);
   
});
import { test, expect } from '@playwright/test';
import fs from 'fs';

test('Draw walls on canvas using precise coordinates', async ({ page }) => {
  // Setup
  const screenshotDir = 'screenshots';
  fs.mkdirSync(screenshotDir, { recursive: true });

  // Login
  await page.goto('http://185.100.212.76:8200');
  await page.getByPlaceholder('Email').fill('ramkumar@tester.local');
  await page.getByPlaceholder('Password').fill('123456');
  await page.getByRole('button', { name: 'Continue', exact: true }).click();

  // Switch to 2D mode and select wall tool
  await page.locator('.toggle-option:has-text("2d")').click();
  await page.getByTitle('Wall').getByRole('img').click();

  // Take before screenshot
  await page.screenshot({ path: `${screenshotDir}/before.png` });

  // Draw wall using your exact coordinates
  const canvas = page.locator('canvas');
  
  // First wall segment
  await canvas.click({ position: { x: 74, y: 111 } });
  await canvas.click({ position: { x: 733, y: 100 } });
  
  // Second wall segment
  await canvas.click({ position: { x: 733, y: 594 } });
  
  // Third wall segment
  await canvas.click({ position: { x: 60, y: 593 } });
  
  // Fourth wall segment (closing the wall)
  await canvas.click({ position: { x: 74, y: 107 } });
  
  // Finalize with right-click
  await canvas.click({ 
    button: 'right',
    position: { x: 23, y: 129 }
  });

  // Take after screenshot
  const afterPath = `${screenshotDir}/after.png`;
  await page.screenshot({ path: afterPath });

  // Verification
  const canvasData = await canvas.evaluate(el => el.toDataURL());
  expect(canvasData).not.toBe(''); // Canvas should have content

  const beforeImg = fs.readFileSync(`${screenshotDir}/before.png`);
  const afterImg = fs.readFileSync(afterPath);
  expect(beforeImg.equals(afterImg)).toBe(false); // Screenshots should differ
});