import { page } from "../setup";
import { expect } from "@playwright/test";
import { When, Then, After } from "@cucumber/cucumber";
let names = "";
When("I click choose {string}", async function (pageName: string) {
this.currentPage = pageName;
await page.locator("//div[@class='ml-2 mr-2 mobile-hidden']").waitFor({ state: "visible" });
await page.locator("//div[@class='ml-2 mr-2 mobile-hidden']").click();
await page.getByRole("menuitem", { name: pageName }).click();
});
When("I update my profile with {string} and {string}", async function (firstName: string, lastName: string) {
names = firstName + " " + lastName;
this.oldFirstName = await page.locator('input[name="firstName"]').textContent();
this.oldLastName = await page.locator('input[name="surname"]').textContent();
await page.locator('input[name="firstName"]').fill(firstName);
await page.locator('input[name="surname"]').fill(lastName);
});
When("I click {string} button", async function (buttonText: string) {
this.targetButton = buttonText;
await page.getByRole("button", { name: `${buttonText}` }).click();
});
Then("I should see the information updated successfully", async function () {
await page.getByRole("button", { name: `${names}` }).waitFor();
const displayedtext = await page
.getByRole("button", { name: `${names}` })
.first()
.textContent();
expect(displayedtext).toMatch(`${names}`);
});