-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TESTS-24: feat(tests): done Create project test (#4126)
- Loading branch information
1 parent
69f8cd7
commit 00e0525
Showing
8 changed files
with
185 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<void> { | ||
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() | ||
} | ||
} |
33 changes: 30 additions & 3 deletions
33
tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<void> { | ||
await this.buttonCreateProject.hover() | ||
await this.buttonCreateProject.locator('button.small').click() | ||
} | ||
|
||
async checkProjectExist (projectName: string): Promise<void> { | ||
await expect(this.buttonProjectsParent.filter({ hasText: projectName })).toHaveCount(1) | ||
} | ||
|
||
async checkProjectNotExist (projectName: string): Promise<void> { | ||
await expect(this.buttonProjectsParent.filter({ hasText: projectName })).toHaveCount(0) | ||
} | ||
|
||
async openProject (projectName: string): Promise<void> { | ||
await this.buttonProjectsParent.filter({ hasText: projectName }).click() | ||
} | ||
|
||
async openTemplateForProject (projectName: string): Promise<void> { | ||
await this.page.locator(`a[href$="templates"][href*="${projectName}"]`).click() | ||
} | ||
|
||
async openIssuesForProject (projectName: string): Promise<void> { | ||
await this.page.locator(`a[href$="issues"][href*="${projectName}"]`).click() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters