Skip to content

Commit

Permalink
add sectionsHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
vitPinchuk committed Nov 9, 2024
1 parent 2f527de commit b57a418
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
20 changes: 14 additions & 6 deletions test/panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down
37 changes: 29 additions & 8 deletions test/utils/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,31 @@ class ButtonsHelper {
}
}

/**
* Buttons Helper
*/
class SectionsHelper {
private readonly locator: Locator;
private readonly selectors: LocatorSelectors<typeof TEST_IDS.panel>;

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
*/
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit b57a418

Please sign in to comment.