From d4907ce57866b9d517e59e709bb3fe7ffe16c46f Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Wed, 22 Nov 2023 12:14:26 +0300 Subject: [PATCH] TESTS-85: feat(tests): added issues.spec.ts test (#4025) Signed-off-by: Alex Velichko --- .github/workflows/main.yml | 7 ++ tests/create-local.sh | 4 ++ tests/prepare.sh | 3 + tests/restore-workspace.sh | 1 + tests/sanity/.env | 4 +- tests/sanity/storageSecond.json | 34 ++++++++++ .../sanity/tests/collaborative/issues.spec.ts | 67 +++++++++++++++++++ tests/sanity/tests/model/common-page.ts | 3 +- .../sanity/tests/model/tracker/issues-page.ts | 10 +-- tests/sanity/tests/utils.ts | 10 ++- 10 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 tests/sanity/storageSecond.json create mode 100644 tests/sanity/tests/collaborative/issues.spec.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a6004e90e5..14ac8fd77e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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() diff --git a/tests/create-local.sh b/tests/create-local.sh index ce7f5e12f7..a891cbd12b 100755 --- a/tests/create-local.sh +++ b/tests/create-local.sh @@ -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 \ No newline at end of file diff --git a/tests/prepare.sh b/tests/prepare.sh index 3a45d3407e..a7be6b59f7 100755 --- a/tests/prepare.sh +++ b/tests/prepare.sh @@ -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 \ No newline at end of file diff --git a/tests/restore-workspace.sh b/tests/restore-workspace.sh index e2853e17f8..f20bc59c98 100755 --- a/tests/restore-workspace.sh +++ b/tests/restore-workspace.sh @@ -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 diff --git a/tests/sanity/.env b/tests/sanity/.env index d21f4d6876..d51aba7616 100644 --- a/tests/sanity/.env +++ b/tests/sanity/.env @@ -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 \ No newline at end of file +SETTING=storage.json +SETTING_SECOND=storageSecond.json \ No newline at end of file diff --git a/tests/sanity/storageSecond.json b/tests/sanity/storageSecond.json new file mode 100644 index 0000000000..31f49c7ead --- /dev/null +++ b/tests/sanity/storageSecond.json @@ -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" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/sanity/tests/collaborative/issues.spec.ts b/tests/sanity/tests/collaborative/issues.spec.ts new file mode 100644 index 0000000000..f88515e498 --- /dev/null +++ b/tests/sanity/tests/collaborative/issues.spec.ts @@ -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' + }) + }) +}) diff --git a/tests/sanity/tests/model/common-page.ts b/tests/sanity/tests/model/common-page.ts index f732f76d30..15d481c223 100644 --- a/tests/sanity/tests/model/common-page.ts +++ b/tests/sanity/tests/model/common-page.ts @@ -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 { @@ -49,6 +49,7 @@ export class CommonPage { async selectAssignee (page: Page, name: string): Promise { 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() } diff --git a/tests/sanity/tests/model/tracker/issues-page.ts b/tests/sanity/tests/model/tracker/issues-page.ts index e6d609f14e..d068e86584 100644 --- a/tests/sanity/tests/model/tracker/issues-page.ts +++ b/tests/sanity/tests/model/tracker/issues-page.ts @@ -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 { diff --git a/tests/sanity/tests/utils.ts b/tests/sanity/tests/utils.ts index cb6ee9ad06..ddfe66b169 100644 --- a/tests/sanity/tests/utils.ts +++ b/tests/sanity/tests/utils.ts @@ -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 return searchBox } + +export async function getSecondPage (browser: Browser): Promise { + const userSecondContext = await browser.newContext({ storageState: PlatformSettingSecond }) + return await userSecondContext.newPage() +}