mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 11:01:54 +03:00
Added Table test for Documents (#6356)
Signed-off-by: Alexander Platov <alexander.platov@hardcoreeng.com>
This commit is contained in:
parent
7ea8606922
commit
4dd9aef5a9
143
tests/sanity/tests/documents/documents-content.spec.ts
Normal file
143
tests/sanity/tests/documents/documents-content.spec.ts
Normal file
@ -0,0 +1,143 @@
|
||||
import { test, type Page, expect } from '@playwright/test'
|
||||
import {
|
||||
generateId,
|
||||
getTimeForPlanner,
|
||||
generateUser,
|
||||
createAccountAndWorkspace,
|
||||
createAccount,
|
||||
getInviteLink,
|
||||
generateTestData,
|
||||
getSecondPageByInvite
|
||||
} 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'
|
||||
import { PlanningNavigationMenuPage } from '../model/planning/planning-navigation-menu-page'
|
||||
import { PlanningPage } from '../model/planning/planning-page'
|
||||
import { SignUpData } from '../model/common-types'
|
||||
import { TestData } from '../chat/types'
|
||||
|
||||
const retryOptions = { intervals: [1000, 1500, 2500], timeout: 60000 }
|
||||
|
||||
test.describe('Content in the Documents tests', () => {
|
||||
let testData: TestData
|
||||
let newUser2: SignUpData
|
||||
let testTeamspace: NewTeamspace
|
||||
let testDocument: NewDocument
|
||||
|
||||
let leftSideMenuPage: LeftSideMenuPage
|
||||
let documentsPage: DocumentsPage
|
||||
let documentContentPage: DocumentContentPage
|
||||
|
||||
let secondPage: Page
|
||||
let leftSideMenuSecondPage: LeftSideMenuPage
|
||||
let documentsSecondPage: DocumentsPage
|
||||
let documentContentSecondPage: DocumentContentPage
|
||||
|
||||
test.beforeEach(async ({ browser, page, request }) => {
|
||||
leftSideMenuPage = new LeftSideMenuPage(page)
|
||||
documentsPage = new DocumentsPage(page)
|
||||
documentContentPage = new DocumentContentPage(page)
|
||||
testTeamspace = {
|
||||
title: `Teamspace-${generateId()}`,
|
||||
description: 'Teamspace description',
|
||||
autoJoin: true
|
||||
}
|
||||
testDocument = {
|
||||
title: `Document-${generateId()}`,
|
||||
space: testTeamspace.title
|
||||
}
|
||||
|
||||
testData = generateTestData()
|
||||
newUser2 = generateUser()
|
||||
await createAccountAndWorkspace(page, request, testData)
|
||||
await createAccount(request, newUser2)
|
||||
|
||||
const linkText = await getInviteLink(page)
|
||||
await leftSideMenuPage.clickDocuments()
|
||||
await documentsPage.checkTeamspaceNotExist(testTeamspace.title)
|
||||
await documentsPage.createNewTeamspace(testTeamspace)
|
||||
secondPage = await getSecondPageByInvite(browser, linkText, newUser2)
|
||||
|
||||
leftSideMenuSecondPage = new LeftSideMenuPage(secondPage)
|
||||
documentsSecondPage = new DocumentsPage(secondPage)
|
||||
documentContentSecondPage = new DocumentContentPage(secondPage)
|
||||
await documentsPage.clickOnButtonCreateDocument()
|
||||
await documentsPage.createDocument(testDocument)
|
||||
await documentsPage.openDocument(testDocument.title)
|
||||
await documentContentPage.checkDocumentTitle(testDocument.title)
|
||||
})
|
||||
|
||||
test('ToDos in the Document', async () => {
|
||||
const contents: string[] = ['work', 'meet up']
|
||||
let content: string = ''
|
||||
|
||||
for (let i = 0; i < contents.length; i++) {
|
||||
content = await documentContentPage.addContentToTheNewLine(`${i === 0 ? '[] ' : ''}${contents[i]}`)
|
||||
await documentContentPage.checkContent(content)
|
||||
}
|
||||
for (const line of contents) {
|
||||
await documentContentPage.assignToDo(`${newUser2.lastName} ${newUser2.firstName}`, line)
|
||||
}
|
||||
|
||||
await leftSideMenuSecondPage.clickDocuments()
|
||||
await documentsSecondPage.openTeamspace(testDocument.space)
|
||||
await documentsSecondPage.openDocument(testDocument.title)
|
||||
await documentContentSecondPage.checkDocumentTitle(testDocument.title)
|
||||
await documentContentSecondPage.checkContent(content)
|
||||
await leftSideMenuSecondPage.clickPlanner()
|
||||
|
||||
const planningNavigationMenuPage = new PlanningNavigationMenuPage(secondPage)
|
||||
await planningNavigationMenuPage.clickOnButtonToDoAll()
|
||||
const planningPage = new PlanningPage(secondPage)
|
||||
const time: string = getTimeForPlanner()
|
||||
await planningPage.dragToCalendar(contents[0], 1, time)
|
||||
await planningPage.dragToCalendar(contents[1], 1, time, true)
|
||||
await planningPage.checkInSchedule(contents[0])
|
||||
await planningPage.checkInSchedule(contents[1])
|
||||
await planningPage.markDoneInToDos(contents[0])
|
||||
await planningPage.markDoneInToDos(contents[1])
|
||||
await secondPage.close()
|
||||
|
||||
for (const line of contents) await documentContentPage.checkToDo(line, true)
|
||||
})
|
||||
|
||||
test('Table in the Document', async ({ page }) => {
|
||||
await documentContentPage.inputContentParapraph().click()
|
||||
await documentContentPage.leftMenu().click()
|
||||
await documentContentPage.menuPopupItemButton('Table').click()
|
||||
await documentContentPage.menuPopupItemButton('1x2').first().click()
|
||||
await documentContentPage.proseTableCell(0, 0).fill('One')
|
||||
await documentContentPage.proseTableCell(0, 1).fill('Two')
|
||||
await documentContentPage.buttonInsertColumn().click()
|
||||
await documentContentPage.proseTableCell(0, 1).fill('Three')
|
||||
|
||||
await documentContentPage.proseTableColumnHandle(1).hover()
|
||||
await expect(async () => {
|
||||
await page.mouse.down()
|
||||
const boundingBox = await documentContentPage.proseTableCell(0, 1).boundingBox()
|
||||
expect(boundingBox).toBeTruthy()
|
||||
if (boundingBox != null) {
|
||||
await page.mouse.move(boundingBox.x + boundingBox.width * 2, boundingBox.y - 5)
|
||||
await page.mouse.move(boundingBox.x + boundingBox.width * 2 + 5, boundingBox.y - 5)
|
||||
await page.mouse.up()
|
||||
}
|
||||
}).toPass(retryOptions)
|
||||
|
||||
await documentContentPage.buttonInsertLastRow().click()
|
||||
await documentContentPage.proseTableCell(1, 1).fill('Bottom')
|
||||
await documentContentPage.buttonInsertInnerRow().click()
|
||||
await documentContentPage.proseTableCell(1, 1).fill('Middle')
|
||||
|
||||
await leftSideMenuSecondPage.clickDocuments()
|
||||
await documentsSecondPage.openTeamspace(testDocument.space)
|
||||
await documentsSecondPage.openDocument(testDocument.title)
|
||||
await documentContentSecondPage.checkDocumentTitle(testDocument.title)
|
||||
await expect(documentContentSecondPage.proseTableCell(1, 1)).toContainText('Middle')
|
||||
await documentContentSecondPage.proseTableCell(1, 1).dblclick()
|
||||
await documentContentSecondPage.proseTableCell(1, 1).fill('Center')
|
||||
await expect(documentContentPage.proseTableCell(1, 1)).toContainText('Center', { timeout: 5000 })
|
||||
await secondPage.close()
|
||||
})
|
||||
})
|
@ -1,26 +1,9 @@
|
||||
import { test } from '@playwright/test'
|
||||
import {
|
||||
generateId,
|
||||
getSecondPage,
|
||||
PlatformSetting,
|
||||
PlatformURI,
|
||||
getTimeForPlanner,
|
||||
generateUser,
|
||||
createAccountAndWorkspace,
|
||||
createAccount,
|
||||
getInviteLink,
|
||||
generateTestData,
|
||||
reLogin
|
||||
} from '../utils'
|
||||
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'
|
||||
import { PlanningNavigationMenuPage } from '../model/planning/planning-navigation-menu-page'
|
||||
import { PlanningPage } from '../model/planning/planning-page'
|
||||
import { SignUpData } from '../model/common-types'
|
||||
import { SignInJoinPage } from '../model/signin-page'
|
||||
import { TestData } from '../chat/types'
|
||||
|
||||
test.use({
|
||||
storageState: PlatformSetting
|
||||
@ -186,69 +169,4 @@ test.describe('Documents tests', () => {
|
||||
await documentContentPage.checkDocumentTitle(newDocument.title)
|
||||
await documentContentPage.checkDocumentLocked()
|
||||
})
|
||||
|
||||
test('ToDos in the Document', async ({ page, browser, request }) => {
|
||||
const testData: TestData = generateTestData()
|
||||
await createAccountAndWorkspace(page, request, testData)
|
||||
const newUser2: SignUpData = generateUser()
|
||||
await createAccount(request, newUser2)
|
||||
|
||||
const todosTeamspace: NewTeamspace = {
|
||||
title: `ToDos Teamspace-${generateId()}`,
|
||||
description: 'ToDos Teamspace description',
|
||||
autoJoin: true
|
||||
}
|
||||
const todosDocument: NewDocument = {
|
||||
title: `ToDos in the Document-${generateId()}`,
|
||||
space: todosTeamspace.title
|
||||
}
|
||||
const contents: string[] = ['work', 'meet up']
|
||||
let content: string = ''
|
||||
|
||||
const linkText = await getInviteLink(page)
|
||||
await leftSideMenuPage.clickDocuments()
|
||||
await documentsPage.checkTeamspaceNotExist(todosTeamspace.title)
|
||||
await documentsPage.createNewTeamspace(todosTeamspace)
|
||||
const page2 = await browser.newPage()
|
||||
await page2.goto(linkText ?? '')
|
||||
const joinPage: SignInJoinPage = new SignInJoinPage(page2)
|
||||
await joinPage.join(newUser2)
|
||||
await page2.goto(`${PlatformURI}/workbench/sanity-ws`)
|
||||
|
||||
await documentsPage.clickOnButtonCreateDocument()
|
||||
await documentsPage.createDocument(todosDocument)
|
||||
await documentsPage.openDocument(todosDocument.title)
|
||||
await documentContentPage.checkDocumentTitle(todosDocument.title)
|
||||
for (let i = 0; i < contents.length; i++) {
|
||||
content = await documentContentPage.addContentToTheNewLine(`${i === 0 ? '[] ' : ''}${contents[i]}`)
|
||||
await documentContentPage.checkContent(content)
|
||||
}
|
||||
for (const line of contents) {
|
||||
await documentContentPage.assignToDo(`${newUser2.lastName} ${newUser2.firstName}`, line)
|
||||
}
|
||||
|
||||
await reLogin(page2, { ...testData, userName: newUser2.email })
|
||||
const leftSideMenuPageSecond = new LeftSideMenuPage(page2)
|
||||
await leftSideMenuPageSecond.clickDocuments()
|
||||
const documentsPageSecond = new DocumentsPage(page2)
|
||||
await documentsPageSecond.openTeamspace(todosDocument.space)
|
||||
await documentsPageSecond.openDocument(todosDocument.title)
|
||||
const documentContentPageSecond = new DocumentContentPage(page2)
|
||||
await documentContentPageSecond.checkDocumentTitle(todosDocument.title)
|
||||
await documentContentPageSecond.checkContent(content)
|
||||
await leftSideMenuPageSecond.clickPlanner()
|
||||
|
||||
const planningNavigationMenuPage = new PlanningNavigationMenuPage(page2)
|
||||
await planningNavigationMenuPage.clickOnButtonToDoAll()
|
||||
const planningPage = new PlanningPage(page2)
|
||||
const time: string = getTimeForPlanner()
|
||||
await planningPage.dragToCalendar(contents[0], 1, time)
|
||||
await planningPage.dragToCalendar(contents[1], 1, time, true)
|
||||
await planningPage.checkInSchedule(contents[0])
|
||||
await planningPage.checkInSchedule(contents[1])
|
||||
await planningPage.markDoneInToDos(contents[0])
|
||||
await planningPage.markDoneInToDos(contents[1])
|
||||
for (const line of contents) await documentContentPage.checkToDo(line, true)
|
||||
await page2.close()
|
||||
})
|
||||
})
|
||||
|
@ -11,6 +11,23 @@ export class DocumentContentPage extends CommonPage {
|
||||
|
||||
readonly buttonDocumentTitle = (): Locator => this.page.locator('div[class*="main-content"] div.title input')
|
||||
readonly inputContent = (): Locator => this.page.locator('div.textInput div.tiptap')
|
||||
readonly inputContentParapraph = (): Locator => this.page.locator('div.textInput div.tiptap > p')
|
||||
readonly leftMenu = (): Locator => this.page.locator('div.tiptap-left-menu')
|
||||
readonly proseTableCell = (row: number, col: number): Locator =>
|
||||
this.page.locator('table.proseTable').locator('tr').nth(row).locator('td').nth(col).locator('p')
|
||||
|
||||
readonly proseTableColumnHandle = (col: number): Locator =>
|
||||
this.page.locator('table.proseTable').locator('tr').first().locator('td').nth(col).locator('div.table-col-handle')
|
||||
|
||||
readonly buttonInsertColumn = (col: number = 0): Locator =>
|
||||
this.page.locator('div.table-col-insert').nth(col).locator('button')
|
||||
|
||||
readonly buttonInsertLastRow = (): Locator =>
|
||||
this.page.locator('table.proseTable + div.table-button-container__col + div.table-button-container__row')
|
||||
|
||||
readonly buttonInsertInnerRow = (row: number = 0): Locator =>
|
||||
this.page.locator('table.proseTable').locator('tr').nth(row).locator('div.table-row-insert button')
|
||||
|
||||
readonly buttonToolbarLink = (): Locator => this.page.locator('div.text-editor-toolbar button[data-id="btnLink"]')
|
||||
readonly inputFormLink = (): Locator => this.page.locator('form[id="text-editor:string:Link"] input')
|
||||
readonly buttonFormLinkSave = (): Locator =>
|
||||
|
@ -8,6 +8,7 @@ import { SignUpData } from './model/common-types'
|
||||
import { ApiEndpoint } from './API/Api'
|
||||
import { SelectWorkspacePage } from './model/select-workspace-page'
|
||||
import { LoginPage } from './model/login-page'
|
||||
import { SignInJoinPage } from './model/signin-page'
|
||||
|
||||
export const PlatformURI = process.env.PLATFORM_URI as string
|
||||
export const PlatformTransactor = process.env.PLATFORM_TRANSACTOR as string
|
||||
@ -109,6 +110,19 @@ export async function getSecondPage (browser: Browser): Promise<{ page: Page, co
|
||||
const userSecondContext = await browser.newContext({ storageState: PlatformSettingSecond })
|
||||
return { page: await userSecondContext.newPage(), context: userSecondContext }
|
||||
}
|
||||
|
||||
export async function getSecondPageByInvite (
|
||||
browser: Browser,
|
||||
linkText: string | null,
|
||||
newUser: SignUpData
|
||||
): Promise<Page> {
|
||||
const page = await browser.newPage()
|
||||
await page.goto(linkText ?? '')
|
||||
const joinPage: SignInJoinPage = new SignInJoinPage(page)
|
||||
await joinPage.join(newUser)
|
||||
return page
|
||||
}
|
||||
|
||||
export function expectToContainsOrdered (val: Locator, text: string[], timeout?: number): Promise<void> {
|
||||
const origIssuesExp = new RegExp('.*' + text.join('.*') + '.*')
|
||||
return expect(val).toHaveText(origIssuesExp, { timeout })
|
||||
|
Loading…
Reference in New Issue
Block a user