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-85: feat(tests): added issues.spec.ts test #4025

Merged
merged 6 commits into from
Nov 22, 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
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions tests/create-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions tests/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions tests/restore-workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion tests/sanity/.env
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions tests/sanity/storageSecond.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
67 changes: 67 additions & 0 deletions tests/sanity/tests/collaborative/issues.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
})
})
})
3 changes: 2 additions & 1 deletion tests/sanity/tests/model/common-page.ts
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down Expand Up @@ -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()
}
Expand Down
10 changes: 5 additions & 5 deletions tests/sanity/tests/model/tracker/issues-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down Expand Up @@ -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> {
Expand Down
10 changes: 8 additions & 2 deletions tests/sanity/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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()
}