Jack Maclennan Portfolio
    Preparing search index...

    Fixture for Modal within HamburgerMenu.

      public constructor(private readonly page: Page) {
    this.hamburgerMenu = this.page.getByTestId('hamburger-menu');
    this.icon = this.hamburgerMenu.getByTestId('hamburger-icon');
    this.hamburgerModal = new HamburgerModal(page);
    }

    Provides method helpers for locating child elements and interactivity.

    export class HamburgerModal implements Component {
    /** @public Component wrapper. */
    private readonly hamburgerModal: Locator;
    /** @public Child {@link SocialIcons}. */
    private readonly socialIcons: SocialIcons;
    /** @public Child {@link SiteLinks}. */
    private readonly siteLinks: SiteLinks;
    /** @public Child close-icon. */
    private readonly closeIcon: Locator;

    /**
    * @param page - Playwright page object.
    */
    public constructor(private readonly page: Page) {
    this.hamburgerModal = page.getByTestId('hamburger-modal');
    this.socialIcons = new SocialIcons(this.hamburgerModal);
    this.siteLinks = new SiteLinks(this.hamburgerModal);
    this.closeIcon = this.hamburgerModal.getByTestId('hamburger-close');
    }

    /** Getter method. @returns {@link hamburgerModal}. */
    public getWrapper(): Locator {
    return this.hamburgerModal;
    }

    /** Testing helper method. */
    public async rendersCorrectly(): Promise<boolean> {
    if (await this.getWrapper().isHidden()) {
    await expect(this.getSocialIcons().getWrapper(), 'site links hidden when modal closed').toBeHidden();
    await expect(this.getSiteLinks().getWrapper(), 'site links hidden when modal closed').toBeHidden();
    await expect(this.getCloseIcon(), 'close icon hidden when modal closed').toBeHidden();
    await expect(this.getWrapper()).toBeHidden();
    } else {
    expect(await this.getSocialIcons().rendersCorrectly()).toBeTruthy();
    expect(await this.getSiteLinks().rendersCorrectly()).toBeTruthy();
    await expect(this.getCloseIcon(), 'close icon should be visible when modal open').toBeVisible();
    }
    return true;
    }

    /** Getter method. @returns {@link socialIcons}. */
    getSocialIcons(): SocialIcons {
    return this.socialIcons;
    }

    /** Getter method. @returns {@link siteLinks}. */
    getSiteLinks(): SiteLinks {
    return this.siteLinks;
    }

    /** Getter method. @returns {@link closeIcon}. */
    getCloseIcon(): Locator {
    return this.closeIcon;
    }

    /** Closes modal by interacting with {@link closeIcon}. */
    async closeModal(): Promise<void> {
    await expect(this.hamburgerModal, 'modal should be visible').toBeVisible();
    await this.getCloseIcon().click();
    await expect(this.hamburgerModal, 'modal should be hidden').toBeHidden();
    }

    /** Cleans up tests by closing {@link hamburgerModal} if left open. */
    async cleanup(): Promise<void> {
    if (await this.getWrapper().isVisible()) await this.closeModal();
    }
    }

    Implements

    Index

    Constructors

    Properties

    hamburgerModal: Locator

    Component wrapper.

    socialIcons: SocialIcons

    Child SocialIcons.

    siteLinks: SiteLinks

    Child SiteLinks.

    closeIcon: Locator

    Child close-icon.

    page: Page

    Playwright page object.

    Methods