``import { expect } from '@playwright/test';
import { page } from '../setup';
import { Given, When, Then, After } from '@cucumber/cucumber';
const firstName = 'Ha';
const lastName = 'Tran';
const saveBtn = 'Save';
const job = 'Internal Solutions Producer';
const tel = '(568) 853-6415 x80759';
const viewProfile = 'View Profile';
const marketPlace = '/marketplace';
let newUserName, newFullName, jobTitle, telephoneNumber, newjobTitle, newtelephoneNumber;
Given('I am in user profile page', async () => {
const fullName = ${firstName} ${lastName};
await page.goto(${marketPlace});
await page
.getByRole('button', { name: ${fullName} })
.first()
.click();
await page.getByRole('menuitem', { name: ${viewProfile} }).click();
});
When('I update my profile within required fields', async (table) => {
const [profiles] = table.rows();
const newFirstName = profiles[0];
const newLastName = profiles[1];
newFullName = profiles[0] + ' ' + profiles[1];
await page.locator('input[name="firstName"]').fill(newFirstName);
await page.locator('input[name="surname"]').fill(newLastName);
await page.getByRole('button', { name: ${saveBtn} }).click();
await page.getByRole('button', { name: ${saveBtn} }).waitFor({ state: 'hidden' });
await page.getByRole('button', { name: ${newFullName} }).waitFor({ state: 'visible' });
newUserName = await page
.getByRole('button', { name: ${newFullName} })
.first()
.textContent();
});
Then('I should see the full name is updated successfully', async () => {
expect(newUserName).toMatch(newFullName);
});
After({ tags: '@update-profiles' || '@profile-required-fields' } , async () => {
await page.locator('input[name="firstName"]').fill(firstName);
await page.locator('input[name="surname"]').fill(lastName);
await page.locator('input[name="jobTitle"]').fill(job);
await page.locator('input[name="telephoneNumber"]').fill(tel);
await page.getByRole('button', { name: ${saveBtn} }).click();
await page.getByRole('button', { name: ${saveBtn} }).waitFor({ state: 'hidden' });
});```