import { test as base } from "../conf";
import { RequestPage } from "../../pom/request/request.page";

const test = base.extend<{ requestPage33: RequestPage }>({
    requestPage33: async ({ page, conf }, use) => {
        const requestPage = new RequestPage(page);
        await base.step("Setup: Check the users in this request", async () => {
            await requestPage.getDetailCase(conf.data.case);
            await requestPage.dashboardLoc.buttonByText("Share").click();
            await requestPage.waitForSecond(2);
            const members = (await requestPage.requestLoc.detail.share.listMembers.all()).length;
            if (members !== 3) {
                await requestPage.requestLoc.detail.share.inputEmail.first().fill(conf.data.member_name_delete);
                await requestPage.requestLoc.create.dropdownMemberShare(conf.data.member_name_delete).waitFor({ state: 'visible' });
                await requestPage.requestLoc.create.dropdownMemberShare(conf.data.member_name_delete).click();
                await requestPage.dashboardLoc.buttonByText("Done").first().click();
            }
        });

        await use(requestPage);
    }
});

export { test };
