TESTS-85: feat(tests): added issues.spec.ts test (#4025)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2023-11-22 12:14:26 +03:00 committed by GitHub
parent bf68a5c00e
commit d4907ce578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 134 additions and 9 deletions

View File

@ -198,6 +198,13 @@ jobs:
with:
name: playwright-results
path: ./tests/sanity/playwright-report/
- name: Get Allure history
uses: actions/checkout@v2
if: ${{ github.ref == 'refs/heads/main' }}
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: Generates Allure Report
uses: simple-elf/allure-report-action@master
if: always()

View File

@ -12,6 +12,9 @@ node ../dev/tool/bundle.js create-workspace sanity-ws -o SanityTest
# Create user record in accounts
node ../dev/tool/bundle.js create-account user1 -f John -l Appleseed -p 1234
node ../dev/tool/bundle.js confirm-email user1
# Create second user record in accounts
node ../dev/tool/bundle.js create-account user2 -f Kainin -l Numoin -p 1234
node ../dev/tool/bundle.js confirm-email user2
# Restore workspace contents in mongo/elastic
@ -21,6 +24,7 @@ node ../dev/tool/bundle.js upgrade-workspace sanity-ws
# Re-assign user to workspace.
node ../dev/tool/bundle.js assign-workspace user1 sanity-ws
node ../dev/tool/bundle.js assign-workspace user2 sanity-ws
node ../dev/tool/bundle.js configure sanity-ws --enable=*
node ../dev/tool/bundle.js configure sanity-ws --list

View File

@ -10,8 +10,11 @@ docker-compose -p sanity up -d --force-recreate --renew-anon-volumes
./tool.sh create-workspace sanity-ws -o SanityTest
# Create user record in accounts
./tool.sh create-account user1 -f John -l Appleseed -p 1234
./tool.sh create-account user2 -f Kainin -l Dirak -p 1234
# Make user the workspace maintainer
./tool.sh set-user-role user1 sanity-ws 1
./tool.sh confirm-email user1
./tool.sh set-user-role user2 sanity-ws 1
./tool.sh confirm-email user2
./restore-workspace.sh

View File

@ -7,6 +7,7 @@
# Re-assign user to workspace.
./tool.sh assign-workspace user1 sanity-ws
./tool.sh assign-workspace user2 sanity-ws
./tool.sh configure sanity-ws --enable=*
./tool.sh configure sanity-ws --list

View File

@ -1,5 +1,7 @@
PLATFORM_URI='http://localhost:8083'
PLATFORM_TRANSACTOR='ws://localhost:3334'
PLATFORM_USER='user1'
PLATFORM_USER_SECOND='user2'
PLATFORM_TOKEN='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InVzZXIxIiwid29ya3NwYWNlIjoic2FuaXR5LXdzIn0.hfUCqePHO-WNps2by4B-CYGKIpDpLG0WVCUUtU-SVI4'
SETTING=storage.json
SETTING=storage.json
SETTING_SECOND=storageSecond.json

View File

@ -0,0 +1,34 @@
{
"cookies": [],
"origins": [
{
"origin": "http://localhost:8083",
"localStorage": [
{
"name": "login:metadata:LoginEmail",
"value": "user2"
},
{
"name": "login:metadata:LoginTokens",
"value": "{\"sanity-ws\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb25maXJtZWQiOnRydWUsImVtYWlsIjoidXNlcjIiLCJ3b3Jrc3BhY2UiOiJzYW5pdHktd3MiLCJwcm9kdWN0SWQiOiIifQ.810B-zY0JjmKWTeTNmhUWKPY4wkp5hGX3Ng6Y73NK7I\"}"
},
{
"name": "login:metadata:LoginEndpoint",
"value": "ws://localhost:3334"
},
{
"name": "#platform.notification.logging",
"value": "false"
},
{
"name": "#platform.lazy.loading",
"value": "false"
},
{
"name": "flagOpenInDesktopApp",
"value": "true"
}
]
}
]
}

View File

@ -0,0 +1,67 @@
import { test } from '@playwright/test'
import { generateId, getSecondPage, PlatformSetting, PlatformURI } from '../utils'
import { allure } from 'allure-playwright'
import { NewIssue } from '../model/tracker/types'
import { IssuesPage } from '../model/tracker/issues-page'
import { LeftSideMenuPage } from '../model/left-side-menu-page'
import { IssuesDetailsPage } from '../model/tracker/issues-details-page'
test.use({
storageState: PlatformSetting
})
test.describe('Collaborative test for issue', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Collaborative test')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished()
})
test('Issues can be assigned to another users', async ({ page, browser }) => {
const newIssue: NewIssue = {
title: `Collaborative test for issue-${generateId()}`,
description: 'Collaborative test for issue',
status: 'Backlog',
priority: 'Urgent',
assignee: 'Appleseed John',
createLabel: true,
labels: `CREATE-ISSUE-${generateId()}`,
component: 'No component',
estimation: '2',
milestone: 'No Milestone',
duedate: 'today',
filePath: 'cat.jpeg'
}
// open second page
const userSecondPage = await getSecondPage(browser)
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished()
const leftSideMenuPageSecond = new LeftSideMenuPage(userSecondPage)
await leftSideMenuPageSecond.buttonTracker.click()
const issuesPageSecond = new IssuesPage(userSecondPage)
await issuesPageSecond.linkSidebarAll.click()
await issuesPageSecond.modelSelectorAll.click()
// create a new issue by first user
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/tracker/`))?.finished()
const leftSideMenuPage = new LeftSideMenuPage(page)
await leftSideMenuPage.buttonTracker.click()
const issuesPage = new IssuesPage(page)
await issuesPage.createNewIssue(newIssue)
await issuesPage.linkSidebarAll.click()
await issuesPage.modelSelectorAll.click()
await issuesPage.searchIssueByName(newIssue.title)
await issuesPage.openIssueByName(newIssue.title)
// check created issued by second user
await issuesPageSecond.searchIssueByName(newIssue.title)
await issuesPageSecond.openIssueByName(newIssue.title)
const issuesDetailsPageSecond = new IssuesDetailsPage(userSecondPage)
await issuesDetailsPageSecond.checkIssue({
...newIssue,
milestone: 'Milestone',
estimation: '2h'
})
})
})

View File

@ -1,4 +1,4 @@
import { Page } from '@playwright/test'
import { Page, expect } from '@playwright/test'
export class CommonPage {
async selectMenuItem (page: Page, name: string): Promise<void> {
@ -49,6 +49,7 @@ export class CommonPage {
async selectAssignee (page: Page, name: string): Promise<void> {
if (name !== 'first') {
await page.locator('div.selectPopup input').fill(name.split(' ')[0])
await expect(page.locator('div.selectPopup div.list-item')).toHaveCount(1)
}
await page.locator('div.selectPopup div.list-item').click()
}

View File

@ -5,7 +5,6 @@ import { CommonTrackerPage } from './common-tracker-page'
export class IssuesPage extends CommonTrackerPage {
readonly page: Page
readonly pageHeader: Locator
readonly modelSelectorAll: Locator
readonly modelSelectorActive: Locator
readonly modelSelectorBacklog: Locator
@ -24,14 +23,14 @@ export class IssuesPage extends CommonTrackerPage {
readonly textPopupCreateNewIssueFile: Locator
readonly buttonCreateIssue: Locator
readonly inputSearch: Locator
readonly linkSidebarAll: Locator
constructor (page: Page) {
super(page)
this.page = page
this.pageHeader = page.locator('div[class*="header"]', { hasText: 'Issues' })
this.modelSelectorAll = this.pageHeader.locator('text=All')
this.modelSelectorActive = this.pageHeader.locator('text=Active')
this.modelSelectorBacklog = this.pageHeader.locator('text=Backlog')
this.modelSelectorAll = page.locator('div[data-id="tab-all"]')
this.modelSelectorActive = page.locator('div[data-id="tab-active"]')
this.modelSelectorBacklog = page.locator('div[data-id="tab-backlog"]')
this.buttonCreateNewIssue = page.locator('button > span', { hasText: 'New issue' })
this.inputPopupCreateNewIssueTitle = page.locator('form[id="tracker:string:NewIssue"] input[type="text"]')
this.inputPopupCreateNewIssueDescription = page.locator('form[id="tracker:string:NewIssue"] div.tiptap')
@ -59,6 +58,7 @@ export class IssuesPage extends CommonTrackerPage {
this.textPopupCreateNewIssueFile = page.locator('div[class*="attachments"] > div[class*="attachment"]')
this.buttonCreateIssue = page.locator('button > span', { hasText: 'Create issue' })
this.inputSearch = page.locator('input[placeholder="Search"]')
this.linkSidebarAll = page.locator('a[href$="all-issues"]')
}
async createNewIssue (data: NewIssue): Promise<void> {

View File

@ -1,10 +1,11 @@
import { Locator, Page } from '@playwright/test'
import { Browser, Locator, Page } from '@playwright/test'
export const PlatformURI = process.env.PLATFORM_URI as string
export const PlatformTransactor = process.env.PLATFORM_TRANSACTOR as string
export const PlatformUser = process.env.PLATFORM_USER as string
export const PlatformToken = process.env.PLATFORM_TOKEN as string
export const PlatformUserSecond = process.env.PLATFORM_USER_SECOND as string
export const PlatformSetting = process.env.SETTING as string
export const PlatformSettingSecond = process.env.SETTING_SECOND as string
function toHex (value: number, chars: number): string {
const result = value.toString(16)
@ -58,3 +59,8 @@ export async function fillSearch (page: Page, search: string): Promise<Locator>
return searchBox
}
export async function getSecondPage (browser: Browser): Promise<Page> {
const userSecondContext = await browser.newContext({ storageState: PlatformSettingSecond })
return await userSecondContext.newPage()
}