forked from hcengineering/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): added documents tests (hcengineering#4843)
Signed-off-by: Alex Velichko <[email protected]> Signed-off-by: Tiago Cruz <[email protected]>
- Loading branch information
1 parent
2b502a8
commit 81a6941
Showing
27 changed files
with
558 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
import { test } from '@playwright/test' | ||
import { generateId, getSecondPage, PlatformSetting, PlatformURI } from '../utils' | ||
import { NewDocument, NewTeamspace } 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' | ||
|
||
test.use({ | ||
storageState: PlatformSetting | ||
}) | ||
|
||
test.describe('Documents tests', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() | ||
}) | ||
|
||
test('Create a document', async ({ page }) => { | ||
const newDocument: NewDocument = { | ||
title: `New Document-${generateId()}`, | ||
space: 'Default' | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.buttonCreateDocument.click() | ||
|
||
await documentsPage.createDocument(newDocument) | ||
await documentsPage.openDocument(newDocument.title) | ||
|
||
const documentContentPage = new DocumentContentPage(page) | ||
await documentContentPage.checkDocumentTitle(newDocument.title) | ||
}) | ||
|
||
test('Edit document', async ({ page }) => { | ||
const contentOne = ' * Text first line' | ||
const contentTwo = ' * Text second line' | ||
const newDocumentTitle = `Edit Updated Document Title-${generateId()}` | ||
const editDocument: NewDocument = { | ||
title: `Edit Document Title-${generateId()}`, | ||
space: 'Default' | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.buttonCreateDocument.click() | ||
|
||
await documentsPage.createDocument(editDocument) | ||
await documentsPage.openDocument(editDocument.title) | ||
|
||
const documentContentPage = new DocumentContentPage(page) | ||
await documentContentPage.checkDocumentTitle(editDocument.title) | ||
|
||
let content = await documentContentPage.addContentToTheNewLine(contentOne) | ||
await documentContentPage.checkContent(content) | ||
|
||
content = await documentContentPage.addContentToTheNewLine(contentTwo) | ||
await documentContentPage.checkContent(content) | ||
|
||
await documentContentPage.updateDocumentTitle(newDocumentTitle) | ||
await documentContentPage.checkDocumentTitle(newDocumentTitle) | ||
}) | ||
|
||
test('Move document', async ({ page }) => { | ||
const contentFirst = 'Text first line' | ||
const moveDocument: NewDocument = { | ||
title: `Move Document Title-${generateId()}`, | ||
space: 'Default' | ||
} | ||
const moveTeamspace: NewTeamspace = { | ||
title: `Move Teamspace-${generateId()}`, | ||
description: 'Move Teamspace description', | ||
private: false | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.checkTeamspaceNotExist(moveTeamspace.title) | ||
await documentsPage.createNewTeamspace(moveTeamspace) | ||
await documentsPage.checkTeamspaceExist(moveTeamspace.title) | ||
await documentsPage.buttonCreateDocument.click() | ||
|
||
await documentsPage.createDocument(moveDocument) | ||
await documentsPage.openDocument(moveDocument.title) | ||
|
||
const documentContentPage = new DocumentContentPage(page) | ||
await documentContentPage.checkDocumentTitle(moveDocument.title) | ||
|
||
const content = await documentContentPage.addContentToTheNewLine(contentFirst) | ||
await documentContentPage.checkContent(content) | ||
|
||
await documentsPage.moreActionsOnDocument(moveDocument.title, 'Move') | ||
await documentsPage.fillMoveDocumentForm(moveTeamspace.title) | ||
|
||
await documentsPage.openTeamspace(moveTeamspace.title) | ||
await documentsPage.openDocumentForTeamspace(moveTeamspace.title, moveDocument.title) | ||
await documentContentPage.checkDocumentTitle(moveDocument.title) | ||
}) | ||
|
||
test('Collarabotive edit document content', async ({ page, browser }) => { | ||
let content = '' | ||
const contentFirstUser = 'First first!!! This string come from from the first user' | ||
const contentSecondUser = 'Second second!!! This string come from from the second user' | ||
const colDocument: NewDocument = { | ||
title: `Collarabotive edit Title-${generateId()}`, | ||
space: 'Default' | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.openTeamspace(colDocument.space) | ||
await documentsPage.buttonCreateDocument.click() | ||
|
||
await documentsPage.createDocument(colDocument) | ||
await documentsPage.openDocument(colDocument.title) | ||
|
||
await test.step('User1. Add content first user', async () => { | ||
const documentContentPage = new DocumentContentPage(page) | ||
await documentContentPage.checkDocumentTitle(colDocument.title) | ||
|
||
content = await documentContentPage.addContentToTheNewLine(contentFirstUser) | ||
await documentContentPage.checkContent(content) | ||
}) | ||
|
||
await test.step('User2. Add content second user', async () => { | ||
const userSecondPage = await getSecondPage(browser) | ||
await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() | ||
|
||
const leftSideMenuPageSecond = new LeftSideMenuPage(userSecondPage) | ||
await leftSideMenuPageSecond.buttonDocuments.click() | ||
|
||
const documentsPageSecond = new DocumentsPage(userSecondPage) | ||
await documentsPageSecond.openTeamspace(colDocument.space) | ||
await documentsPageSecond.openDocument(colDocument.title) | ||
|
||
const documentContentPageSecond = new DocumentContentPage(page) | ||
await documentContentPageSecond.checkDocumentTitle(colDocument.title) | ||
await documentContentPageSecond.checkContent(content) | ||
|
||
content = await documentContentPageSecond.addContentToTheNewLine(contentSecondUser) | ||
await documentContentPageSecond.checkContent(content) | ||
}) | ||
|
||
await test.step('User1. Check final content', async () => { | ||
const documentContentPage = new DocumentContentPage(page) | ||
await documentContentPage.checkDocumentTitle(colDocument.title) | ||
await documentContentPage.checkContent(content) | ||
}) | ||
}) | ||
|
||
test('Add Link to the Document', async ({ page }) => { | ||
const contentLink = 'Lineforthelink' | ||
const linkDocument: NewDocument = { | ||
title: `Links Document Title-${generateId()}`, | ||
space: 'Default' | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.buttonCreateDocument.click() | ||
|
||
await documentsPage.createDocument(linkDocument) | ||
await documentsPage.openDocument(linkDocument.title) | ||
|
||
const documentContentPage = new DocumentContentPage(page) | ||
await documentContentPage.checkDocumentTitle(linkDocument.title) | ||
|
||
await documentContentPage.addRandomLines(5) | ||
await documentContentPage.addContentToTheNewLine(contentLink) | ||
await documentContentPage.addRandomLines(5) | ||
|
||
await documentContentPage.addLinkToText(contentLink, 'test/link/123456') | ||
await documentContentPage.checkLinkInTheText(contentLink, 'test/link/123456') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { test } from '@playwright/test' | ||
import { generateId, PlatformSetting, PlatformURI } from '../utils' | ||
import { NewTeamspace } from '../model/documents/types' | ||
import { LeftSideMenuPage } from '../model/left-side-menu-page' | ||
import { DocumentsPage } from '../model/documents/documents-page' | ||
|
||
test.use({ | ||
storageState: PlatformSetting | ||
}) | ||
|
||
test.describe('Teamspace tests', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() | ||
}) | ||
|
||
test('Create a teamspace', async ({ page }) => { | ||
const newTeamspace: NewTeamspace = { | ||
title: `New Teamspace-${generateId()}`, | ||
description: 'New Teamspace description', | ||
private: false | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.checkTeamspaceNotExist(newTeamspace.title) | ||
await documentsPage.createNewTeamspace(newTeamspace) | ||
await documentsPage.checkTeamspaceExist(newTeamspace.title) | ||
}) | ||
|
||
test('Archive teamspace', async ({ page }) => { | ||
const archiveTeamspace: NewTeamspace = { | ||
title: 'Teamspace for archive' | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.checkTeamspaceExist(archiveTeamspace.title) | ||
|
||
await documentsPage.moreActionTeamspace(archiveTeamspace.title, 'Archive') | ||
await documentsPage.pressYesForPopup(page) | ||
|
||
await documentsPage.checkTeamspaceNotExist(archiveTeamspace.title) | ||
}) | ||
|
||
test('Edit teamspace', async ({ page }) => { | ||
const editTeamspace: NewTeamspace = { | ||
title: `Edit Teamspace-${generateId()}`, | ||
description: 'Edit Teamspace description', | ||
private: false | ||
} | ||
const updateEditTeamspace: NewTeamspace = { | ||
title: `Edit Updated Teamspace-${generateId()}`, | ||
description: 'Edit Updated Teamspace description', | ||
private: false | ||
} | ||
|
||
const leftSideMenuPage = new LeftSideMenuPage(page) | ||
await leftSideMenuPage.buttonDocuments.click() | ||
|
||
const documentsPage = new DocumentsPage(page) | ||
await documentsPage.checkTeamspaceNotExist(editTeamspace.title) | ||
await documentsPage.createNewTeamspace(editTeamspace) | ||
await documentsPage.checkTeamspaceExist(editTeamspace.title) | ||
|
||
await documentsPage.moreActionTeamspace(editTeamspace.title, 'Edit teamspace') | ||
|
||
await documentsPage.editTeamspace(updateEditTeamspace) | ||
|
||
await documentsPage.moreActionTeamspace(updateEditTeamspace.title, 'Edit teamspace') | ||
await documentsPage.checkTeamspace(updateEditTeamspace) | ||
}) | ||
}) |
71 changes: 71 additions & 0 deletions
71
tests/sanity/tests/model/documents/document-content-page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { type Locator, type Page, expect } from '@playwright/test' | ||
import { CommonPage } from '../common-page' | ||
|
||
export class DocumentContentPage extends CommonPage { | ||
readonly page: Page | ||
readonly buttonDocumentTitle: Locator | ||
readonly inputContent: Locator | ||
readonly buttonToolbarLink: Locator | ||
readonly inputFormLink: Locator | ||
readonly buttonFormLinkSave: Locator | ||
readonly buttonMoreActions: Locator | ||
|
||
constructor (page: Page) { | ||
super() | ||
this.page = page | ||
this.buttonDocumentTitle = page.locator('div[class*="main-content"] div.title input') | ||
this.inputContent = page.locator('div.textInput div.tiptap') | ||
this.buttonToolbarLink = page.locator('div.text-editor-toolbar button:nth-child(10)') | ||
this.inputFormLink = page.locator('form[id="text-editor:string:Link"] input') | ||
this.buttonFormLinkSave = page.locator('form[id="text-editor:string:Link"] button[type="submit"]') | ||
this.buttonMoreActions = page.locator('div.popupPanel-title button:first-child') | ||
} | ||
|
||
async checkDocumentTitle (title: string): Promise<void> { | ||
await expect(this.buttonDocumentTitle).toHaveValue(title) | ||
} | ||
|
||
async addContentToTheNewLine (newContent: string): Promise<string> { | ||
await this.inputContent.pressSequentially(`\n${newContent}`) | ||
const endContent = await this.inputContent.textContent() | ||
if (endContent == null) { | ||
return '' | ||
} else { | ||
return endContent | ||
} | ||
} | ||
|
||
async checkContent (content: string): Promise<void> { | ||
await expect(this.inputContent).toHaveText(content) | ||
} | ||
|
||
async updateDocumentTitle (title: string): Promise<void> { | ||
await this.buttonDocumentTitle.fill(title) | ||
} | ||
|
||
async addRandomLines (count: number, lineLength: number = 36): Promise<void> { | ||
for (let i = 0; i < count; i++) { | ||
await this.addContentToTheNewLine(Math.random().toString(lineLength).substring(2, lineLength)) | ||
await this.page.waitForTimeout(100) | ||
} | ||
} | ||
|
||
async addLinkToText (text: string, link: string): Promise<void> { | ||
await expect(this.page.locator('p', { hasText: text })).toBeVisible() | ||
await this.page.locator('p', { hasText: text }).click() | ||
await this.page.locator('p', { hasText: text }).dblclick() | ||
await this.buttonToolbarLink.click() | ||
|
||
await this.inputFormLink.fill(link) | ||
await this.buttonFormLinkSave.click() | ||
} | ||
|
||
async checkLinkInTheText (text: string, link: string): Promise<void> { | ||
await expect(this.page.locator('a', { hasText: text })).toHaveAttribute('href', link) | ||
} | ||
|
||
async executeMoreAction (action: string): Promise<void> { | ||
await this.buttonMoreActions.click() | ||
await this.selectFromDropdown(this.page, action) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/sanity/tests/model/documents/document-create-popup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { type Locator, type Page } from '@playwright/test' | ||
import { CommonPage } from '../common-page' | ||
import { NewDocument } from './types' | ||
|
||
export class DocumentCreatePopup extends CommonPage { | ||
readonly page: Page | ||
readonly popup: Locator | ||
readonly form: Locator | ||
readonly buttonSelectSpace: Locator | ||
readonly buttonSelectParent: Locator | ||
readonly buttonSelectIcon: Locator | ||
readonly inputTitle: Locator | ||
readonly buttonSubmit: Locator | ||
|
||
constructor (page: Page) { | ||
super() | ||
this.page = page | ||
this.popup = page.locator('div.popup') | ||
this.form = this.popup.locator('form[id="document:string:CreateDocument"]') | ||
|
||
this.buttonSelectSpace = this.form.locator('button[id="space.selector"]') | ||
this.buttonSelectParent = this.form.locator('div[class*="title"] div > button') | ||
this.buttonSelectIcon = this.form.locator('div[class*="horizontalBox"] button.only-icon') | ||
this.inputTitle = this.form.locator('input') | ||
this.buttonSubmit = this.form.locator('button[type="submit"]') | ||
} | ||
|
||
async createDocument (data: NewDocument): Promise<void> { | ||
await this.inputTitle.fill(data.title) | ||
|
||
if (data.space != null) { | ||
await this.buttonSelectSpace.click() | ||
await this.selectMenuItem(this.page, data.space) | ||
} | ||
|
||
if (data.parentDocument != null) { | ||
await this.buttonSelectParent.click() | ||
await this.selectMenuItem(this.page, data.parentDocument) | ||
} | ||
|
||
if (data.icon != null) { | ||
await this.buttonSelectIcon.click() | ||
} | ||
|
||
await this.buttonSubmit.click() | ||
} | ||
} |
Oops, something went wrong.