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

test.setTimeout(60000); //  Set global timeout before any test runs
test('Verify navigation to Dropdown page works', async ({ page }) => {
  await page.goto('https://the-internet.herokuapp.com/');
  await page.click('text=Dropdown');
  await expect(page).toHaveURL(/dropdown/);
});

test('Test dropdown selection', async ({ page }) => {
  await page.goto('https://the-internet.herokuapp.com/dropdown');
  await page.selectOption('#dropdown', '2');
  await expect(page.locator('#dropdown')).toHaveValue('2');
});

test('Test file upload feature', async ({ page }) => {
  await page.goto('https://the-internet.herokuapp.com/upload');
  const filePath = path.resolve('tests/tests/sample.txt'); // Make sure this file exists
  await page.setInputFiles('#file-upload', filePath);
  await page.click('#file-submit');
  await expect(page.locator('h3')).toHaveText('File Uploaded!');
});
