github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/webui/test/e2e/poms/setupPage.ts (about)

     1  import { Download, Locator, Page } from "@playwright/test";
     2  import { LakeFSCredentials } from "../types";
     3  
     4  export class SetupPage {
     5      private page: Page;
     6  
     7      public emailErrorSelectorText = "Please enter your email address.";
     8      public usernameErrorSelectorText = "Please enter your admin username.";
     9      public usernameInputLocator: Locator;
    10      public downloadCredentialsButtonLocator: Locator;
    11      public goToLoginButtonLocator: Locator;
    12      public setupFinishedTitleLocator: Locator;
    13  
    14      constructor(page: Page) {
    15          this.page = page;
    16          this.usernameInputLocator = this.page.getByPlaceholder("Admin Username");
    17          this.downloadCredentialsButtonLocator = this.page.getByRole("link", { name: "Download credentials" });
    18          this.goToLoginButtonLocator = this.page.getByRole("button", { name: "Go To Login" });
    19          this.setupFinishedTitleLocator = this.page.getByText("You're all set!");
    20      }
    21  
    22      async goto(): Promise<void> {
    23          await this.page.goto("/setup");
    24      }
    25  
    26      async fillForm(email: string, username = "admin", receiveUpdatesChecked = true): Promise<void> {
    27          await this.usernameInputLocator.fill(username);
    28          await this.page.getByLabel("Email").fill(email);
    29          if (receiveUpdatesChecked) {
    30              await this.page.getByLabel("I'd like to receive security, product and feature updates").check();
    31          }
    32          await this.page.getByRole("button", { name: "Setup" }).click();
    33      }
    34  
    35      async donwloadCredentialsButton(): Promise<Download> {
    36          const downloadPromise = this.page.waitForEvent("download");
    37          await this.downloadCredentialsButtonLocator.click();
    38          return downloadPromise;
    39      }
    40  
    41      async goToLoginButton(): Promise<Page> {
    42          const pagePromise = this.page.context().waitForEvent("page");
    43          await this.goToLoginButtonLocator.click();
    44          const newPage = await pagePromise;
    45          return newPage;
    46      }
    47  
    48      async getCredentials(): Promise<LakeFSCredentials> {
    49          const accessKeyId = await this.page.getByRole("code").nth(0).innerText();
    50          const secretAccessKey = await this.page.getByRole("code").nth(1).innerText();
    51          return { accessKeyId, secretAccessKey };
    52      }
    53  }