TESTS-216: feat(tests): done Public link generate test (#4915)

Signed-off-by: Alex Velichko <alex@hardcoreeng.com>
This commit is contained in:
Alex Velichko 2024-03-11 20:08:38 +03:00 committed by GitHub
parent 2d266bb3fd
commit e44300c1c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,25 @@
import { IssuesPage } from './issues-page'
import { type Locator, type Page, expect } from '@playwright/test'
export class PublicLinkPopup extends IssuesPage {
readonly page: Page
readonly textPublicLink: Locator
readonly buttonRevoke: Locator
readonly buttonCopy: Locator
readonly buttonClose: Locator
constructor (page: Page) {
super(page)
this.page = page
this.textPublicLink = page.locator('form[id="guest:string:PublicLink"] div.link')
this.buttonRevoke = page.locator('form[id="guest:string:PublicLink"] button', { hasText: 'Revoke' })
this.buttonCopy = page.locator('form[id="guest:string:PublicLink"] button', { hasText: 'Copy' })
this.buttonClose = page.locator('form[id="guest:string:PublicLink"] button', { hasText: 'Close' })
}
async getPublicLink (): Promise<string> {
const link = await this.textPublicLink.textContent()
expect(link).toContain('http')
return link ?? ''
}
}

View File

@ -0,0 +1,50 @@
import { expect, test } from '@playwright/test'
import { generateId, PlatformSetting, PlatformURI } from '../utils'
import { LeftSideMenuPage } from '../model/left-side-menu-page'
import { IssuesDetailsPage } from '../model/tracker/issues-details-page'
import { NewIssue } from '../model/tracker/types'
import { prepareNewIssueWithOpenStep } from './common-steps'
import { PublicLinkPopup } from '../model/tracker/public-link-popup'
test.describe('Tracker public link issues tests', () => {
test('Public link generate', async ({ browser }) => {
const publicLinkIssue: NewIssue = {
title: `Public link generate issue-${generateId()}`,
description: 'Public link generate issue'
}
let link: string
await test.step('Get public link from popup', async () => {
const newContext = await browser.newContext({ storageState: PlatformSetting })
const page = await newContext.newPage()
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished()
const leftSideMenuPage = new LeftSideMenuPage(page)
await leftSideMenuPage.buttonTracker.click()
await prepareNewIssueWithOpenStep(page, publicLinkIssue)
const issuesDetailsPage = new IssuesDetailsPage(page)
await issuesDetailsPage.moreActionOnIssue('Public link')
const publicLinkPopup = new PublicLinkPopup(page)
link = await publicLinkPopup.getPublicLink()
})
await test.step('Check guest access to the issue', async () => {
const clearSession = await browser.newContext()
await clearSession.clearCookies()
await clearSession.clearPermissions()
const clearPage = await clearSession.newPage()
await clearPage.goto(link)
const clearIssuesDetailsPage = new IssuesDetailsPage(clearPage)
await clearIssuesDetailsPage.waitDetailsOpened(publicLinkIssue.title)
await clearIssuesDetailsPage.checkIssue({
...publicLinkIssue,
status: 'Backlog'
})
expect(clearPage.url()).toContain('guest')
})
})
})