diff --git a/.drone.env b/.drone.env index 3361053f3e9..4f24a173d07 100644 --- a/.drone.env +++ b/.drone.env @@ -1,3 +1,3 @@ # The version of OCIS to use in pipelines that test against OCIS -OCIS_COMMITID=964263489149108b3953828dccf2e91264ce5f25 +OCIS_COMMITID=0f77acab45991f77ec24a863186026636b1b2818 OCIS_BRANCH=master diff --git a/tests/e2e/cucumber/features/smoke/notifications.oc10.feature b/tests/e2e/cucumber/features/smoke/notifications.oc10.feature new file mode 100644 index 00000000000..d8c6110a35c --- /dev/null +++ b/tests/e2e/cucumber/features/smoke/notifications.oc10.feature @@ -0,0 +1,29 @@ +Feature: Notifications + As a user + I want to be notified + About new things that concern me + + Background: + Given "Admin" creates following users + | id | + | Alice | + | Brian | + And "Admin" sets the default folder for received shares to "Shares" + And "Admin" disables share auto accepting + + Scenario: User should be able to read and dismiss notifications + Given "Alice" creates the following folder in personal space using API + | name | + | folder_to_shared | + And "Alice" logs in + And "Alice" opens the "files" app + And "Alice" shares the following resource using the sidebar panel + | resource | recipient | type | role | resourceType | + | folder_to_shared | Brian | user | editor | folder | + When "Brian" logs in + Then "Brian" should see the following notifications + | message | + | "Alice Hansen" invited you to view "folder_to_shared" | + And "Brian" marks all notifications as read + Then "Brian" should see no notifications + And "Alice" logs out diff --git a/tests/e2e/cucumber/features/smoke/notifications.ocis.feature b/tests/e2e/cucumber/features/smoke/notifications.ocis.feature new file mode 100644 index 00000000000..f5ee5edadfb --- /dev/null +++ b/tests/e2e/cucumber/features/smoke/notifications.ocis.feature @@ -0,0 +1,68 @@ +Feature: Notifications + As a user + I want to be notified + About new things that concern me + + Background: + Given "Admin" creates following users + | id | + | Alice | + | Brian | + And "Admin" assigns following roles to the users using API + | id | role | + | Alice | Space Admin | + + Scenario: User should be able to read and dismiss notifications + Given "Alice" creates the following folder in personal space using API + | name | + | folder_to_shared | + And "Alice" creates the following project space using API + | name | id | + | team | team.1 | + And "Alice" logs in + And "Alice" opens the "files" app + And "Alice" shares the following resource using the sidebar panel + | resource | recipient | type | role | resourceType | + | folder_to_shared | Brian | user | editor | folder | + And "Alice" navigates to the projects space page + And "Alice" navigates to the project space "team.1" + And "Alice" adds following users to the project space + | user | role | kind | + | Brian | editor | user | + When "Brian" logs in + Then "Brian" should see the following notifications + | message | + | Alice Hansen shared folder_to_shared with you | + | Alice Hansen added you to Space team | + And "Brian" marks all notifications as read + Then "Brian" should see no notifications + When "Alice" opens the "files" app + And "Alice" removes following sharee + | resource | recipient | + | folder_to_shared | Brian | + And "Alice" navigates to the projects space page + And "Alice" navigates to the project space "team.1" + And "Alice" removes access to following users from the project space + | user | role | kind | + | Brian | editor | user | + When "Brian" reloads the page + Then "Brian" should see the following notifications + | message | + | Alice Hansen unshared folder_to_shared with you | + | Alice Hansen removed you from Space team | + And "Brian" marks all notifications as read + Then "Brian" should see no notifications + And "Brian" logs out + When "Alice" opens the "admin-settings" app + And "Alice" navigates to the project spaces management page + And "Alice" disables the space "team.1" using the context-menu + And "Alice" reloads the page + Then "Alice" should see the following notifications + | message | + | Alice Hansen disabled Space team | + And "Alice" deletes the space "team.1" using the context-menu + And "Alice" reloads the page + Then "Alice" should see the following notifications + | message | + | Alice Hansen deleted Space team | + And "Alice" logs out diff --git a/tests/e2e/cucumber/steps/ui/notifications.ts b/tests/e2e/cucumber/steps/ui/notifications.ts new file mode 100644 index 00000000000..a664435435a --- /dev/null +++ b/tests/e2e/cucumber/steps/ui/notifications.ts @@ -0,0 +1,35 @@ +import { DataTable, Then, When } from '@cucumber/cucumber' +import { World } from '../../environment' +import { objects } from '../../../support' +import { expect } from '@playwright/test' + +Then( + '{string} should see the following notification(s)', + async function (this: World, stepUser: string, stepTable: DataTable): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const application = new objects.runtime.Application({ page }) + const messages = await application.getNotificationMessages() + for (const { message } of stepTable.hashes()) { + expect(messages).toContain(message) + } + } +) + +Then( + '{string} should see no notification(s)', + async function (this: World, stepUser: string): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const application = new objects.runtime.Application({ page }) + const messages = await application.getNotificationMessages() + expect(messages.length).toBe(0) + } +) + +When( + '{string} marks all notifications as read', + async function (this: World, stepUser: string): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const application = new objects.runtime.Application({ page }) + await application.markNotificationsAsRead() + } +) diff --git a/tests/e2e/support/objects/runtime/application.ts b/tests/e2e/support/objects/runtime/application.ts index 874d4ff462f..41a4c03a83f 100644 --- a/tests/e2e/support/objects/runtime/application.ts +++ b/tests/e2e/support/objects/runtime/application.ts @@ -3,6 +3,12 @@ import util from 'util' const appSwitcherButton = '#_appSwitcherButton' const appSelector = `//ul[contains(@class, "applications-list")]//a[@href="#/%s" or @href="/%s"]` +const notificationsBell = `#oc-notifications-bell` +const notificationsDrop = `#oc-notifications-drop` +const notificationsLoading = `#oc-notifications-drop .oc-notifications-loading` +const markNotificationsAsReadButton = `#oc-notifications-drop .oc-notifications-mark-all` +const notificationItemsMessages = `#oc-notifications-drop .oc-notifications-item .oc-notifications-message` + export class Application { #page: Page @@ -18,4 +24,28 @@ export class Application { await this.#page.locator(appSwitcherButton).click() await this.#page.locator(util.format(appSelector, name, name)).click() } + + async getNotificationMessages(): Promise { + const dropIsOpen = await this.#page.locator(notificationsDrop).isVisible() + if (!dropIsOpen) { + await this.#page.locator(notificationsBell).click() + } + await this.#page.waitForSelector(notificationsLoading, { state: 'detached' }) + const result = this.#page.locator(notificationItemsMessages) + const messages = [] + const count = await result.count() + for (let i = 0; i < count; i++) { + messages.push(await result.nth(i).innerText()) + } + return messages + } + + async markNotificationsAsRead(): Promise { + const dropIsOpen = await this.#page.locator(notificationsDrop).isVisible() + if (!dropIsOpen) { + await this.#page.locator(notificationsBell).click() + } + await this.#page.waitForSelector(notificationsLoading, { state: 'detached' }) + await this.#page.locator(markNotificationsAsReadButton).click() + } }