diff --git a/tests/sanity/tests/inbox/inbox.spec.ts b/tests/sanity/tests/inbox/inbox.spec.ts index 17b0b425fe..3b0fe1a8d6 100644 --- a/tests/sanity/tests/inbox/inbox.spec.ts +++ b/tests/sanity/tests/inbox/inbox.spec.ts @@ -9,6 +9,9 @@ import { InboxPage } from '../model/inbox.ts/inbox-page' import { SignUpData } from '../model/common-types' import { faker } from '@faker-js/faker' import { SignInJoinPage } from '../model/signin-page' +import { ChannelPage } from '../model/channel-page' +import { UserProfilePage } from '../model/profile/user-profile-page' +import { MenuItems, NotificationsPage } from '../model/profile/notifications-page' test.describe('Inbox tests', () => { let leftSideMenuPage: LeftSideMenuPage @@ -190,4 +193,66 @@ test.describe('Inbox tests', () => { await inboxPage.clickCloseLeftSidePanel() // ADD ASSERT ONCE THE ISSUE IS FIXED }) + + test('User is able to send message to other user and he should see it in inbox', async ({ page, browser }) => { + const channelPage = new ChannelPage(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 inboxPageSecond = new InboxPage(page2) + await leftSideMenuPage.clickOnCloseInvite() + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + await page.waitForTimeout(1000) + + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('general') + await channelPage.sendMessage('Test message') + + await channelPage.checkMessageExist('Test message', true, 'Test message') + await leftSideMenuPage.clickNotification() + await inboxPage.checkIfInboxChatExists('Channel general', false) + await leftSideMenuPageSecond.clickNotification() + await inboxPageSecond.checkIfInboxChatExists('Channel general', true) + await inboxPageSecond.clickOnInboxChat('Channel general') + await inboxPageSecond.checkIfTextInChatIsPresent('Test message') + }) + + test('User is able to turn off notification and he should not receive messages to inbox', async ({ + page, + browser + }) => { + const channelPage = new ChannelPage(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 inboxPageSecond = new InboxPage(page2) + const notificationPageSecond = new NotificationsPage(page2) + await leftSideMenuPage.clickOnCloseInvite() + await page2.goto(linkText ?? '') + const joinPage = new SignInJoinPage(page2) + await joinPage.join(newUser2) + const userProfilePageSecond = new UserProfilePage(page2) + await userProfilePageSecond.openProfileMenu() + await userProfilePageSecond.clickSettings() + await userProfilePageSecond.clickOnNotificationsButton() + await notificationPageSecond.clickMenuItem(MenuItems.CHAT) + await notificationPageSecond.toggleChatMessage() + await page.waitForTimeout(1000) + await leftSideMenuPage.clickChunter() + await channelPage.clickChannel('general') + await channelPage.sendMessage('Test message') + await channelPage.checkMessageExist('Test message', true, 'Test message') + await leftSideMenuPageSecond.clickNotification() + await inboxPageSecond.checkIfInboxChatExists('Channel general', false) + }) }) diff --git a/tests/sanity/tests/model/inbox.ts/inbox-page.ts b/tests/sanity/tests/model/inbox.ts/inbox-page.ts index 1206f46c09..6a8a607567 100644 --- a/tests/sanity/tests/model/inbox.ts/inbox-page.ts +++ b/tests/sanity/tests/model/inbox.ts/inbox-page.ts @@ -11,6 +11,7 @@ export class InboxPage { readonly toDoName = (): Locator => this.page.getByRole('paragraph') readonly leftSidePanelOpen = (): Locator => this.page.locator('#btnPAside') readonly leftSidePanelClose = (): Locator => this.page.locator('#btnPClose') + readonly inboxChat = (text: string): Locator => this.page.getByText(text) // ACTIONS @@ -33,4 +34,20 @@ export class InboxPage { async checkIfTaskIsPresentInInbox (toDoText: string): Promise { await expect(this.toDoName()).toContainText(toDoText) } + + async clickOnInboxChat (text: string): Promise { + await this.inboxChat(text).click() + } + + async checkIfInboxChatExists (text: string, exists: boolean): Promise { + if (exists) { + await expect(this.inboxChat(text)).toBeVisible() + } else { + await expect(this.inboxChat(text)).not.toBeVisible() + } + } + + async checkIfTextInChatIsPresent (text: string): Promise { + await expect(this.inboxChat(text).nth(1)).toBeVisible() + } } diff --git a/tests/sanity/tests/model/profile/notifications-page.ts b/tests/sanity/tests/model/profile/notifications-page.ts new file mode 100644 index 0000000000..954ab0f73b --- /dev/null +++ b/tests/sanity/tests/model/profile/notifications-page.ts @@ -0,0 +1,100 @@ +import { Page, Locator } from '@playwright/test' + +export enum MenuItems { + COMPANIES = 'Companies', + PERSONS = 'Persons', + CHAT = 'Chat', + REVIEW = 'Review', + APPLICATION = 'Application', + VACANCY = 'Vacancy', + TALENT = 'Talent', + SETTING = 'Setting', + TELEGRAM = 'Telegram', + EMAIL = 'Email', + NOTIFICATIONS = 'Notifications', + ISSUES = 'Issues', + DOCUMENTS = 'Documents', + REQUESTS = 'Requests', + TODOS = "Todo's" +} + +export class NotificationsPage { + private readonly page: Page + + companies = (): Locator => this.page.getByRole('button', { name: 'Companies' }) + persons = (): Locator => this.page.getByRole('button', { name: 'Persons' }) + chat = (): Locator => this.page.getByRole('button', { name: 'Chat' }) + review = (): Locator => this.page.getByRole('button', { name: 'Review' }) + application = (): Locator => this.page.getByRole('button', { name: 'Application' }) + vacancy = (): Locator => this.page.getByRole('button', { name: 'Vacancy' }) + talent = (): Locator => this.page.getByRole('button', { name: 'Talent' }) + setting = (): Locator => this.page.getByRole('button', { name: 'Setting' }) + telegram = (): Locator => this.page.getByRole('button', { name: 'Telegram' }) + email = (): Locator => this.page.getByRole('button', { name: 'Email' }) + notifications = (): Locator => this.page.getByRole('button', { name: 'Notifications' }) + issues = (): Locator => this.page.getByRole('button', { name: 'Issues' }) + documents = (): Locator => this.page.getByRole('button', { name: 'Documents' }) + requests = (): Locator => this.page.getByRole('button', { name: 'Requests' }) + todos = (): Locator => this.page.getByRole('button', { name: "Todo's" }) + chatMessageToggle = (): Locator => this.page.locator('div:nth-child(6) > .flex-between > .toggle > .toggle-switch') + + constructor (page: Page) { + this.page = page + } + + async clickMenuItem (item: MenuItems): Promise { + switch (item) { + case MenuItems.COMPANIES: + await this.companies().click() + break + case MenuItems.PERSONS: + await this.persons().click() + break + case MenuItems.CHAT: + await this.chat().click() + break + case MenuItems.REVIEW: + await this.review().click() + break + case MenuItems.APPLICATION: + await this.application().click() + break + case MenuItems.VACANCY: + await this.vacancy().click() + break + case MenuItems.TALENT: + await this.talent().click() + break + case MenuItems.SETTING: + await this.setting().click() + break + case MenuItems.TELEGRAM: + await this.telegram().click() + break + case MenuItems.EMAIL: + await this.email().click() + break + case MenuItems.NOTIFICATIONS: + await this.notifications().click() + break + case MenuItems.ISSUES: + await this.issues().click() + break + case MenuItems.DOCUMENTS: + await this.documents().click() + break + case MenuItems.REQUESTS: + await this.requests().click() + break + case MenuItems.TODOS: + await this.todos().click() + break + default: + throw new Error('Unknown button type') + } + } + + async toggleChatMessage (): Promise { + await this.chatMessageToggle().click() + } +} diff --git a/tests/sanity/tests/model/profile/user-profile-page.ts b/tests/sanity/tests/model/profile/user-profile-page.ts index 8e6b46cf1e..178d2cddaf 100644 --- a/tests/sanity/tests/model/profile/user-profile-page.ts +++ b/tests/sanity/tests/model/profile/user-profile-page.ts @@ -28,6 +28,7 @@ export class UserProfilePage { savePassword = (): Locator => this.page.getByRole('button', { name: 'Save' }) savedButton = (): Locator => this.page.getByRole('button', { name: 'Saved' }) signOutButton = (): Locator => this.page.getByRole('button', { name: 'Sign out' }) + notificationsButton = (): Locator => this.page.getByRole('button', { name: 'Notifications' }) constructor (page: Page) { this.page = page @@ -95,6 +96,10 @@ export class UserProfilePage { await this.locationInput().fill(newLocation) } + async clickOnNotificationsButton (): Promise { + await this.notificationsButton().click() + } + async changePassword (currentPassword: string, newPassword: string): Promise { await this.changePasswordButton().click() await this.currentPassword().fill(currentPassword)