diff --git a/tests/sanity/tests/model/tracker/new-project-page.ts b/tests/sanity/tests/model/tracker/new-project-page.ts new file mode 100644 index 0000000000..44227a9001 --- /dev/null +++ b/tests/sanity/tests/model/tracker/new-project-page.ts @@ -0,0 +1,75 @@ +import { expect, type Locator, type Page } from '@playwright/test' +import { CommonTrackerPage } from './common-tracker-page' +import { NewProject } from './types' + +export class NewProjectPage extends CommonTrackerPage { + readonly page: Page + readonly popupHeader: Locator + readonly inputTitle: Locator + readonly inputIdentifier: Locator + readonly inputDescription: Locator + readonly buttonChooseIcon: Locator + readonly buttonMakePrivate: Locator + readonly buttonCreateProject: Locator + + constructor (page: Page) { + super(page) + this.page = page + this.popupHeader = page.locator('form[id="tracker:string:NewProject"] div[class*="title"]:last-child', { + hasText: 'New project' + }) + this.inputTitle = page.locator('input[placeholder="New project"]') + this.inputIdentifier = page.locator('input[placeholder="PRJCT"]') + this.inputDescription = page.locator('form[id="tracker:string:NewProject"] div.tiptap') + this.buttonChooseIcon = page.locator('div.antiGrid-row button.only-icon') + this.buttonMakePrivate = page.locator('div.antiGrid-row span.toggle-switch') + this.buttonCreateProject = page.locator('form[id="tracker:string:NewProject"] button[type="submit"]') + } + + async createNewProject (data: NewProject): Promise { + await expect(this.popupHeader).toBeVisible() + + if (data.type != null) { + await this.page + .locator('div[class*="header"]', { hasText: 'Project type' }) + .locator('xpath=..') + .locator('button') + .click() + await this.selectMenuItem(this.page, data.type) + } + + if (data.title != null) { + await this.inputTitle.fill(data.title) + } + if (data.identifier != null) { + await this.inputIdentifier.fill(data.identifier) + } + if (data.description != null) { + await this.inputDescription.fill(data.description) + } + if (data.icon != null) { + await this.inputDescription.fill(data.icon) + } + if (data.private != null && data.private) { + await this.buttonMakePrivate.click() + } + if (data.defaultAssigneeForIssues != null) { + await this.page + .locator('div[class*="header"]', { hasText: 'Default assignee for issues' }) + .locator('xpath=..') + .locator('button') + .click() + await this.selectMenuItem(this.page, data.defaultAssigneeForIssues) + } + if (data.defaultIssueStatus != null) { + await this.page + .locator('div[class*="header"]', { hasText: 'Default issue status' }) + .locator('xpath=..') + .locator('button') + .click() + await this.selectFromDropdown(this.page, data.defaultIssueStatus) + } + + await this.buttonCreateProject.click() + } +} diff --git a/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts b/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts index 91e92226fb..cd9b9e09e2 100644 --- a/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts +++ b/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts @@ -1,13 +1,40 @@ -import { type Locator, type Page } from '@playwright/test' +import { expect, type Locator, type Page } from '@playwright/test' export class TrackerNavigationMenuPage { readonly page: Page readonly buttonIssues: Locator - readonly buttonTemplates: Locator + readonly buttonCreateProject: Locator + readonly buttonProjectsParent: Locator constructor (page: Page) { this.page = page this.buttonIssues = page.locator('a span', { hasText: 'Issues' }) - this.buttonTemplates = page.locator('a[href$="templates"]') + this.buttonCreateProject = page.locator('div#tree-projects').locator('xpath=..') + this.buttonProjectsParent = page.locator('div.parent > span') + } + + async pressCreateProjectButton (): Promise { + await this.buttonCreateProject.hover() + await this.buttonCreateProject.locator('button.small').click() + } + + async checkProjectExist (projectName: string): Promise { + await expect(this.buttonProjectsParent.filter({ hasText: projectName })).toHaveCount(1) + } + + async checkProjectNotExist (projectName: string): Promise { + await expect(this.buttonProjectsParent.filter({ hasText: projectName })).toHaveCount(0) + } + + async openProject (projectName: string): Promise { + await this.buttonProjectsParent.filter({ hasText: projectName }).click() + } + + async openTemplateForProject (projectName: string): Promise { + await this.page.locator(`a[href$="templates"][href*="${projectName}"]`).click() + } + + async openIssuesForProject (projectName: string): Promise { + await this.page.locator(`a[href$="issues"][href*="${projectName}"]`).click() } } diff --git a/tests/sanity/tests/model/tracker/types.ts b/tests/sanity/tests/model/tracker/types.ts index 69816deedc..435bc31827 100644 --- a/tests/sanity/tests/model/tracker/types.ts +++ b/tests/sanity/tests/model/tracker/types.ts @@ -15,3 +15,14 @@ export interface Issue { duedate?: string filePath?: string } + +export interface NewProject { + title: string + identifier: string + description: string + private: boolean + defaultAssigneeForIssues: string + defaultIssueStatus: string + icon?: string + type?: string +} diff --git a/tests/sanity/tests/playwright.config.ts b/tests/sanity/tests/playwright.config.ts index 97b3c7e13d..654d3502c6 100644 --- a/tests/sanity/tests/playwright.config.ts +++ b/tests/sanity/tests/playwright.config.ts @@ -19,6 +19,7 @@ const config: PlaywrightTestConfig = { timeout: 15000 }, reporter: [ + ['list'], [ 'allure-playwright', { diff --git a/tests/sanity/tests/tracker/component.spec.ts b/tests/sanity/tests/tracker/component.spec.ts new file mode 100644 index 0000000000..1df9d01101 --- /dev/null +++ b/tests/sanity/tests/tracker/component.spec.ts @@ -0,0 +1,41 @@ +import { expect, test } from '@playwright/test' +import { navigate } from './tracker.utils' +import { generateId, PlatformSetting, PlatformURI, fillSearch } from '../utils' +import { allure } from 'allure-playwright' + +test.use({ + storageState: PlatformSetting +}) + +test.describe('Tracker component tests', () => { + test.beforeEach(async ({ page }) => { + await allure.parentSuite('Tracker tests') + await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() + }) + + test('create-component-issue', async ({ page }) => { + await page.click('[id="app-tracker\\:string\\:TrackerApplication"]') + + await navigate(page) + await page.click('text=Components') + await expect(page).toHaveURL( + `${PlatformURI}/workbench/sanity-ws/tracker/tracker%3Aproject%3ADefaultProject/components` + ) + await page.click('button:has-text("Component")') + await page.click('[placeholder="Component\\ name"]') + const componentName = 'component-' + generateId() + await page.fill('[placeholder="Component\\ name"]', componentName) + + await page.click('button:has-text("Create component")') + + await fillSearch(page, componentName) + + await page.click(`text=${componentName}`) + await page.click('button:has-text("New issue")') + await page.fill('[placeholder="Issue\\ title"]', 'issue') + await page.click('form button:has-text("Component")') + await page.click(`.selectPopup button:has-text("${componentName}")`) + await page.click('form button:has-text("Create issue")') + await page.waitForSelector('form.antiCard', { state: 'detached' }) + }) +}) diff --git a/tests/sanity/tests/tracker/projects.spec.ts b/tests/sanity/tests/tracker/projects.spec.ts index 968535e461..d471ce29c4 100644 --- a/tests/sanity/tests/tracker/projects.spec.ts +++ b/tests/sanity/tests/tracker/projects.spec.ts @@ -1,41 +1,38 @@ -import { expect, test } from '@playwright/test' -import { navigate } from './tracker.utils' -import { generateId, PlatformSetting, PlatformURI, fillSearch } from '../utils' +import { test } from '@playwright/test' +import { PlatformSetting, PlatformURI } from '../utils' import { allure } from 'allure-playwright' +import { TrackerNavigationMenuPage } from '../model/tracker/tracker-navigation-menu-page' +import { NewProjectPage } from '../model/tracker/new-project-page' +import { NewProject } from '../model/tracker/types' test.use({ storageState: PlatformSetting }) -test.describe('component tests', () => { +test.describe('Tracker Projects tests', () => { test.beforeEach(async ({ page }) => { await allure.parentSuite('Tracker tests') await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() }) - test('create-component-issue', async ({ page }) => { - await page.click('[id="app-tracker\\:string\\:TrackerApplication"]') + test('Create project', async ({ page }) => { + const newProjectData: NewProject = { + title: 'TestProject', + identifier: 'QWERT', + description: 'Test Project description', + private: true, + defaultAssigneeForIssues: 'Dirak Kainin', + defaultIssueStatus: 'In Progress' + } - await navigate(page) - await page.click('text=Components') - await expect(page).toHaveURL( - `${PlatformURI}/workbench/sanity-ws/tracker/tracker%3Aproject%3ADefaultProject/components` - ) - await page.click('button:has-text("Component")') - await page.click('[placeholder="Component\\ name"]') - const componentName = 'component-' + generateId() - await page.fill('[placeholder="Component\\ name"]', componentName) + const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page) + await trackerNavigationMenuPage.checkProjectNotExist(newProjectData.title) + await trackerNavigationMenuPage.pressCreateProjectButton() - await page.click('button:has-text("Create component")') + const newProjectPage = new NewProjectPage(page) + await newProjectPage.createNewProject(newProjectData) + await trackerNavigationMenuPage.checkProjectExist(newProjectData.title) - await fillSearch(page, componentName) - - await page.click(`text=${componentName}`) - await page.click('button:has-text("New issue")') - await page.fill('[placeholder="Issue\\ title"]', 'issue') - await page.click('form button:has-text("Component")') - await page.click(`.selectPopup button:has-text("${componentName}")`) - await page.click('form button:has-text("Create issue")') - await page.waitForSelector('form.antiCard', { state: 'detached' }) + await trackerNavigationMenuPage.openProject(newProjectData.title) }) }) diff --git a/tests/sanity/tests/tracker/template.spec.ts b/tests/sanity/tests/tracker/template.spec.ts index 42ab9ad6a6..21df5d8bf8 100644 --- a/tests/sanity/tests/tracker/template.spec.ts +++ b/tests/sanity/tests/tracker/template.spec.ts @@ -34,7 +34,7 @@ test.describe('Tracker template tests', () => { await leftSideMenuPage.buttonTracker.click() const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page) - await trackerNavigationMenuPage.buttonTemplates.click() + await trackerNavigationMenuPage.openTemplateForProject('Default') const templatePage = new TemplatePage(page) await templatePage.createNewTemplate(newTemplate) @@ -67,7 +67,7 @@ test.describe('Tracker template tests', () => { await leftSideMenuPage.buttonTracker.click() const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page) - await trackerNavigationMenuPage.buttonTemplates.click() + await trackerNavigationMenuPage.openTemplateForProject('Default') const templatePage = new TemplatePage(page) await templatePage.createNewTemplate(newTemplate) @@ -122,7 +122,7 @@ test.describe('Tracker template tests', () => { await leftSideMenuPage.buttonTracker.click() const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page) - await trackerNavigationMenuPage.buttonTemplates.click() + await trackerNavigationMenuPage.openTemplateForProject('Default') let templatePage = new TemplatePage(page) await templatePage.createNewTemplate(deleteTemplate) diff --git a/tests/sanity/tests/tracker/tracker.spec.ts b/tests/sanity/tests/tracker/tracker.spec.ts index 0511402f2e..cccb9e0139 100644 --- a/tests/sanity/tests/tracker/tracker.spec.ts +++ b/tests/sanity/tests/tracker/tracker.spec.ts @@ -14,6 +14,7 @@ import { openIssue, toTime } from './tracker.utils' +import { TrackerNavigationMenuPage } from '../model/tracker/tracker-navigation-menu-page' test.use({ storageState: PlatformSetting @@ -45,7 +46,7 @@ test.describe('Tracker tests', () => { async function performPanelTest (statuses: string[], panel: string, mode: string): Promise { const excluded = DEFAULT_STATUSES.filter((status) => !statuses.includes(status)) - await page.locator(`.antiNav-element__dropbox > a > .antiNav-element:has-text("${panel}")`).click() + await new TrackerNavigationMenuPage(page).openIssuesForProject('Default') await page.locator(`.ac-header .overflow-label:has-text("${mode}")`).click() await page.click(ViewletSelectors.Table) for (const s of statuses) {