import { waitForUpdatesAsync } from '@ni/nimble-components/dist/esm/testing/async-helpers';
/**
 * Page object for the `ok-fv-accordion-item` component to provide consistent
 * ways of querying and interacting with the component during tests.
 */
export class FvAccordionItemPageObject {
    constructor(accordionItemElement) {
        this.accordionItemElement = accordionItemElement;
    }
    async clickSummary() {
        const details = this.getDetails();
        const togglePromise = new Promise(resolve => {
            details.addEventListener('toggle', () => resolve(), { once: true });
        });
        this.getSummary().click();
        await togglePromise;
        await waitForUpdatesAsync();
    }
    getHeaderText() {
        return this.getTitle().textContent?.trim() ?? '';
    }
    isExpanded() {
        return this.getDetails().open;
    }
    hasContentSlot() {
        return !!this.accordionItemElement.shadowRoot?.querySelector('slot');
    }
    hasExpanderIcon() {
        return !!this.accordionItemElement.shadowRoot?.querySelector('nimble-icon-arrow-expander-right');
    }
    getDetails() {
        const details = this.accordionItemElement.shadowRoot?.querySelector('details');
        if (!details) {
            throw new Error('Accordion item details element not found');
        }
        return details;
    }
    getSummary() {
        const summary = this.accordionItemElement.shadowRoot?.querySelector('.accordion-item-summary');
        if (!summary) {
            throw new Error('Accordion item summary element not found');
        }
        return summary;
    }
    getTitle() {
        const title = this.accordionItemElement.shadowRoot?.querySelector('.accordion-item-title');
        if (!title) {
            throw new Error('Accordion item title element not found');
        }
        return title;
    }
}
//# sourceMappingURL=fv-accordion-item.pageobject.js.map