From 69ca75e3b26092ac69929974f2244a925a6a310c Mon Sep 17 00:00:00 2001 From: JasminMus <167111741+JasminMus@users.noreply.github.com> Date: Mon, 27 May 2024 18:43:48 +0200 Subject: [PATCH] Add chat tests (#5625) Signed-off-by: Jasmin --- tests/sanity/tests/API/Api.ts | 12 + tests/sanity/tests/chat/chat.spec.ts | 299 +++++++++++++++++- tests/sanity/tests/model/channel-page.ts | 174 +++++++++- .../sanity/tests/model/left-side-menu-page.ts | 5 + .../tests/model/profile/user-profile-page.ts | 5 + tests/sanity/tests/playwright.config.ts | 1 + tests/sanity/tests/utils.ts | 14 +- 7 files changed, 489 insertions(+), 21 deletions(-) diff --git a/tests/sanity/tests/API/Api.ts b/tests/sanity/tests/API/Api.ts index ce19c21f50..6d66e506ef 100644 --- a/tests/sanity/tests/API/Api.ts +++ b/tests/sanity/tests/API/Api.ts @@ -63,4 +63,16 @@ export class ApiEndpoint { const response = await this.request.post(url, { data: payload, headers }) return await response.json() } + + async leaveWorkspace (email: string, username: string, password: string): Promise { + const token = await this.loginAndGetToken(username, password) + const url = AccountUrl + const payload = { + method: 'leaveWorkspace', + params: [email] + } + const headers = this.getDefaultHeaders(token) + const response = await this.request.post(url, { data: payload, headers }) + return await response.json() + } } diff --git a/tests/sanity/tests/chat/chat.spec.ts b/tests/sanity/tests/chat/chat.spec.ts index 09cc1e9245..5f350068da 100644 --- a/tests/sanity/tests/chat/chat.spec.ts +++ b/tests/sanity/tests/chat/chat.spec.ts @@ -1,4 +1,4 @@ -import { test } from '@playwright/test' +import { test, expect } from '@playwright/test' import { PlatformURI, generateTestData } from '../utils' import { LeftSideMenuPage } from '../model/left-side-menu-page' import { ChunterPage } from '../model/chunter-page' @@ -34,8 +34,9 @@ test.describe('channel tests', () => { api = new ApiEndpoint(request) await api.createAccount(data.userName, '1234', data.firstName, data.lastName) await api.createWorkspaceWithLogin(data.workspaceName, data.userName, '1234') - await (await page.goto(`${PlatformURI}/workbench/${data.workspaceName}`))?.finished() + await (await page.goto(`${PlatformURI}`))?.finished() await loginPage.login(data.userName, '1234') + await (await page.goto(`${PlatformURI}/workbench/${data.workspaceName}`))?.finished() }) test('create new private channel and check if the messages stays on it', async ({ browser, page }) => { @@ -45,13 +46,13 @@ test.describe('channel tests', () => { await chunterPage.createPrivateChannel(data.channelName, true) await channelPage.checkIfChannelDefaultExist(true, data.channelName) await channelPage.sendMessage('Test message') - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') await channelPage.clickChannel('general') - await channelPage.checkMessageExist('Test message', false) + await channelPage.checkMessageExist('Test message', false, 'Test message') await channelPage.clickChannel(data.channelName) - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') await page.reload() - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') }) test('create new public channel and check if the messages stays on it', async ({ browser, page }) => { @@ -61,13 +62,13 @@ test.describe('channel tests', () => { await chunterPage.createPrivateChannel(data.channelName, false) await channelPage.checkIfChannelDefaultExist(true, data.channelName) await channelPage.sendMessage('Test message') - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') await channelPage.clickChannel('general') - await channelPage.checkMessageExist('Test message', false) + await channelPage.checkMessageExist('Test message', false, 'Test message') await channelPage.clickChannel(data.channelName) - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') await page.reload() - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') }) test('create new private channel tests and check if the new user have access to it', async ({ browser, page }) => { @@ -77,7 +78,7 @@ test.describe('channel tests', () => { await chunterPage.createPrivateChannel(data.channelName, true) await channelPage.checkIfChannelDefaultExist(true, data.channelName) await channelPage.sendMessage('Test message') - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') await leftSideMenuPage.openProfileMenu() await leftSideMenuPage.inviteToWorkspace() await leftSideMenuPage.getInviteLink() @@ -106,7 +107,7 @@ test.describe('channel tests', () => { await chunterPage.createPrivateChannel(data.channelName, false) await channelPage.checkIfChannelDefaultExist(true, data.channelName) await channelPage.sendMessage('Test message') - await channelPage.checkMessageExist('Test message', true) + await channelPage.checkMessageExist('Test message', true, 'Test message') await leftSideMenuPage.openProfileMenu() await leftSideMenuPage.inviteToWorkspace() await leftSideMenuPage.getInviteLink() @@ -124,4 +125,278 @@ test.describe('channel tests', () => { await channelPageSecond.clickChannelTab() await channelPageSecond.checkIfChannelTableExist(data.channelName, true) }) + + test('create new private channel and test if the user can exchange the messages', async ({ browser, page }) => { + await leftSideMenuPage.clickChunter() + await chunterPage.clickChannelBrowser() + await chunterPage.clickNewChannelHeader() + await chunterPage.createPrivateChannel(data.channelName, false) + await channelPage.checkIfChannelDefaultExist(true, data.channelName) + await channelPage.sendMessage('Test message') + await channelPage.checkMessageExist('Test message', true, 'Test message') + await leftSideMenuPage.openProfileMenu() + await leftSideMenuPage.inviteToWorkspace() + await leftSideMenuPage.getInviteLink() + + const linkText = await page.locator('.antiPopup .link').textContent() + const page2 = await browser.newPage() + const leftSideMenuPageSecond = new LeftSideMenuPage(page2) + const channelPageSecond = new ChannelPage(page2) + await leftSideMenuPage.clickOnCloseInvite() + await api.createAccount(newUser2.email, newUser2.password, newUser2.firstName, newUser2.lastName) + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + await leftSideMenuPageSecond.clickChunter() + await channelPageSecond.checkIfChannelDefaultExist(false, data.channelName) + await channelPageSecond.clickChannelTab() + await channelPageSecond.checkIfChannelTableExist(data.channelName, true) + await channelPageSecond.clickJoinChannelButton() + await channelPageSecond.clickChooseChannel(data.channelName) + await channelPageSecond.checkMessageExist('Test message', true, 'Test message') + await channelPageSecond.sendMessage('My dream is to fly') + await channelPageSecond.checkMessageExist('My dream is to fly', true, 'My dream is to fly') + await channelPage.clickOnClosePopupButton() + await channelPage.checkMessageExist('My dream is to fly', true, 'My dream is to fly') + }) + + test('create new private channel add user to it', async ({ browser, page }) => { + await leftSideMenuPage.clickChunter() + await chunterPage.clickChannelBrowser() + await chunterPage.clickNewChannelHeader() + await chunterPage.createPrivateChannel(data.channelName, true) + await channelPage.checkIfChannelDefaultExist(true, data.channelName) + await channelPage.sendMessage('Test message') + await channelPage.checkMessageExist('Test message', true, 'Test message') + await leftSideMenuPage.openProfileMenu() + await leftSideMenuPage.inviteToWorkspace() + await leftSideMenuPage.getInviteLink() + + const linkText = await page.locator('.antiPopup .link').textContent() + const page2 = await browser.newPage() + const leftSideMenuPageSecond = new LeftSideMenuPage(page2) + const channelPageSecond = new ChannelPage(page2) + await leftSideMenuPage.clickOnCloseInvite() + await api.createAccount(newUser2.email, newUser2.password, newUser2.firstName, newUser2.lastName) + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + await leftSideMenuPageSecond.clickChunter() + await channelPage.clickChannelTab() + await channelPage.clickOnUser(data.lastName + ' ' + data.firstName) + await channelPage.addMemberToChannel(newUser2.lastName + ' ' + newUser2.firstName) + await leftSideMenuPageSecond.clickChunter() + await channelPageSecond.checkIfChannelDefaultExist(true, data.channelName) + await channelPageSecond.clickChannelTab() + await channelPageSecond.checkIfChannelTableExist(data.channelName, true) + await channelPageSecond.clickChooseChannel(data.channelName) + await channelPageSecond.checkMessageExist('Test message', true, 'Test message') + await channelPageSecond.sendMessage('One two') + await channelPageSecond.checkMessageExist('One two', true, 'One two') + await channelPage.clickChooseChannel(data.channelName) + await channelPage.checkMessageExist('One two', true, 'One two') + }) + + test('go to general channel add user to it', async ({ browser, page }) => { + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('general') + + await channelPage.sendMessage('Test message') + await channelPage.checkMessageExist('Test message', true, 'Test message') + await leftSideMenuPage.openProfileMenu() + await leftSideMenuPage.inviteToWorkspace() + await leftSideMenuPage.getInviteLink() + + const linkText = await page.locator('.antiPopup .link').textContent() + const page2 = await browser.newPage() + const leftSideMenuPageSecond = new LeftSideMenuPage(page2) + const channelPageSecond = new ChannelPage(page2) + await leftSideMenuPage.clickOnCloseInvite() + await api.createAccount(newUser2.email, newUser2.password, newUser2.firstName, newUser2.lastName) + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + await leftSideMenuPageSecond.clickChunter() + await channelPageSecond.clickChannel('general') + await channelPageSecond.checkMessageExist('Test message', true, 'Test message') + await channelPageSecond.sendMessage('One two') + await channelPageSecond.checkMessageExist('One two', true, 'One two') + await channelPage.clickChannel('random') + await channelPage.clickOnClosePopupButton() + await channelPage.clickChannel('general') + await channelPage.checkMessageExist('One two', true, 'One two') + }) + + test('go to random channel add user to it', async ({ browser, page }) => { + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('random') + + await channelPage.sendMessage('Test message') + await channelPage.checkMessageExist('Test message', true, 'Test message') + await leftSideMenuPage.openProfileMenu() + await leftSideMenuPage.inviteToWorkspace() + await leftSideMenuPage.getInviteLink() + + const linkText = await page.locator('.antiPopup .link').textContent() + const page2 = await browser.newPage() + const leftSideMenuPageSecond = new LeftSideMenuPage(page2) + const channelPageSecond = new ChannelPage(page2) + await leftSideMenuPage.clickOnCloseInvite() + await api.createAccount(newUser2.email, newUser2.password, newUser2.firstName, newUser2.lastName) + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + await leftSideMenuPageSecond.clickChunter() + await channelPageSecond.clickChannel('random') + await channelPageSecond.checkMessageExist('Test message', true, 'Test message') + await channelPageSecond.sendMessage('One two') + await channelPageSecond.checkMessageExist('One two', true, 'One two') + await channelPage.clickChannel('general') + await channelPage.clickOnClosePopupButton() + await channelPage.clickChannel('random') + await channelPage.checkMessageExist('One two', true, 'One two') + }) + + test('check if user can add emoji', async () => { + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('random') + await channelPage.sendMessage('Test message') + await channelPage.checkMessageExist('Test message', true, 'Test message') + await channelPage.addEmoji('Test message', '😤') + await channelPage.checkIfEmojiIsAdded('😤') + }) + + test('check if user can save message', async () => { + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('random') + await channelPage.sendMessage('Test message') + await channelPage.saveMessage('Test message') + await channelPage.sendMessage('Test message') + await channelPage.clickSaveMessageTab() + await channelPage.checkIfMessageExist(true, 'Test message') + }) + + test('check if user can pin message', async () => { + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('random') + await channelPage.sendMessage('Test message') + await channelPage.replyToMessage('Test message', 'Reply message') + await channelPage.checkIfMessageExist(true, 'Reply message') + await channelPage.closeAndOpenReplyMessage() + await channelPage.checkIfMessageExist(true, 'Reply message') + }) + + test('check if user can edit message', async ({ page }) => { + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('random') + await channelPage.sendMessage('Test message') + await channelPage.clickOpenMoreButton('Test message') + await channelPage.clickEditMessageButton(' edited message') + await page.keyboard.press('Enter') + await channelPage.checkIfMessageExist(true, 'Test message edited message') + await channelPage.clickOpenMoreButton('Test message edited message') + await channelPage.clickEditMessageButton(' 1') + await channelPage.clickOnUpdateButton() + await channelPage.checkIfMessageExist(true, 'Test message edited message 1') + }) + + test('check if user can copy message', async ({ page }) => { + const expectedUrl = `http://localhost:8083/workbench/${data.workspaceName}/chunter/chunter:space:Random|chunter:class:Channel?message=` + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('random') + await channelPage.sendMessage('Test message') + await channelPage.clickOpenMoreButton('Test message') + await channelPage.clickCopyLinkButton() + const clipboardContent = await page.evaluate(async () => { + return await navigator.clipboard.readText() + }) + expect(clipboardContent).toContain(expectedUrl) + }) + + test('check if user can delete messages', async ({ page }) => { + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('random') + await channelPage.sendMessage('Test message') + await channelPage.clickOpenMoreButton('Test message') + await channelPage.clickDeleteMessageButton() + await channelPage.checkIfMessageExist(false, 'Test message') + }) + + test('Check if user can change the name of chat', async ({ browser, page }) => { + await leftSideMenuPage.clickChunter() + await chunterPage.clickChannelBrowser() + await chunterPage.clickNewChannelHeader() + await chunterPage.createPrivateChannel(data.channelName, false) + await channelPage.checkIfChannelDefaultExist(true, data.channelName) + await channelPage.clickOnOpenChannelDetails() + await channelPage.changeChannelName(data.channelName) + await channelPage.checkIfNameIsChanged('New Channel Name') + }) + + test('Check if user can switch to private or public', async ({ browser, page }) => { + await leftSideMenuPage.clickChunter() + await chunterPage.clickChannelBrowser() + await chunterPage.clickNewChannelHeader() + await chunterPage.createPrivateChannel(data.channelName, false) + await channelPage.checkIfChannelDefaultExist(true, data.channelName) + await channelPage.clickOnOpenChannelDetails() + await channelPage.changeChannelPrivacyOrAutoJoin('No', 'Yes', 'Yes') + await channelPage.changeChannelPrivacyOrAutoJoin('Yes', 'No', 'No') + }) + + test('Check if user can switch auto join', async ({ browser, page }) => { + await leftSideMenuPage.clickChunter() + await chunterPage.clickChannelBrowser() + await chunterPage.clickNewChannelHeader() + await chunterPage.createPrivateChannel(data.channelName, false) + await channelPage.checkIfChannelDefaultExist(true, data.channelName) + await channelPage.clickOnOpenChannelDetails() + await channelPage.changeChannelPrivacyOrAutoJoin('N/A', 'Yes', 'Yes') + }) + + test('Check if the user can be added through preview tab', async ({ browser, page }) => { + await leftSideMenuPage.openProfileMenu() + await leftSideMenuPage.inviteToWorkspace() + await leftSideMenuPage.getInviteLink() + + const linkText = await page.locator('.antiPopup .link').textContent() + const page2 = await browser.newPage() + const leftSideMenuPageSecond = new LeftSideMenuPage(page2) + const channelPageSecond = new ChannelPage(page2) + + await leftSideMenuPage.clickOnCloseInvite() + await api.createAccount(newUser2.email, newUser2.password, newUser2.firstName, newUser2.lastName) + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + await leftSideMenuPageSecond.clickChunter() + await channelPageSecond.clickChannel('general') + await channelPageSecond.clickOnOpenChannelDetails() + await channelPageSecond.checkIfUserIsAdded(data.lastName + ' ' + data.firstName, false) + }) + + test('Check if we can create new public channel tests and check if the new user have can be added through preview', async ({ + browser, + page + }) => { + await leftSideMenuPage.clickChunter() + await chunterPage.clickChannelBrowser() + await chunterPage.clickNewChannelHeader() + await chunterPage.createPrivateChannel(data.channelName, false) + await channelPage.checkIfChannelDefaultExist(true, data.channelName) + await leftSideMenuPage.openProfileMenu() + await leftSideMenuPage.inviteToWorkspace() + await leftSideMenuPage.getInviteLink() + const linkText = await page.locator('.antiPopup .link').textContent() + await leftSideMenuPage.clickOnCloseInvite() + const page2 = await browser.newPage() + await api.createAccount(newUser2.email, newUser2.password, newUser2.firstName, newUser2.lastName) + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel(data.channelName) + await channelPage.clickOnOpenChannelDetails() + await channelPage.addMemberToChannelPreview(newUser2.lastName + ' ' + newUser2.firstName) + }) }) diff --git a/tests/sanity/tests/model/channel-page.ts b/tests/sanity/tests/model/channel-page.ts index 1a34326c04..c951cb2088 100644 --- a/tests/sanity/tests/model/channel-page.ts +++ b/tests/sanity/tests/model/channel-page.ts @@ -9,33 +9,173 @@ export class ChannelPage { readonly inputMessage = (): Locator => this.page.locator('div[class~="text-editor-view"]') readonly buttonSendMessage = (): Locator => this.page.locator('g#Send') - readonly textMessage = (): Locator => this.page.getByText('Test message') + readonly textMessage = (messageText: string): Locator => this.page.getByText(messageText) readonly channelName = (channel: string): Locator => this.page.getByText('general random').getByText(channel) readonly channelTab = (): Locator => this.page.getByRole('link', { name: 'Channels' }).getByRole('button') readonly channelTable = (): Locator => this.page.getByRole('table') readonly channel = (channel: string): Locator => this.page.getByRole('button', { name: channel }) + readonly chooseChannel = (channel: string): Locator => this.page.getByRole('link', { name: channel }) + readonly closePopupWindow = (): Locator => this.page.locator('.root > div > .antiButton').first() + readonly openAddMemberToChannel = (userName: string): Locator => this.page.getByRole('button', { name: userName }) + readonly addMemberToChannelButton = (userName: string): Locator => this.page.getByRole('button', { name: userName }) + readonly joinChannelButton = (): Locator => this.page.getByRole('button', { name: 'Join' }) + readonly addEmojiButton = (): Locator => this.page.locator('.root > button').first() + readonly selectEmoji = (emoji: string): Locator => this.page.getByText(emoji) + readonly saveMessageButton = (): Locator => this.page.locator('.root > button:nth-child(2)') + readonly pinMessageButton = (): Locator => this.page.locator('.root > button:nth-child(3)') + readonly replyButton = (): Locator => this.page.locator('.root > button:nth-child(4)') + readonly openMoreButton = (): Locator => this.page.locator('.root > button:nth-child(5)') + readonly messageSaveMarker = (): Locator => this.page.locator('.saveMarker') + readonly saveMessageTab = (): Locator => this.page.getByRole('button', { name: 'Saved' }) + readonly pinnedMessageButton = (): Locator => this.page.getByRole('button', { name: 'pinned' }) + readonly pinnedMessage = (message: string): Locator => this.page.locator('.antiPopup').getByText(message) + readonly closeReplyButton = (): Locator => this.page.locator('.close > .svg-medium') + readonly openReplyMessage = (): Locator => this.page.getByText('1 reply Last reply less than') + readonly editMessageButton = (): Locator => this.page.getByRole('button', { name: 'Edit' }) + readonly copyLinkButton = (): Locator => this.page.getByRole('button', { name: 'Copy link' }) + readonly deleteMessageButton = (): Locator => this.page.getByRole('button', { name: 'Delete' }) + readonly updateButton = (): Locator => this.page.getByRole('button', { name: 'Update' }) + readonly openChannelDetails = (): Locator => this.page.locator('.ac-header > .antiButton') + readonly changeChannelNameConfirm = (): Locator => this.page.locator('.ml-2 > .antiButton') + readonly privateOrPublicChangeButton = (change: string): Locator => this.page.getByRole('button', { name: change }) + readonly userAdded = (user: string): Locator => this.page.getByText(user) + private readonly addMemberPreview = (): Locator => this.page.getByRole('button', { name: 'Add members' }) + private readonly addButtonPreview = (): Locator => this.page.getByRole('button', { name: 'Add', exact: true }) async sendMessage (message: string): Promise { await this.inputMessage().fill(message) await this.buttonSendMessage().click() } + async clickOnOpenChannelDetails (): Promise { + await this.openChannelDetails().click() + } + async clickChannel (channel: string): Promise { await this.channel(channel).click() } - async checkMessageExist (message: string, messageExists: boolean): Promise { - if (messageExists) { - await expect(this.textMessage().filter({ hasText: message })).toBeVisible() + async changeChannelName (channel: string): Promise { + await this.channel(channel).nth(2).click() + await this.page.keyboard.type('New Channel Name') + await this.changeChannelNameConfirm().click() + } + + async changeChannelPrivacyOrAutoJoin (change: string, YesNo: string, changed: string): Promise { + await this.privateOrPublicChangeButton(change).click() + await this.page.waitForTimeout(200) + await this.page.getByText(YesNo).click() + await expect(this.privateOrPublicChangeButton(changed)).toBeVisible() + } + + async clickDeleteMessageButton (): Promise { + await this.deleteMessageButton().click() + } + + async clickSaveMessageTab (): Promise { + await this.saveMessageTab().click() + } + + async addMemberToChannelPreview (user: string): Promise { + await this.addMemberPreview().click() + await this.addMemberToChannelButton(user).click() + await this.addButtonPreview().click() + await expect(this.userAdded(user)).toBeVisible() + } + + async checkIfUserIsAdded (user: string, added: boolean): Promise { + if (added) { + await expect(this.userAdded(user)).toBeHidden() } else { - await expect(this.textMessage().filter({ hasText: message })).toBeHidden() + await expect(this.userAdded(user)).toBeVisible() } } + async clickOpenMoreButton (message: string): Promise { + await this.textMessage(message).hover() + await this.openMoreButton().click() + } + + async clickEditMessageButton (editedMessage: string): Promise { + await this.editMessageButton().click() + await this.page.waitForTimeout(500) + await this.page.keyboard.type(editedMessage) + } + + async clickCopyLinkButton (): Promise { + await this.copyLinkButton().click() + } + + async clickOnUpdateButton (): Promise { + await this.updateButton().click() + } + + async getClipboardCopyMessage (): Promise { + await this.page.evaluate(async () => { + return await navigator.clipboard.readText() + }) + } + + async checkIfMessageIsCopied (message: string): Promise { + expect(this.getClipboardCopyMessage()).toContain(message) + } + + async clickChooseChannel (channel: string): Promise { + await this.chooseChannel(channel).click({ force: true }) + } + + async addEmoji (textMessage: string, emoji: string): Promise { + await this.textMessage(textMessage).hover() + await this.addEmojiButton().click() + await this.selectEmoji(emoji).click() + } + + async saveMessage (message: string): Promise { + await this.textMessage(message).hover() + await this.saveMessageButton().click() + await expect(this.messageSaveMarker()).toBeVisible() + } + + async pinMessage (message: string): Promise { + await this.textMessage(message).hover() + await this.pinMessageButton().click() + await this.pinnedMessageButton().click() + await expect(this.pinnedMessage(message)).toBeVisible() + } + + async replyToMessage (message: string, messageReply: string): Promise { + await this.textMessage(message).hover() + await this.replyButton().click() + await this.page.waitForTimeout(500) + await this.page.keyboard.type(messageReply) + await this.page.keyboard.press('Enter') + } + + async closeAndOpenReplyMessage (): Promise { + await this.closeReplyButton().click() + await this.openReplyMessage().click() + } + async clickChannelTab (): Promise { await this.channelTab().click() } + async clickOnClosePopupButton (): Promise { + await this.closePopupWindow().click() + } + + async clickOnUser (user: string): Promise { + await this.addMemberToChannelButton(user).click() + } + + async addMemberToChannel (user: string): Promise { + await this.openAddMemberToChannel(user).click() + } + + async clickJoinChannelButton (): Promise { + await this.joinChannelButton().click() + } + async checkIfChannelDefaultExist (shouldExist: boolean, channel: string): Promise { if (shouldExist) { await expect(this.channelName(channel)).toBeVisible() @@ -53,11 +193,29 @@ export class ChannelPage { } } - async checkIfMessageExist (messageExists: boolean): Promise { + async checkIfMessageExist (messageExists: boolean, messageText: string): Promise { if (messageExists) { - await expect(this.textMessage()).toBeVisible() + await expect(this.textMessage(messageText)).toBeVisible() } else { - await expect(this.textMessage()).toBeHidden() + await expect(this.textMessage(messageText)).toBeHidden() } } + + async checkMessageExist (message: string, messageExists: boolean, messageText: string): Promise { + if (messageExists) { + await expect(this.textMessage(messageText).filter({ hasText: message })).toBeVisible() + } else { + await expect(this.textMessage(messageText).filter({ hasText: message })).toBeHidden() + } + } + + async checkIfEmojiIsAdded (emoji: string): Promise { + await expect(this.selectEmoji(emoji + ' 1')).toBeVisible() + } + + async checkIfNameIsChanged (channel: string): Promise { + await expect(this.channel(channel).nth(0)).toBeVisible() + await expect(this.channel(channel).nth(1)).toBeVisible() + await expect(this.channel(channel).nth(2)).toBeVisible() + } } diff --git a/tests/sanity/tests/model/left-side-menu-page.ts b/tests/sanity/tests/model/left-side-menu-page.ts index fda70bb114..c18c740b87 100644 --- a/tests/sanity/tests/model/left-side-menu-page.ts +++ b/tests/sanity/tests/model/left-side-menu-page.ts @@ -17,6 +17,7 @@ export class LeftSideMenuPage extends CommonPage { profileButton = (): Locator => this.page.locator('#profile-button') inviteToWorkspaceButton = (): Locator => this.page.locator('button:has-text("Invite to workspace")') getInviteLinkButton = (): Locator => this.page.locator('button:has-text("Get invite link")') + clickCloseOnInviteLinkButton = (): Locator => this.page.getByRole('button', { name: 'Close' }) // Actions async openProfileMenu (): Promise { @@ -51,6 +52,10 @@ export class LeftSideMenuPage extends CommonPage { await this.buttonDocuments().click() } + async clickOnCloseInvite (): Promise { + await this.clickCloseOnInviteLinkButton().click() + } + // Retrieve the last token from local storage async getLastToken (): Promise { return await this.page.evaluate(() => localStorage.getItem('login:metadata:LastToken') ?? '') diff --git a/tests/sanity/tests/model/profile/user-profile-page.ts b/tests/sanity/tests/model/profile/user-profile-page.ts index 2adf1c2657..1e40adcd78 100644 --- a/tests/sanity/tests/model/profile/user-profile-page.ts +++ b/tests/sanity/tests/model/profile/user-profile-page.ts @@ -15,6 +15,7 @@ export class UserProfilePage { leaveWorkspaceCancelButton = (): Locator => this.page.getByRole('button', { name: 'Cancel' }) leaveWorkspaceConfirmButton = (): Locator => this.page.getByRole('button', { name: 'Ok' }) accountDissabledMessage = (): Locator => this.page.getByRole('heading') + changeAccount = (): Locator => this.page.getByRole('link', { name: 'Change account' }) constructor (page: Page) { this.page = page @@ -32,6 +33,10 @@ export class UserProfilePage { await this.profileButton().click() } + async clickChangeAccount (): Promise { + await this.changeAccount().click() + } + async clickLeaveWorkspaceButton (): Promise { await this.leaveWorkspaceButton().click() } diff --git a/tests/sanity/tests/playwright.config.ts b/tests/sanity/tests/playwright.config.ts index 268751c498..7454893abf 100644 --- a/tests/sanity/tests/playwright.config.ts +++ b/tests/sanity/tests/playwright.config.ts @@ -7,6 +7,7 @@ const config: PlaywrightTestConfig = { { name: 'Platform', use: { + permissions: ['clipboard-read', 'clipboard-write'], ...devices['Desktop Chrome'], screenshot: 'only-on-failure', viewport: { diff --git a/tests/sanity/tests/utils.ts b/tests/sanity/tests/utils.ts index c879ae4172..6bc2a0acbf 100644 --- a/tests/sanity/tests/utils.ts +++ b/tests/sanity/tests/utils.ts @@ -14,15 +14,27 @@ export const LocalUrl = process.env.LOCAL_URL as string export const DevUrl = process.env.DEV_URL as string export function generateTestData (): TestData { + const generateWordStartingWithA = (): string => { + const randomWord = faker.lorem.word() + return 'A' + randomWord.slice(1) + } + return { workspaceName: faker.lorem.word(), userName: faker.internet.userName(), firstName: faker.person.firstName(), lastName: faker.person.lastName(), - channelName: faker.lorem.word() + channelName: generateWordStartingWithA() } } +// Consistent data +export const workspaceName = faker.lorem.word() +export const userName = faker.internet.userName() +export const firstName = faker.person.firstName() +export const lastName = faker.person.lastName() +export const channelName = faker.lorem.word() + function toHex (value: number, chars: number): string { const result = value.toString(16) if (result.length < chars) {