|
| 1 | +import { faker } from '@faker-js/faker'; |
| 2 | + |
| 3 | +import { Users } from './fixtures/userStates'; |
| 4 | +import { Admin, AdminSectionsHref } from './page-objects'; |
| 5 | +import { createTargetChannel, createTargetPrivateChannel } from './utils'; |
| 6 | +import { expect, test } from './utils/test'; |
| 7 | + |
| 8 | +test.use({ storageState: Users.admin.state }); |
| 9 | + |
| 10 | +test.describe.serial('admin-rooms', () => { |
| 11 | + let channel: string; |
| 12 | + let privateRoom: string; |
| 13 | + let admin: Admin; |
| 14 | + |
| 15 | + test.beforeEach(async ({ page }) => { |
| 16 | + admin = new Admin(page); |
| 17 | + await page.goto('/admin/rooms'); |
| 18 | + }); |
| 19 | + |
| 20 | + test.beforeAll(async ({ browser, api }) => { |
| 21 | + [channel, privateRoom] = await Promise.all([ |
| 22 | + createTargetChannel(api), |
| 23 | + createTargetPrivateChannel(api), |
| 24 | + browser.newPage({ storageState: Users.admin.state }).then(async (page) => { |
| 25 | + await page.goto('/home'); |
| 26 | + await page.waitForSelector('[data-qa-id="home-header"]'); |
| 27 | + return page; |
| 28 | + }), |
| 29 | + ]); |
| 30 | + }); |
| 31 | + |
| 32 | + test('should display the Rooms Table', async ({ page }) => { |
| 33 | + await expect(page.locator('[data-qa-type="PageHeader-title"]')).toContainText('Rooms'); |
| 34 | + }); |
| 35 | + |
| 36 | + test('should filter room by name', async ({ page }) => { |
| 37 | + await admin.inputSearchRooms.fill(channel); |
| 38 | + |
| 39 | + await expect(page.locator(`[qa-room-name="${channel}"]`)).toBeVisible(); |
| 40 | + }); |
| 41 | + |
| 42 | + test('should filter rooms by type', async ({ page }) => { |
| 43 | + const dropdown = await admin.dropdownFilterRoomType(); |
| 44 | + await dropdown.click(); |
| 45 | + |
| 46 | + const privateOption = page.locator('text=Private channels'); |
| 47 | + |
| 48 | + await privateOption.waitFor(); |
| 49 | + await privateOption.click(); |
| 50 | + |
| 51 | + const selectedDropdown = await admin.dropdownFilterRoomType('Rooms (1)'); |
| 52 | + await expect(selectedDropdown).toBeVisible(); |
| 53 | + |
| 54 | + await expect(page.locator('text=Private Channel').first()).toBeVisible(); |
| 55 | + }); |
| 56 | + |
| 57 | + test('should filter rooms by type and name', async ({ page }) => { |
| 58 | + await admin.inputSearchRooms.fill(privateRoom); |
| 59 | + |
| 60 | + const dropdown = await admin.dropdownFilterRoomType(); |
| 61 | + await dropdown.click(); |
| 62 | + |
| 63 | + await page.locator('text=Private channels').click(); |
| 64 | + |
| 65 | + await expect(page.locator(`[qa-room-name="${privateRoom}"]`)).toBeVisible(); |
| 66 | + }); |
| 67 | + |
| 68 | + test('should be empty in case of the search does not find any room', async ({ page }) => { |
| 69 | + const nonExistingChannel = faker.string.alpha(10); |
| 70 | + |
| 71 | + await admin.inputSearchRooms.fill(nonExistingChannel); |
| 72 | + |
| 73 | + const dropdown = await admin.dropdownFilterRoomType(); |
| 74 | + await dropdown.click(); |
| 75 | + |
| 76 | + await page.locator('text=Private channels').click(); |
| 77 | + |
| 78 | + await expect(page.locator('text=No results found')).toBeVisible(); |
| 79 | + }); |
| 80 | + |
| 81 | + test('should filter rooms by type and name and clean the filter after changing section', async ({ page }) => { |
| 82 | + await admin.inputSearchRooms.fill(privateRoom); |
| 83 | + const dropdown = await admin.dropdownFilterRoomType(); |
| 84 | + await dropdown.click(); |
| 85 | + |
| 86 | + await page.locator('text=Private channels').click(); |
| 87 | + |
| 88 | + const workspaceButton = await admin.adminSectionButton(AdminSectionsHref.Workspace); |
| 89 | + await workspaceButton.click(); |
| 90 | + |
| 91 | + const roomsButton = await admin.adminSectionButton(AdminSectionsHref.Rooms); |
| 92 | + await roomsButton.click(); |
| 93 | + |
| 94 | + const selectDropdown = await admin.dropdownFilterRoomType('All rooms'); |
| 95 | + await expect(selectDropdown).toBeVisible(); |
| 96 | + }); |
| 97 | +}); |
0 commit comments