diff --git a/tests/features/owners/add-owner.spec.ts b/tests/features/owners/add-owner.spec.ts index f85028aea..8b4434459 100644 --- a/tests/features/owners/add-owner.spec.ts +++ b/tests/features/owners/add-owner.spec.ts @@ -2,18 +2,22 @@ import { expect } from '@playwright/test'; import { test } from '../../config/test-base'; test.describe('Owners', () => { - test('Add new Owner', async ({ workerId, steps: { pages }, page }) => { - const ownerName = `Test_ownerName + ${workerId}`; - - await test.step('I open Owners page', async () => { + test.beforeEach(async ({ steps: { pages }, page }) => { + await test.step(`I open Owners page`, async () => { await page.goto(''); await pages.topPanel.clickTab('Management'); await pages.management.owners.click(); }); - await test.step("And click on 'Create Owner' button", async () => { + await test.step(`And Click on 'Create owner' button`, async () => { await pages.owners.createOwner.click(); expect(await pages.modals.addOwner.isOpened()).toBeTruthy(); }); + }); + /** + * /project/1/test-cases/1 + */ + test('Add new Owner', async ({ workerId, steps: { pages }, page }) => { + const ownerName = `Test_ownerName + ${workerId}`; await test.step(`I fill owner name ${ownerName} and click 'create' button.`, async () => { await pages.modals.addOwner.ownerNameField.fill(`${ownerName}`); await pages.modals.addOwner.addNewOwner.click(); @@ -22,4 +26,27 @@ test.describe('Owners', () => { expect(await pages.owners.ownersList.isVisible()).toBeTruthy(); }); }); + /** + * /project/1/test-cases/2 + */ + test(`Cleanup input in popup window Owners`, async ({ workerId, steps: { pages } }) => { + const ownerName = `Test_ownerName + ${workerId}`; + await test.step(`I fill owner name ${ownerName} and click 'create' button.`, async () => { + await pages.modals.addOwner.ownerNameField.fill(`${ownerName}`); + }); + await test.step(`I clean the input`, async () => { + await pages.modals.addOwner.ownerNameCleanButton.click(); + expect(await pages.modals.addOwner.ownerNameField.innerText()).toEqual(''); + expect(await pages.modals.addOwner.addNewOwner.isDisabled()).toBeTruthy(); + }); + }); + /** + * /project/1/test-cases/3 + */ + test(`Close the popup window Add owner`, async ({ steps: { pages } }) => { + await test.step(`I close the popup`, async () => { + await pages.modals.addOwner.closeDialog.click(); + expect(await pages.modals.addOwner.dialogTitle.isHidden()).toBeTruthy(); + }); + }); }); diff --git a/tests/features/search/search.spec.ts b/tests/features/search/search.spec.ts index 7528ca4d7..b9da4b48f 100644 --- a/tests/features/search/search.spec.ts +++ b/tests/features/search/search.spec.ts @@ -125,5 +125,17 @@ test.describe('Search by name of data-entity', () => { expect(await pages.catalog.isAlertVisible()).toBeTruthy(); }); }); + /** + * /project/1/test-cases/22 + */ + test(`Cleanup the search bar`, async ({ steps: { pages } }) => { + await test.step(`When fill an expression`, async () => { + await pages.catalog.searchBy('ticket'); + }); + await test.step(`When clean the input`, async () => { + await pages.catalog.cleanSearchBar.click(); + expect(await pages.catalog.searchBar.innerText()).toEqual(''); + }); + }); }); }); diff --git a/tests/features/tags/add-tag.spec.ts b/tests/features/tags/add-tag.spec.ts index 71fc494b3..67bac72c4 100644 --- a/tests/features/tags/add-tag.spec.ts +++ b/tests/features/tags/add-tag.spec.ts @@ -107,4 +107,55 @@ test.describe('Tags', () => { await expect(pages.tags.importantTag(`${tagNamePrefix}_1`)).toBeVisible(); }); }); + /** + * /project/1/test-cases/8 + */ + test(`Cleanup input in popup window Tags`, async ({ steps: { pages } }) => { + await test.step(`I fill the input`, async () => { + await pages.modals.addTag.fillAllTagName('tag'); + }); + await test.step(`I cleanup the input`, async () => { + await pages.modals.addTag.tagNameCleanButton.click(); + expect(await pages.modals.addTag.tagNameField.innerText()).toEqual(''); + expect(await pages.modals.addTag.addNewTag.isDisabled()).toBeTruthy(); + }); + }); + /** + * /project/1/test-cases/11 + */ + test(`Close the popup window Create tag`, async ({ steps: { pages } }) => { + await test.step(`I close the popup`, async () => { + await pages.modals.addTag.closeDialog.click(); + expect(await pages.modals.addTag.dialogTitle.isHidden()).toBeTruthy(); + }); + }); + /** + * /project/1/test-cases/9 + */ + test(`Delete tag in popup window`, async ({ steps: { pages } }) => { + await test.step(`I add one more tag`, async () => { + await pages.modals.addTag.addOneMoreTag.click(); + await expect(pages.modals.addTag.tagNameField.locator).toHaveCount(2); + }); + await test.step(`I delete one tag`, async () => { + await pages.modals.addTag.deleteTag(1); + await expect(pages.modals.addTag.tagNameField.locator).toHaveCount(1); + }); + }); + /** + * /project/1/test-cases/10 + */ + test(`Delete important tag in popup window`, async ({ steps: { pages } }) => { + await test.step(`Add one more tag`, async () => { + await pages.modals.addTag.addOneMoreTag.click(); + await expect(pages.modals.addTag.tagNameField.locator).toHaveCount(2); + }); + await test.step(`Click 'important'`, async () => { + await pages.modals.addTag.checkImportant(1); + }); + await test.step(`Delete important tag`, async () => { + await pages.modals.addTag.deleteTag(1); + await expect(pages.modals.addTag.tagNameField.locator).toHaveCount(1); + }); + }); }); diff --git a/tests/ui/elements/custom-element.ts b/tests/ui/elements/custom-element.ts index 062226071..6987dbad4 100644 --- a/tests/ui/elements/custom-element.ts +++ b/tests/ui/elements/custom-element.ts @@ -1,6 +1,17 @@ import { Locator, Page } from '@playwright/test'; export default class CustomElement { + constructor(protected readonly context: Page, customElement: string | Locator) { + this.customElementContext = this.getLocator(customElement); + } + + /** + * @returns Returns locator of the matching element + */ + get locator(): Locator { + return this.customElementContext; + } + private customElementContext: Locator; /** @@ -27,10 +38,6 @@ export default class CustomElement { this.customElementContext = customElement; } - constructor(protected readonly context: Page, customElement: string | Locator) { - this.customElementContext = this.getLocator(customElement); - } - /** * Wraps the customElementContext in a Proxy class to dynamically deal with loading status before and after each PW command */ diff --git a/tests/ui/pages/catalog/catalog.page.ts b/tests/ui/pages/catalog/catalog.page.ts index 7b9902f94..8619e1fb9 100644 --- a/tests/ui/pages/catalog/catalog.page.ts +++ b/tests/ui/pages/catalog/catalog.page.ts @@ -1,3 +1,4 @@ +import Button from '../../elements/button'; import InputField from '../../elements/input-field'; import List from '../../elements/list'; import TextBox from '../../elements/text-box'; @@ -7,6 +8,7 @@ const SELECTORS = { filterWithSelect: filterName => `#select-label-id:has-text('${filterName}') >> ..`, filterWithInput: filterName => `label:text-is("${filterName}") >> ..`, searchBar: `[placeholder="Search"]`, + cleanSearchBarButton: `[placeholder="Search"] >> .. >> [title="Clear"]`, filterList: `[role="listbox"]`, filterOption: `[role="option"]`, filterWithInputOption: `[role="presentation"]`, @@ -30,6 +32,10 @@ export default class CatalogPage extends BasePage { return new List(this.page, SELECTORS.resultList, SELECTORS.listItem); } + get cleanSearchBar() { + return new Button(this.page, SELECTORS.cleanSearchBarButton); + } + async openFilterWithSelect(filterName: string) { await this.page.locator(SELECTORS.filterWithSelect(filterName)).click(); } diff --git a/tests/ui/pages/modals/add-owner-modal.ts b/tests/ui/pages/modals/add-owner-modal.ts index 793f56b52..061bf0229 100644 --- a/tests/ui/pages/modals/add-owner-modal.ts +++ b/tests/ui/pages/modals/add-owner-modal.ts @@ -1,12 +1,16 @@ import Button from '../../elements/button'; import InputField from '../../elements/input-field'; +import TextBox from '../../elements/text-box'; import { Pages } from '../index'; import BaseModal from './base-modal'; const SELECTORS = { thisDialog: 'div[role="dialog"]', + dialogTitle: 'div[role="dialog"] h2', ownerName: 'input[name="name"]', + ownerNameCleanButton: 'input[name="name"] >> .. >> [type="button"]', addOwner: 'button:has-text("Add new owner")', + closeDialogButton: 'div[role="dialog"] h2 >> [type="button"]', }; export default class AddOwnerModal extends BaseModal { @@ -27,4 +31,16 @@ export default class AddOwnerModal extends BaseModal { get addNewOwner() { return new Button(this.page, SELECTORS.addOwner); } + + get ownerNameCleanButton() { + return new Button(this.page, SELECTORS.ownerNameCleanButton); + } + + get closeDialog() { + return new Button(this.page, SELECTORS.closeDialogButton); + } + + get dialogTitle() { + return new TextBox(this.page, SELECTORS.dialogTitle); + } } diff --git a/tests/ui/pages/modals/add-tag-modal.ts b/tests/ui/pages/modals/add-tag-modal.ts index cdb45df7e..6108377da 100644 --- a/tests/ui/pages/modals/add-tag-modal.ts +++ b/tests/ui/pages/modals/add-tag-modal.ts @@ -1,21 +1,34 @@ import Button from '../../elements/button'; import InputField from '../../elements/input-field'; +import TextBox from '../../elements/text-box'; import { Pages } from '../index'; import BaseModal from './base-modal'; const SELECTORS = { thisDialog: 'div[role="dialog"]', + dialogTitle: 'div[role="dialog"] h2', tagName: '[placeholder="Tag Name"]', + tagNameCleanButton: '[placeholder="Tag Name"] >> .. >> [type="button"]', + closeDialogButton: 'div[role="dialog"] h2 >> [type="button"]', addTag: '[type="submit"]', importantTag: '[type="checkbox"]', addOneMoreTag: 'div[role="dialog"] button:has-text("Create tag")', tagLineRoot: '.infinite-scroll-component', + deleteTagButton: '[type="button"]:has-text("Delete")', }; export default class AddTagModal extends BaseModal { constructor(pages: Pages) { super(pages, SELECTORS.thisDialog); } + get closeDialog() { + return new Button(this.page, SELECTORS.closeDialogButton); + } + + get dialogTitle() { + return new TextBox(this.page, SELECTORS.dialogTitle); + } + get tagNameField() { return new InputField(this.page, SELECTORS.tagName); } @@ -24,6 +37,14 @@ export default class AddTagModal extends BaseModal { return new Button(this.page, SELECTORS.addTag); } + get tagNameCleanButton() { + return new Button(this.page, SELECTORS.tagNameCleanButton); + } + + get deleteButton() { + return new Button(this.page, SELECTORS.deleteTagButton); + } + async checkImportant(indexOfCheckbox: number) { await this.page.locator(SELECTORS.importantTag).nth(indexOfCheckbox).click(); } @@ -32,6 +53,10 @@ export default class AddTagModal extends BaseModal { return new Button(this.page, SELECTORS.addOneMoreTag); } + async deleteTag(numberOfButton: number) { + await this.modal.locator(SELECTORS.deleteTagButton).nth(numberOfButton).click(); + } + async fillAllTagName(name: string) { const newTags = []; const inputCount = await this.page.locator(SELECTORS.tagName).count();