Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
140 lines
5.6 KiB
TypeScript
140 lines
5.6 KiB
TypeScript
import { createAuxContext } from './fixtures/createAuxContext';
|
|
import { Users } from './fixtures/userStates';
|
|
import { HomeChannel } from './page-objects';
|
|
import { createTargetChannel, deleteChannel } from './utils';
|
|
import { expect, test } from './utils/test';
|
|
|
|
test.describe.serial('Image Gallery', async () => {
|
|
let poHomeChannel: HomeChannel;
|
|
let targetChannel: string;
|
|
let targetChannelLargeImage: string;
|
|
const viewport = {
|
|
width: 1280,
|
|
height: 720,
|
|
};
|
|
// Using more than 5 images so that new images need to be loaded by the gallery
|
|
const imageNames = ['number1.png', 'number2.png', 'number3.png', 'number4.png', 'number5.png', 'number6.png'];
|
|
|
|
test.use({ viewport });
|
|
|
|
test.beforeAll(async ({ api, browser }) => {
|
|
targetChannel = await createTargetChannel(api);
|
|
targetChannelLargeImage = await createTargetChannel(api);
|
|
const { page } = await createAuxContext(browser, Users.user1);
|
|
poHomeChannel = new HomeChannel(page);
|
|
|
|
await poHomeChannel.navbar.openChat(targetChannelLargeImage);
|
|
await poHomeChannel.composer.btnJoinRoom.click();
|
|
|
|
await poHomeChannel.navbar.openChat(targetChannel);
|
|
await poHomeChannel.composer.btnJoinRoom.click();
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await poHomeChannel.page.close();
|
|
await deleteChannel(api, targetChannel);
|
|
await deleteChannel(api, targetChannelLargeImage);
|
|
});
|
|
|
|
test.describe('When sending an image as a file', () => {
|
|
test.beforeAll(async () => {
|
|
const largeFileName = 'test-large-image.jpeg';
|
|
|
|
await poHomeChannel.navbar.openChat(targetChannel);
|
|
for await (const imageName of imageNames) {
|
|
await poHomeChannel.content.sendFileMessage(imageName);
|
|
await poHomeChannel.composer.btnSend.click();
|
|
await expect(poHomeChannel.content.lastUserMessage).toContainText(imageName);
|
|
}
|
|
|
|
await poHomeChannel.navbar.openChat(targetChannelLargeImage);
|
|
await poHomeChannel.content.sendFileMessage(largeFileName);
|
|
await poHomeChannel.composer.btnSend.click();
|
|
await expect(poHomeChannel.content.lastUserMessage).toContainText(largeFileName);
|
|
|
|
await poHomeChannel.content.lastUserMessage.locator('img.gallery-item').click();
|
|
});
|
|
|
|
test('expect to have a large image not out of viewport bounds', async () => {
|
|
expect(
|
|
await poHomeChannel.content.imageGalleryImage.evaluate((el) => parseInt(window.getComputedStyle(el).getPropertyValue('width'))),
|
|
).toBeLessThanOrEqual(viewport.width);
|
|
|
|
expect(
|
|
await poHomeChannel.content.imageGalleryImage.evaluate((el) => parseInt(window.getComputedStyle(el).getPropertyValue('height'))),
|
|
).toBeLessThanOrEqual(viewport.height);
|
|
});
|
|
|
|
test('expect to zoom in image', async () => {
|
|
await (await poHomeChannel.content.getGalleryButtonByName('zoom-in')).click();
|
|
|
|
expect(parseInt((await poHomeChannel.content.imageGalleryImage.getAttribute('data-qa-zoom-scale')) as string)).toBeGreaterThan(1);
|
|
});
|
|
|
|
test('expect to zoom out image', async () => {
|
|
await (await poHomeChannel.content.getGalleryButtonByName('zoom-out')).click();
|
|
|
|
expect(parseInt((await poHomeChannel.content.imageGalleryImage.getAttribute('data-qa-zoom-scale')) as string)).toEqual(1);
|
|
});
|
|
|
|
test('expect to resize image to default ratio', async () => {
|
|
await expect(await poHomeChannel.content.getGalleryButtonByName('zoom-out')).toBeDisabled();
|
|
|
|
await (await poHomeChannel.content.getGalleryButtonByName('zoom-in')).dblclick();
|
|
|
|
await expect(await poHomeChannel.content.getGalleryButtonByName('zoom-out')).toBeEnabled();
|
|
|
|
await (await poHomeChannel.content.getGalleryButtonByName('resize')).click();
|
|
|
|
expect(parseInt((await poHomeChannel.content.imageGalleryImage.getAttribute('data-qa-zoom-scale')) as string)).toEqual(1);
|
|
});
|
|
|
|
test('expect to close gallery', async () => {
|
|
await (await poHomeChannel.content.getGalleryButtonByName('close')).click();
|
|
|
|
await expect(poHomeChannel.content.imageGalleryImage).not.toBeVisible();
|
|
});
|
|
|
|
test('expect successfully move to older images by using the left arrow button', async () => {
|
|
await poHomeChannel.navbar.openChat(targetChannel);
|
|
await poHomeChannel.content.lastUserMessage.locator('img.gallery-item').click();
|
|
|
|
for (let i = 0; i < imageNames.length - 1; i++) {
|
|
await expect(poHomeChannel.content.previousSlideButton).toBeEnabled();
|
|
await expect(poHomeChannel.content.currentGalleryImage).toHaveAttribute(
|
|
'src',
|
|
new RegExp(`${imageNames[imageNames.length - (i + 1)]}$`),
|
|
);
|
|
await poHomeChannel.content.previousSlideButton.click();
|
|
}
|
|
await expect(poHomeChannel.content.previousSlideButton).toBeDisabled();
|
|
});
|
|
|
|
test('expect successfully move to newer images by using the right arrow button', async () => {
|
|
for (let i = 0; i < imageNames.length - 1; i++) {
|
|
await expect(poHomeChannel.content.nextSlideButton).toBeEnabled();
|
|
await expect(poHomeChannel.content.currentGalleryImage).toHaveAttribute('src', new RegExp(`${imageNames[i]}$`));
|
|
await poHomeChannel.content.nextSlideButton.click();
|
|
}
|
|
await expect(poHomeChannel.content.nextSlideButton).toBeDisabled();
|
|
await (await poHomeChannel.content.getGalleryButtonByName('close')).click();
|
|
});
|
|
});
|
|
|
|
test.describe('When sending an image as a link', () => {
|
|
const imageLink = 'https://raw.githubusercontent.com/RocketChat/Rocket.Chat.Artwork/master/Logos/2020/png/logo-horizontal-red.png';
|
|
|
|
test.beforeAll(async () => {
|
|
await poHomeChannel.content.sendMessage(imageLink);
|
|
|
|
await expect(poHomeChannel.content.lastUserMessage).toContainText(imageLink);
|
|
|
|
await poHomeChannel.content.lastUserMessage.locator('img.preview-image').click();
|
|
});
|
|
|
|
test('expect to open the image inside the image gallery', async () => {
|
|
await expect(poHomeChannel.content.imageGalleryImage).toBeVisible();
|
|
});
|
|
});
|
|
});
|