Skip to content

Commit

Permalink
chore: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed Apr 26, 2024
1 parent c2119fc commit 0ca2cf8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
52 changes: 52 additions & 0 deletions apps/meteor/tests/e2e/read-receipt.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { createAuxContext } from './fixtures/createAuxContext';
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { createTargetChannel, setSettingValueById } from './utils';
import { expect, test } from './utils/test';

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

test.describe.serial('read-receipt', () => {
let poHomeChannel: HomeChannel;
let targetChannel: string;

test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'Message_Read_Receipt_Enabled', true);
targetChannel = await createTargetChannel(api);
});

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);

await page.goto('/home');
});

test('should show read receipts message sent status in the sent message', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.sendMessage('hello world');

await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message sent' })).toBeVisible();
});

test('should show read receipts message viewed status in the sent message', async ({ browser }) => {
const { page } = await createAuxContext(browser, Users.user1);
const auxContext = { page, poHomeChannel: new HomeChannel(page) };
await auxContext.poHomeChannel.sidenav.openChat(targetChannel);
await auxContext.poHomeChannel.content.sendMessage('hello admin');

await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();

await auxContext.page.close();
});

test('should show the reads receipt modal with the users who read the message', async ({ page, api }) => {
await setSettingValueById(api, 'Message_Read_Receipt_Store_Users', true);

await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.openLastMessageMenu();
await page.locator('role=menuitem[name="Info"]').click();

await expect(page.getByRole('dialog').getByRole('listitem')).toHaveCount(2);
});
});
1 change: 1 addition & 0 deletions apps/meteor/tests/e2e/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './create-target-channel';
export * from './setSettingValueById';
2 changes: 2 additions & 0 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,8 @@
"Messages": "Messages",
"Messages_selected": "Messages selected",
"Messages_sent": "Messages sent",
"Message_sent": "Message sent",
"Message_viewed": "Message viewed",
"Messages_that_are_sent_to_the_Incoming_WebHook_will_be_posted_here": "Messages that are sent to the Incoming WebHook will be posted here.",
"Meta": "Meta",
"Meta_Description": "Set custom Meta properties.",
Expand Down

0 comments on commit 0ca2cf8

Please sign in to comment.