const { test, expect } = require('@playwright/test');
test.describe('SampleComponent', () => {
test('should submit text and display it correctly', async ({ page }) => {
// Navigate to the page where your component is rendered
await page.goto('http://localhost:3000'); // Change URL to your local app
// Check if the input field, button, and text are present
const input = page.locator('input[placeholder="Enter some text"]');
const button = page.locator('button:has-text("Submit")');
const header = page.locator('h1');
await expect(header).toHaveText('Sample React Component');
// Fill the input field
await input.fill('Hello, Playwright!');
// Click the submit button
await button.click();
// Verify that the submitted text is displayed correctly
const submittedText = page.locator('p');
await expect(submittedText).toHaveText('Submitted Text: Hello, Playwright!');
// Ensure the input field is cleared after submit
await expect(input).toHaveValue('');
});
});