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-217: feat(test): done Public link Revoke test #4926

Merged
merged 2 commits into from
Mar 13, 2024
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 tests/sanity/tests/model/tracker/public-link-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class PublicLinkPopup extends IssuesPage {
readonly buttonRevoke: Locator
readonly buttonCopy: Locator
readonly buttonClose: Locator
readonly buttonOk: Locator

constructor (page: Page) {
super(page)
Expand All @@ -15,11 +16,17 @@ export class PublicLinkPopup extends IssuesPage {
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' })
this.buttonOk = page.locator('div.popup button[type="submit"]', { hasText: 'Ok' })
}

async getPublicLink (): Promise<string> {
const link = await this.textPublicLink.textContent()
expect(link).toContain('http')
return link ?? ''
}

async revokePublicLink (): Promise<void> {
await this.buttonRevoke.click()
await this.buttonOk.click()
}
}
48 changes: 48 additions & 0 deletions tests/sanity/tests/tracker/public-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,52 @@ test.describe('Tracker public link issues tests', () => {
expect(clearPage.url()).toContain('guest')
})
})

test('Public link Revoke', async ({ browser }) => {
const publicLinkIssue: NewIssue = {
title: `Public link Revoke issue-${generateId()}`,
description: 'Public link Revoke issue'
}

const newContext = await browser.newContext({ storageState: PlatformSetting })
const page = await newContext.newPage()
let link: string
await test.step('Get public link from popup', async () => {
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()
})

const clearSession = await browser.newContext()
const clearPage = await clearSession.newPage()
await test.step('Check guest access to the issue', async () => {
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')
})

await test.step('Revoke guest access to the issue', async () => {
const publicLinkPopup = new PublicLinkPopup(page)
await publicLinkPopup.revokePublicLink()
})

await test.step('Check guest access to the issue after the revoke', async () => {
await clearPage.goto(link)
await expect(clearPage.locator('div.antiPopup > h1')).toHaveText('Public link was revoked')
})
})
})