Skip to content

Commit

Permalink
feat: improving test
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanPazRibeiro committed May 7, 2024
1 parent f9df2e3 commit 0f30b24
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
25 changes: 14 additions & 11 deletions apps/meteor/tests/e2e/admin-room.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { faker } from '@faker-js/faker';
import { Page } from '@playwright/test';

import { Users } from './fixtures/userStates';
import { Admin } from './page-objects';
import { Admin, AdminSectionsHref } from './page-objects';
import { createTargetChannel, createTargetPrivateChannel } from './utils';
import { expect, test } from './utils/test';

test.use({ storageState: Users.admin.state });

test.describe.serial('admin-rooms', () => {
let adminPage: Page;
let channel: string;
let privateRoom: string;
let admin: Admin;
Expand All @@ -20,12 +18,15 @@ test.describe.serial('admin-rooms', () => {
});

test.beforeAll(async ({ browser, api }) => {
adminPage = await browser.newPage({ storageState: Users.admin.state });
await adminPage.goto('/home');
await adminPage.waitForSelector('[data-qa-id="home-header"]');

channel = await createTargetChannel(api);
privateRoom = await createTargetPrivateChannel(api);
[channel, privateRoom] = await Promise.all([
createTargetChannel(api),
createTargetPrivateChannel(api),
browser.newPage({ storageState: Users.admin.state }).then(async (page) => {
await page.goto('/home');
await page.waitForSelector('[data-qa-id="home-header"]');
return page;
}),
]);
});

test('should display the Rooms Table', async ({ page }) => {
Expand Down Expand Up @@ -93,9 +94,11 @@ test.describe.serial('admin-rooms', () => {
await privateOption.waitFor();
await privateOption.click();

await page.goto('/admin/info');
const workspaceButton = await admin.adminSectionButton(AdminSectionsHref.Workspace);
await workspaceButton.click();

await page.goto('/admin/rooms');
const roomsButton = await admin.adminSectionButton(AdminSectionsHref.Rooms);
await roomsButton.click();

const selectDropdown = await admin.dropdownFilterRoomType('All rooms');
await expect(selectDropdown).toBeVisible();
Expand Down
26 changes: 26 additions & 0 deletions apps/meteor/tests/e2e/page-objects/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@ import type { Locator, Page } from '@playwright/test';

import { AdminFlextab } from './fragments/admin-flextab';

export enum AdminSectionsHref {
Workspace = '/admin/info',
Subscription = '/admin/subscription',
Engagement = '/admin/engagement/users',
Moderation = '/admin/moderation',
Federation = '/admin/federation',
Rooms = '/admin/rooms',
Users = '/admin/users',
Invites = '/admin/invites',
User_Status = '/admin/user-status',
Permissions = '/admin/permissions',
Device_Management = '/admin/device-management',
Email_Inboxes = '/admin/email-inboxes',
Mailer = '/admin/mailer',
Third_party_login = '/admin/third-party-login',
Integrations = '/admin/integrations',
Import = '/admin/import',
Reports = '/admin/reports',
Sounds = '/admin/sounds',
Emoji = '/admin/emoji',
Settings = '/admin/settings',
}
export class Admin {
public readonly page: Page;

Expand Down Expand Up @@ -188,4 +210,8 @@ export class Admin {
async dropdownFilterRoomType(text = 'All rooms'): Promise<Locator> {
return this.page.locator(`div[role="button"]:has-text("${text}")`);
}

async adminSectionButton(href: AdminSectionsHref): Promise<Locator> {
return this.page.locator(`a[href="${href}"]`);
}
}
4 changes: 2 additions & 2 deletions packages/mock-providers/src/MockedQueryClientWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import React from "react";
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from 'react';

export const MockedQueryClientWrapper = () => {
const queryClient = new QueryClient();
Expand Down

0 comments on commit 0f30b24

Please sign in to comment.