Skip to content

Commit

Permalink
chore(playwright): fix playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matej Tarca authored and matejtarca committed Oct 19, 2023
1 parent e4c84a0 commit da41c1a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 35 deletions.
14 changes: 10 additions & 4 deletions e2e/applicationForm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ test.describe("application form", () => {

await page.getByRole("button", { name: /^Sign in$/ }).click();

await page.waitForTimeout(2000);

await page.getByRole("link", { name: "Edit application form" }).click();

await expect(
page.getByRole("heading", { name: "Application Form Editor" })
).toBeVisible();

await page.waitForTimeout(2000);

await expect(page.getByText("General info")).toBeVisible();

// Creating and deleting steps
Expand All @@ -49,6 +53,8 @@ test.describe("application form", () => {
// Editing step
await page.getByText("Step #2").click();

await page.waitForTimeout(2000);

await expect(page.getByRole("heading", { name: "Step #2" })).toBeVisible();

await page.getByRole("button", { name: "Edit title" }).click();
Expand All @@ -75,7 +81,7 @@ test.describe("application form", () => {
await page.getByText("Select a field type").click();
await page.getByLabel("textarea").getByText("textarea").click();
await page.getByLabel("Required").check();
await page.getByRole("button", { name: "Create new field" }).click();
await page.getByRole("button", { name: "Save new field" }).click();

await expect(
page.getByText("1. What is your experience with hackathons? (textarea)")
Expand All @@ -88,7 +94,7 @@ test.describe("application form", () => {
await page.getByLabel("Name").fill("hackathonsPast");
await page.getByText("Select a field type").click();
await page.getByLabel("checkbox").getByText("checkbox").click();
await page.getByRole("button", { name: "Create new field" }).click();
await page.getByRole("button", { name: "Save new field" }).click();

await expect(
page.getByText("2. I have been at the hackathon in the past. (checkbox)")
Expand All @@ -99,7 +105,7 @@ test.describe("application form", () => {
await page.getByLabel("Name").fill("company");
await page.getByText("Select a field type").click();
await page.getByLabel("text", { exact: true }).getByText("text").click();
await page.getByRole("button", { name: "Create new field" }).click();
await page.getByRole("button", { name: "Save new field" }).click();

await expect(
page.getByText("3. What company do you work for? (text)")
Expand All @@ -119,7 +125,7 @@ test.describe("application form", () => {
await page.getByLabel("Name").fill("hackathonsPast");
await page.getByText("Select a field type").click();
await page.getByLabel("checkbox").getByText("checkbox").click();
await page.getByRole("button", { name: "Create new field" }).click();
await page.getByRole("button", { name: "Save new field" }).click();

await expect(
page.getByText("3. I have been at the hackathon in the past. (checkbox)")
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@playwright/test": "^1.38.1",
"@playwright/test": "^1.39.0",
"@storybook/addon-essentials": "^7.4.6",
"@storybook/addon-interactions": "^7.4.6",
"@storybook/addon-links": "^7.4.6",
Expand Down
4 changes: 2 additions & 2 deletions src/app/dashboard/application/[applicationId]/detail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const metadata: Metadata = {
title: "Application detail",
};

const DashboardPage = async ({
const ApplicationDetailPage = async ({
params,
}: {
params: { applicationId: string };
Expand All @@ -23,4 +23,4 @@ const DashboardPage = async ({
return <ApplicationDetail applicationDetail={applicationDetail} />;
};

export default DashboardPage;
export default ApplicationDetailPage;
5 changes: 3 additions & 2 deletions src/app/dashboard/form-editor/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export const metadata: Metadata = {
title: "Edit application form",
};

const DashboardPage = async () => {
const FormEditorPage = async () => {
if (!(await requireOrganizerApp())) {
redirect("/application");
}
const applicationFormSteps = await getApplicationFormSteps();

return <ApplicationFormEditor applicationFormSteps={applicationFormSteps} />;
};

export default DashboardPage;
export default FormEditorPage;
9 changes: 7 additions & 2 deletions src/app/dashboard/form-editor/step/[stepId]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ export const metadata: Metadata = {
title: "Edit application form step",
};

const DashboardPage = async ({ params }: { params: { stepId: string } }) => {
const FormEditorStepPage = async ({
params,
}: {
params: { stepId: string };
}) => {
if (!(await requireOrganizerApp())) {
redirect("/application");
}
const stepInfo = await getStepInfo(Number(params.stepId));
const formFieldTypes = await getFormFieldTypes();

return <FormStepEditor stepInfo={stepInfo} formFieldTypes={formFieldTypes} />;
};

export default DashboardPage;
export default FormEditorStepPage;
1 change: 1 addition & 0 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const DashboardPage = async () => {
if (!(await requireOrganizerApp())) {
redirect("/application");
}

return <Dashboard />;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const NewFieldDialog = ({ stepId, formFieldTypes }: Props) => {
)}
/>
<DialogFooter>
<Button type="submit">Create new field</Button>
<Button type="submit">Save new field</Button>
</DialogFooter>
</Stack>
</form>
Expand Down

0 comments on commit da41c1a

Please sign in to comment.