diff --git a/tests/sanity-ws/000006/_migrations-1709234348850-0.snp.gz b/tests/sanity-ws/000006/_migrations-1709234348850-0.snp.gz new file mode 100644 index 0000000000..3791d1bd2a Binary files /dev/null and b/tests/sanity-ws/000006/_migrations-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/_migrations-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/_migrations-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..bf2128165b Binary files /dev/null and b/tests/sanity-ws/000006/_migrations-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/activity-1709234348850-0.snp.gz b/tests/sanity-ws/000006/activity-1709234348850-0.snp.gz new file mode 100644 index 0000000000..044b0bee7a Binary files /dev/null and b/tests/sanity-ws/000006/activity-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/activity-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/activity-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..d55797702e Binary files /dev/null and b/tests/sanity-ws/000006/activity-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/doc-index-state-1709234348850-0.snp.gz b/tests/sanity-ws/000006/doc-index-state-1709234348850-0.snp.gz new file mode 100644 index 0000000000..af7ae3f27d Binary files /dev/null and b/tests/sanity-ws/000006/doc-index-state-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/doc-index-state-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/doc-index-state-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..c8a7ec3cf6 Binary files /dev/null and b/tests/sanity-ws/000006/doc-index-state-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/fulltext-blob-1709234348850-0.snp.gz b/tests/sanity-ws/000006/fulltext-blob-1709234348850-0.snp.gz new file mode 100644 index 0000000000..8038983de6 Binary files /dev/null and b/tests/sanity-ws/000006/fulltext-blob-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/fulltext-blob-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/fulltext-blob-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..9df3cfbeec Binary files /dev/null and b/tests/sanity-ws/000006/fulltext-blob-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/notification-1709234348850-0.snp.gz b/tests/sanity-ws/000006/notification-1709234348850-0.snp.gz new file mode 100644 index 0000000000..8a3cf01b11 Binary files /dev/null and b/tests/sanity-ws/000006/notification-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/notification-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/notification-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..4fceeb79c8 Binary files /dev/null and b/tests/sanity-ws/000006/notification-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/space-1709234348850-0.snp.gz b/tests/sanity-ws/000006/space-1709234348850-0.snp.gz new file mode 100644 index 0000000000..2d77d9068d Binary files /dev/null and b/tests/sanity-ws/000006/space-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/space-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/space-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..3a4e4ca0de Binary files /dev/null and b/tests/sanity-ws/000006/space-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/status-1709234348850-0.snp.gz b/tests/sanity-ws/000006/status-1709234348850-0.snp.gz new file mode 100644 index 0000000000..37ea63355c Binary files /dev/null and b/tests/sanity-ws/000006/status-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/status-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/status-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..7a2de1cd21 Binary files /dev/null and b/tests/sanity-ws/000006/status-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/task-1709234348850-0.snp.gz b/tests/sanity-ws/000006/task-1709234348850-0.snp.gz new file mode 100644 index 0000000000..9efbfae750 Binary files /dev/null and b/tests/sanity-ws/000006/task-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/task-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/task-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..69f7e056a7 Binary files /dev/null and b/tests/sanity-ws/000006/task-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/000006/tx-1709234348850-0.snp.gz b/tests/sanity-ws/000006/tx-1709234348850-0.snp.gz new file mode 100644 index 0000000000..dd4809bc6d Binary files /dev/null and b/tests/sanity-ws/000006/tx-1709234348850-0.snp.gz differ diff --git a/tests/sanity-ws/000006/tx-data-1709234348850-1.tar.gz b/tests/sanity-ws/000006/tx-data-1709234348850-1.tar.gz new file mode 100644 index 0000000000..b336c2452c Binary files /dev/null and b/tests/sanity-ws/000006/tx-data-1709234348850-1.tar.gz differ diff --git a/tests/sanity-ws/backup.json.gz b/tests/sanity-ws/backup.json.gz index 405c138d99..0ff851845c 100644 Binary files a/tests/sanity-ws/backup.json.gz and b/tests/sanity-ws/backup.json.gz differ diff --git a/tests/sanity/tests/documents/documents.spec.ts b/tests/sanity/tests/documents/documents.spec.ts new file mode 100644 index 0000000000..4a63363bad --- /dev/null +++ b/tests/sanity/tests/documents/documents.spec.ts @@ -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') + }) +}) diff --git a/tests/sanity/tests/documents/teamspace.spec.ts b/tests/sanity/tests/documents/teamspace.spec.ts new file mode 100644 index 0000000000..1a8de790f2 --- /dev/null +++ b/tests/sanity/tests/documents/teamspace.spec.ts @@ -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) + }) +}) diff --git a/tests/sanity/tests/model/documents/document-content-page.ts b/tests/sanity/tests/model/documents/document-content-page.ts new file mode 100644 index 0000000000..7d918d0374 --- /dev/null +++ b/tests/sanity/tests/model/documents/document-content-page.ts @@ -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 { + await expect(this.buttonDocumentTitle).toHaveValue(title) + } + + async addContentToTheNewLine (newContent: string): Promise { + await this.inputContent.pressSequentially(`\n${newContent}`) + const endContent = await this.inputContent.textContent() + if (endContent == null) { + return '' + } else { + return endContent + } + } + + async checkContent (content: string): Promise { + await expect(this.inputContent).toHaveText(content) + } + + async updateDocumentTitle (title: string): Promise { + await this.buttonDocumentTitle.fill(title) + } + + async addRandomLines (count: number, lineLength: number = 36): Promise { + 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 { + 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 { + await expect(this.page.locator('a', { hasText: text })).toHaveAttribute('href', link) + } + + async executeMoreAction (action: string): Promise { + await this.buttonMoreActions.click() + await this.selectFromDropdown(this.page, action) + } +} diff --git a/tests/sanity/tests/model/documents/document-create-popup.ts b/tests/sanity/tests/model/documents/document-create-popup.ts new file mode 100644 index 0000000000..2bd393acf0 --- /dev/null +++ b/tests/sanity/tests/model/documents/document-create-popup.ts @@ -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 { + 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() + } +} diff --git a/tests/sanity/tests/model/documents/document-move-popup.ts b/tests/sanity/tests/model/documents/document-move-popup.ts new file mode 100644 index 0000000000..a7b6e0dbaa --- /dev/null +++ b/tests/sanity/tests/model/documents/document-move-popup.ts @@ -0,0 +1,23 @@ +import { type Locator, type Page } from '@playwright/test' +import { CommonPage } from '../common-page' + +export class DocumentMovePopup extends CommonPage { + readonly page: Page + readonly popup: Locator + readonly buttonSelectSpace: Locator + readonly buttonSubmit: Locator + + constructor (page: Page) { + super() + this.page = page + this.popup = page.locator('div.popup') + this.buttonSelectSpace = this.popup.locator('button[id="space.selector"]') + this.buttonSubmit = this.popup.locator('button[type="submit"]') + } + + async moveToSpace (newSpace: string): Promise { + await this.buttonSelectSpace.click() + await this.selectMenuItem(this.page, newSpace) + await this.buttonSubmit.click() + } +} diff --git a/tests/sanity/tests/model/documents/documents-page.ts b/tests/sanity/tests/model/documents/documents-page.ts new file mode 100644 index 0000000000..c1f9a6fea9 --- /dev/null +++ b/tests/sanity/tests/model/documents/documents-page.ts @@ -0,0 +1,137 @@ +import { type Locator, type Page, expect } from '@playwright/test' +import { NewDocument, NewTeamspace } from './types' +import { CommonPage } from '../common-page' +import { DocumentCreatePopup } from './document-create-popup' +import { DocumentMovePopup } from './document-move-popup' + +export class DocumentsPage extends CommonPage { + readonly page: Page + readonly buttonCreateDocument: Locator + readonly divTeamspacesParent: Locator + readonly buttonCreateTeamspace: Locator + readonly inputModalNewTeamspaceTitle: Locator + readonly inputModalNewTeamspaceDescription: Locator + readonly inputModalNewTeamspacePrivate: Locator + readonly buttonModalNewTeamspaceCreate: Locator + readonly buttonModalEditTeamspaceTitle: Locator + readonly buttonModalEditTeamspaceDescription: Locator + readonly buttonModalEditTeamspacePrivate: Locator + readonly buttonModalEditTeamspaceSave: Locator + readonly buttonModalEditTeamspaceClose: Locator + readonly popupCreateDocument: DocumentCreatePopup + readonly popupMoveDocument: DocumentMovePopup + + constructor (page: Page) { + super() + this.page = page + this.popupCreateDocument = new DocumentCreatePopup(page) + this.popupMoveDocument = new DocumentMovePopup(page) + + this.buttonCreateDocument = page.locator('div[data-float="navigator"] button[type="submit"]') + this.divTeamspacesParent = page.locator('div#tree-teamspaces').locator('xpath=..') + this.buttonCreateTeamspace = page.locator('div#tree-teamspaces > button') + this.inputModalNewTeamspaceTitle = page.locator( + 'form[id="document:string:NewTeamspace"] input[placeholder="New teamspace"]' + ) + this.inputModalNewTeamspaceDescription = page.locator('form[id="document:string:NewTeamspace"] div.tiptap') + this.inputModalNewTeamspacePrivate = page.locator( + 'form[id="document:string:NewTeamspace"] div.antiGrid label.toggle' + ) + this.buttonModalNewTeamspaceCreate = page.locator('form[id="document:string:NewTeamspace"] button[type="submit"]') + this.buttonModalEditTeamspaceTitle = page.locator('form[id="document:string:EditTeamspace"] input[type="text"]') + this.buttonModalEditTeamspaceDescription = page.locator('form[id="document:string:EditTeamspace"] div.tiptap') + this.buttonModalEditTeamspacePrivate = page.locator( + 'form[id="document:string:EditTeamspace"] div.antiGrid label.toggle' + ) + this.buttonModalEditTeamspaceSave = page.locator('form[id="document:string:EditTeamspace"] button[type="submit"]') + this.buttonModalEditTeamspaceClose = page.locator('form[id="document:string:EditTeamspace"] button#card-close') + } + + async createNewTeamspace (data: NewTeamspace): Promise { + await this.divTeamspacesParent.hover() + await this.buttonCreateTeamspace.click() + + await this.inputModalNewTeamspaceTitle.fill(data.title) + if (data.description != null) { + await this.inputModalNewTeamspaceDescription.fill(data.description) + } + if (data.private != null) { + await this.inputModalNewTeamspacePrivate.click() + } + + await this.buttonModalNewTeamspaceCreate.click() + } + + async openTeamspace (name: string): Promise { + const classes = await this.page + .locator('div.antiNav-element span[class*="label"]', { hasText: name }) + .locator('xpath=..') + .getAttribute('class') + if (classes != null && classes.includes('collapsed')) { + await this.page.locator('div.antiNav-element span[class*="label"]', { hasText: name }).click() + } + } + + async checkTeamspaceExist (name: string): Promise { + await expect(this.page.locator('div[class*="dropbox"] span[class*="label"]', { hasText: name })).toHaveCount(1) + } + + async checkTeamspaceNotExist (name: string): Promise { + await expect(this.page.locator('div[class*="dropbox"] span[class*="label"]', { hasText: name })).toHaveCount(0) + } + + async moreActionTeamspace (name: string, action: string): Promise { + await this.page.locator('div[class*="dropbox"] > div > span[class*="label"]', { hasText: name }).hover() + await this.page.locator(`xpath=//span[text()="${name}"]/../div[last()]`).click() + await this.selectFromDropdown(this.page, action) + } + + async createDocument (data: NewDocument): Promise { + await this.popupCreateDocument.createDocument(data) + } + + async openDocument (name: string): Promise { + await this.page.locator('div.tree > span[class*="label"]', { hasText: name }).click() + } + + async openDocumentForTeamspace (spaceName: string, documentName: string): Promise { + await this.page + .locator('div.parent > span[class*="label"]', { hasText: spaceName }) + .locator('xpath=../following-sibling::div[1]') + .locator('div.tree > span[class*="label"]', { hasText: documentName }) + .click() + } + + async editTeamspace (data: NewTeamspace): Promise { + await this.buttonModalEditTeamspaceTitle.fill(data.title) + if (data.description != null) { + await this.buttonModalEditTeamspaceDescription.fill(data.description) + } + if (data.private != null) { + await this.buttonModalEditTeamspacePrivate.click() + } + + await this.buttonModalEditTeamspaceSave.click() + } + + async checkTeamspace (data: NewTeamspace): Promise { + await expect(this.buttonModalEditTeamspaceTitle).toHaveValue(data.title) + if (data.description != null) { + await expect(this.buttonModalEditTeamspaceDescription).toHaveText(data.description) + } + await this.buttonModalEditTeamspaceClose.click() + } + + async moreActionsOnDocument (documentName: string, action: string): Promise { + await this.page + .locator('div.tree > span[class*="label"]', { hasText: documentName }) + .locator('xpath=..') + .locator('div[class*="tool"]:nth-child(6)') + .click() + await this.selectFromDropdown(this.page, action) + } + + async fillMoveDocumentForm (newSpace: string): Promise { + await this.popupMoveDocument.moveToSpace(newSpace) + } +} diff --git a/tests/sanity/tests/model/documents/types.ts b/tests/sanity/tests/model/documents/types.ts new file mode 100644 index 0000000000..8c2530090e --- /dev/null +++ b/tests/sanity/tests/model/documents/types.ts @@ -0,0 +1,18 @@ +export interface NewTeamspace { + title: string + description?: string + private?: boolean +} + +export interface NewDocument { + title: string + space: string + parentDocument?: string + icon?: string +} + +export interface Date { + day: string + month: string + year: string +} diff --git a/tests/sanity/tests/model/left-side-menu-page.ts b/tests/sanity/tests/model/left-side-menu-page.ts index 5c4e6d27df..d8878fad82 100644 --- a/tests/sanity/tests/model/left-side-menu-page.ts +++ b/tests/sanity/tests/model/left-side-menu-page.ts @@ -7,6 +7,7 @@ export class LeftSideMenuPage extends CommonPage { readonly buttonContacts: Locator readonly buttonTracker: Locator readonly buttonNotification: Locator + readonly buttonDocuments: Locator constructor (page: Page) { super() @@ -15,5 +16,6 @@ export class LeftSideMenuPage extends CommonPage { this.buttonContacts = page.locator('button[id$="Contacts"]') this.buttonTracker = page.locator('button[id$="TrackerApplication"]') this.buttonNotification = page.locator('button[id$="Inbox"]') + this.buttonDocuments = page.locator('button[id$="DocumentApplication"]') } }