Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TESTS-24: feat(tests): done Create project test #4126

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions tests/sanity/tests/model/tracker/new-project-page.ts
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 tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts
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()
}
}
11 changes: 11 additions & 0 deletions tests/sanity/tests/model/tracker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions tests/sanity/tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const config: PlaywrightTestConfig = {
timeout: 15000
},
reporter: [
['list'],
[
'allure-playwright',
{
Expand Down
41 changes: 41 additions & 0 deletions tests/sanity/tests/tracker/component.spec.ts
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' })
})
})
47 changes: 22 additions & 25 deletions tests/sanity/tests/tracker/projects.spec.ts
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)
})
})
6 changes: 3 additions & 3 deletions tests/sanity/tests/tracker/template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tests/sanity/tests/tracker/tracker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
openIssue,
toTime
} from './tracker.utils'
import { TrackerNavigationMenuPage } from '../model/tracker/tracker-navigation-menu-page'

test.use({
storageState: PlatformSetting
Expand Down Expand Up @@ -45,7 +46,7 @@ test.describe('Tracker tests', () => {

async function performPanelTest (statuses: string[], panel: string, mode: string): Promise<void> {
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) {
Expand Down