e2e tests
This commit is contained in:
parent
8c33e14fbc
commit
c9dd083eae
6 changed files with 15 additions and 24 deletions
|
|
@ -127,7 +127,7 @@ const FileInput: React.FC<FileInputProps> = ({ label, ...props }) => {
|
||||||
|
|
||||||
{/* File info */}
|
{/* File info */}
|
||||||
{fileInfo && (
|
{fileInfo && (
|
||||||
<div className="flex gap-4 p-4 items-center border-t border-grey-500">
|
<div className="file-info flex gap-4 p-4 items-center border-t border-grey-500">
|
||||||
<FontAwesomeIcon icon={faFile} className="text-amber-500 h-5 w-5" />
|
<FontAwesomeIcon icon={faFile} className="text-amber-500 h-5 w-5" />
|
||||||
<div className="grow">
|
<div className="grow">
|
||||||
<div className="flex justify-between text-sm text-slate-500">
|
<div className="flex justify-between text-sm text-slate-500">
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,7 @@ const ToggleField = ({
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 itens-center">
|
<div className="flex gap-3 itens-center">
|
||||||
<SwitchPrimitive.Root
|
<SwitchPrimitive.Root
|
||||||
className="relative h-[25px] w-[42px] cursor-default rounded-full bg-indigo-900 outline-none"
|
className="toggle-switch relative h-[25px] w-[42px] cursor-default rounded-full bg-indigo-900 outline-none"
|
||||||
checked={checked}
|
|
||||||
onCheckedChange={(isChecked) => handleCheckedChange(isChecked)}
|
onCheckedChange={(isChecked) => handleCheckedChange(isChecked)}
|
||||||
>
|
>
|
||||||
<SwitchPrimitive.Thumb className="block h-[21px] w-[21px] translate-x-0.5 rounded-full bg-white transition-transform duration-100 will-change-transform data-[state=checked]:translate-x-[19px]" />
|
<SwitchPrimitive.Thumb className="block h-[21px] w-[21px] translate-x-0.5 rounded-full bg-white transition-transform duration-100 will-change-transform data-[state=checked]:translate-x-[19px]" />
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export const initialValues: FormValues = {
|
||||||
testingCenter2: "",
|
testingCenter2: "",
|
||||||
testingCenter3: "",
|
testingCenter3: "",
|
||||||
testingCenter4: "",
|
testingCenter4: "",
|
||||||
toleranceWindow: false,
|
toleranceWindow: false
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validationSchema = Yup.object({
|
export const validationSchema = Yup.object({
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ const FormComponent: React.FC = () => {
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{/* Success message - Display a success message if the form has been submitted successfully */}
|
{/* Success message - Display a success message if the form has been submitted successfully */}
|
||||||
{formSubmitted && <div className="sucess-message text-center text-green-500">Success</div>}
|
{formSubmitted && <div className="success-message text-center text-green-500">Success</div>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
import { expect, test } from "@playwright/test"
|
|
||||||
|
|
||||||
test("has title", async ({ page }) => {
|
|
||||||
await page.goto("./")
|
|
||||||
|
|
||||||
await expect(page).toHaveTitle(/Next.js Enterprise Boilerplate/)
|
|
||||||
})
|
|
||||||
|
|
@ -6,11 +6,12 @@ import { expect, test } from "@playwright/test"
|
||||||
test("form loads correctly with initial state", async ({ page }) => {
|
test("form loads correctly with initial state", async ({ page }) => {
|
||||||
await page.goto("/"); //Home URL
|
await page.goto("/"); //Home URL
|
||||||
|
|
||||||
// Check if specific fields are present and empty
|
// Check if specific fields are present and the default selected option is the placeholder value
|
||||||
await expect(page.locator('input[name="importName"]')).toBeEmpty();
|
await expect(page.locator('select[name="importName"] option').first()).toHaveText('Select Import Name:');
|
||||||
await expect(page.locator('input[name="manifestFile"]')).toBeEmpty();
|
|
||||||
|
// Check if the file upload field indicates that no file is selected
|
||||||
|
await expect(page.locator('.file-info')).not.toBeVisible();
|
||||||
|
|
||||||
await expect(page.locator('input[name="toleranceWindow"]')).not.toBeChecked();
|
|
||||||
// Verify that no option is selected initially for "splitSchedule"
|
// Verify that no option is selected initially for "splitSchedule"
|
||||||
await expect(page.locator('input[name="splitSchedule"]:checked')).toHaveCount(0);
|
await expect(page.locator('input[name="splitSchedule"]:checked')).toHaveCount(0);
|
||||||
|
|
||||||
|
|
@ -31,9 +32,6 @@ test("form loads correctly with initial state", async ({ page }) => {
|
||||||
|
|
||||||
// Check if the file name is displayed correctly
|
// Check if the file name is displayed correctly
|
||||||
await expect(page.locator('.file-info')).toHaveText(/testFile.txt/);
|
await expect(page.locator('.file-info')).toHaveText(/testFile.txt/);
|
||||||
|
|
||||||
// Optionally, check for the upload progress bar to reach 100%
|
|
||||||
await expect(page.locator('.upload-progress')).toHaveCSS('width', '100%');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Toggle and submit interactions
|
//Toggle and submit interactions
|
||||||
|
|
@ -41,21 +39,22 @@ test("form loads correctly with initial state", async ({ page }) => {
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
|
|
||||||
// Toggle a switch
|
// Toggle a switch
|
||||||
await page.locator('input[name="toleranceWindow"]').click();
|
await page.locator('.toggle-switch').click();
|
||||||
await expect(page.locator('input[name="toleranceWindow"]')).toBeChecked();
|
// Wait for the 'aria-checked' attribute to become 'true'
|
||||||
|
await expect(page.locator('.toggle-switch')).toHaveAttribute('aria-checked', 'true', { timeout: 5000 });
|
||||||
|
|
||||||
// Fill in other required fields
|
// Fill in other required fields
|
||||||
// Select an option from "importName" dropdown
|
// Select an option from "importName" dropdown
|
||||||
await page.locator('select[name="importName"]').selectOption({ label: "Import ABC" });
|
await page.locator('select[name="importName"]').selectOption({ label: "Import ABC" });
|
||||||
|
|
||||||
// Upload a file for "manifestFile"
|
// Upload a file for "manifestFile"
|
||||||
await page.locator('input[name="manifestFile"]').setInputFiles('/e2e/testFile.txt');
|
await page.locator('input[type="file"]').setInputFiles('/e2e/testFile.txt');
|
||||||
|
|
||||||
// Select an option for "splitSchedule"
|
// Select an option for "splitSchedule"
|
||||||
await page.locator('input[name="splitSchedule"][value="Yes"]').click();
|
await page.locator('button[role="radio"][value="Yes"]').click();
|
||||||
|
|
||||||
// Select an option for "client"
|
// Select an option for "client"
|
||||||
await page.locator('input[name="client"][value="Single"]').click();
|
await page.locator('button[role="radio"][value="Single"]').click();
|
||||||
|
|
||||||
// Enable and click the submit button
|
// Enable and click the submit button
|
||||||
const submitButton = page.locator('button', { hasText: 'Continue Import' });
|
const submitButton = page.locator('button', { hasText: 'Continue Import' });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue