diff --git a/test/panel.spec.ts b/test/panel.spec.ts index 21cf023..eb8e661 100644 --- a/test/panel.spec.ts +++ b/test/panel.spec.ts @@ -135,7 +135,9 @@ test.describe('Data Manipulation Panel', () => { await panel.checkIfNoErrors(); await panel.checkPresence(); - await panel.checkSectionPresence('Current Values'); + + const sections = panel.getSections(); + await sections.checkSectionPresence('Current Values'); const elements = panel.getElements(); const disabledMaxElement = await elements.getDisabledElement('max', 'disabled'); @@ -165,7 +167,9 @@ test.describe('Data Manipulation Panel', () => { await panel.checkIfNoErrors(); await panel.checkPresence(); - await panel.checkSectionPresence('Current Values'); + + const sections = panel.getSections(); + await sections.checkSectionPresence('Current Values'); const elements = panel.getElements(); const disabledMaxElement = await elements.getDisabledElement('max', 'disabled'); @@ -221,8 +225,10 @@ test.describe('Data Manipulation Panel', () => { await panel.checkIfNoErrors(); await panel.checkPresence(); - await panel.checkSectionPresence('Current Values'); - await panel.checkSectionPresence('New Values'); + + const sections = panel.getSections(); + await sections.checkSectionPresence('Current Values'); + await sections.checkSectionPresence('New Values'); const elements = panel.getElements(); const disabledMaxElement = await elements.getDisabledElement('max', 'disabled'); @@ -415,12 +421,14 @@ test.describe('Data Manipulation Panel', () => { const elements = panel.getElements(); await elements.checkElementNotPresence('element1', 'string'); - await panel.checkSectionPresence('Section 1'); + + const sections = panel.getSections(); + await sections.checkSectionPresence('Section 1'); /** * Open section */ - await panel.openSection('Section 1'); + await sections.openSection('Section 1'); await elements.checkElementPresence('element1', 'string'); await dashboardPage.refreshDashboard(); diff --git a/test/utils/form.ts b/test/utils/form.ts index cbf6637..9edb3eb 100644 --- a/test/utils/form.ts +++ b/test/utils/form.ts @@ -183,6 +183,31 @@ class ButtonsHelper { } } +/** + * Buttons Helper + */ +class SectionsHelper { + private readonly locator: Locator; + private readonly selectors: LocatorSelectors; + + constructor(parentLocator: Locator) { + this.locator = parentLocator; + this.selectors = getLocatorSelectors(TEST_IDS.panel)(this.locator); + } + + private getMsg(message: string): string { + return `Sections: ${message}`; + } + + public async checkSectionPresence(name: string) { + return expect(this.selectors.splitLayoutContent(name), this.getMsg(`Check ${name} Section`)).toBeVisible(); + } + + public async openSection(name: string) { + return this.selectors.splitLayoutContent(name).click(); + } +} + /** * Panel Editor Helper */ @@ -245,6 +270,10 @@ export class PanelHelper { return new ButtonsHelper(this.locator); } + public getSections() { + return new SectionsHelper(this.locator); + } + public async checkIfNoErrors() { return expect(this.panel.getErrorIcon(), this.getMsg('Check If No Errors')).not.toBeVisible(); } @@ -257,14 +286,6 @@ export class PanelHelper { return expect(this.selectors.infoMessage(), this.getMsg(`Check Alert Message`)).toBeVisible(); } - public async checkSectionPresence(name: string) { - return expect(this.selectors.splitLayoutContent(name), this.getMsg(`Check ${name} Section`)).toBeVisible(); - } - - public async openSection(name: string) { - return this.selectors.splitLayoutContent(name).click(); - } - public async checkErrorMessage() { return expect(this.selectors.errorMessage(), this.getMsg(`Check Error Message`)).toBeVisible(); }