diff --git a/tests/sanity/tests/model/tracker/public-link-popup.ts b/tests/sanity/tests/model/tracker/public-link-popup.ts new file mode 100644 index 00000000000..75815b5c1ab --- /dev/null +++ b/tests/sanity/tests/model/tracker/public-link-popup.ts @@ -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 { + const link = await this.textPublicLink.textContent() + expect(link).toContain('http') + return link ?? '' + } +} diff --git a/tests/sanity/tests/tracker/public-link.spec.ts b/tests/sanity/tests/tracker/public-link.spec.ts new file mode 100644 index 00000000000..21ef1945050 --- /dev/null +++ b/tests/sanity/tests/tracker/public-link.spec.ts @@ -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') + }) + }) +})