From 97d03c38ee044e0cb7d1d12ec40bcf6fa7c40228 Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Wed, 13 Mar 2024 13:30:04 +0300 Subject: [PATCH] TESTS-221: feat(tests): done Document public link revoke test (#4940) Signed-off-by: Alex Velichko --- .../tests/documents/documents-link.spec.ts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/sanity/tests/documents/documents-link.spec.ts diff --git a/tests/sanity/tests/documents/documents-link.spec.ts b/tests/sanity/tests/documents/documents-link.spec.ts new file mode 100644 index 0000000000..43a53c4ec3 --- /dev/null +++ b/tests/sanity/tests/documents/documents-link.spec.ts @@ -0,0 +1,55 @@ +import { expect, test } from '@playwright/test' +import { generateId, PlatformSetting, PlatformURI } from '../utils' +import { NewDocument } from '../model/documents/types' +import { LeftSideMenuPage } from '../model/left-side-menu-page' +import { DocumentsPage } from '../model/documents/documents-page' +import { DocumentContentPage } from '../model/documents/document-content-page' +import { PublicLinkPopup } from '../model/tracker/public-link-popup' + +test.describe('Documents link tests', () => { + test('Document public link revoke', async ({ browser }) => { + const publicLinkDocument: NewDocument = { + title: `Document Public link revoke-${generateId()}`, + space: 'Default' + } + + 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.buttonDocuments.click() + + const documentsPage = new DocumentsPage(page) + await documentsPage.buttonCreateDocument.click() + + await documentsPage.createDocument(publicLinkDocument) + await documentsPage.openDocument(publicLinkDocument.title) + + const documentContentPage = new DocumentContentPage(page) + await documentContentPage.executeMoreAction('Public link') + + const publicLinkPopup = new PublicLinkPopup(page) + const link = await publicLinkPopup.getPublicLink() + + const clearSession = await browser.newContext() + const clearPage = await clearSession.newPage() + await test.step('Check guest access to the document', async () => { + await clearPage.goto(link) + + const documentContentClearPage = new DocumentContentPage(clearPage) + await documentContentClearPage.checkDocumentTitle(publicLinkDocument.title) + expect(clearPage.url()).toContain('guest') + }) + + await test.step('Revoke guest access to the document', async () => { + const publicLinkPopup = new PublicLinkPopup(page) + await publicLinkPopup.revokePublicLink() + }) + + await test.step('Check guest access to the document after the revoke', async () => { + await clearPage.goto(link) + await expect(clearPage.locator('div.antiPopup > h1')).toHaveText('Public link was revoked') + }) + }) +})