2024-04-02 12:13:06 +02:00
|
|
|
import { expect, test } from '@playwright/test';
|
|
|
|
|
|
|
|
|
|
import { waitForElementCount } from '../helpers';
|
|
|
|
|
|
|
|
|
|
import { createTeam, keyCloakSignIn } from './common';
|
|
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page, browserName }) => {
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
await keyCloakSignIn(page, browserName);
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-03 11:49:14 +02:00
|
|
|
test.describe('Pads Panel', () => {
|
2024-04-02 12:13:06 +02:00
|
|
|
test('checks all the elements are visible', async ({ page }) => {
|
2024-04-03 11:49:14 +02:00
|
|
|
const panel = page.getByLabel('Pads panel').first();
|
2024-04-02 12:13:06 +02:00
|
|
|
|
|
|
|
|
await expect(panel.getByText('Recents')).toBeVisible();
|
|
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
|
panel.getByRole('button', {
|
2024-04-03 11:49:14 +02:00
|
|
|
name: 'Sort the pads',
|
2024-04-02 12:13:06 +02:00
|
|
|
}),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
|
panel.getByRole('button', {
|
2024-04-03 11:49:14 +02:00
|
|
|
name: 'Add a pad',
|
2024-04-02 12:13:06 +02:00
|
|
|
}),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('checks the sort button', async ({ page }) => {
|
|
|
|
|
const responsePromiseSortDesc = page.waitForResponse(
|
|
|
|
|
(response) =>
|
2024-04-03 11:49:14 +02:00
|
|
|
response.url().includes('/pads/?page=1&ordering=-created_at') &&
|
2024-04-02 12:13:06 +02:00
|
|
|
response.status() === 200,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const responsePromiseSortAsc = page.waitForResponse(
|
|
|
|
|
(response) =>
|
2024-04-03 11:49:14 +02:00
|
|
|
response.url().includes('/pads/?page=1&ordering=created_at') &&
|
2024-04-02 12:13:06 +02:00
|
|
|
response.status() === 200,
|
|
|
|
|
);
|
|
|
|
|
|
2024-04-03 11:49:14 +02:00
|
|
|
const panel = page.getByLabel('Pads panel').first();
|
2024-04-02 12:13:06 +02:00
|
|
|
|
|
|
|
|
await panel
|
|
|
|
|
.getByRole('button', {
|
2024-04-03 11:49:14 +02:00
|
|
|
name: 'Sort the pads by creation date ascendent',
|
2024-04-02 12:13:06 +02:00
|
|
|
})
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
const responseSortAsc = await responsePromiseSortAsc;
|
|
|
|
|
expect(responseSortAsc.ok()).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
await panel
|
|
|
|
|
.getByRole('button', {
|
2024-04-03 11:49:14 +02:00
|
|
|
name: 'Sort the pads by creation date descendent',
|
2024-04-02 12:13:06 +02:00
|
|
|
})
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
const responseSortDesc = await responsePromiseSortDesc;
|
|
|
|
|
expect(responseSortDesc.ok()).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('checks the infinite scroll', async ({ page, browserName }) => {
|
|
|
|
|
test.setTimeout(90000);
|
2024-04-03 11:49:14 +02:00
|
|
|
const panel = page.getByLabel('Pads panel').first();
|
2024-04-02 12:13:06 +02:00
|
|
|
|
2024-04-03 11:49:14 +02:00
|
|
|
const randomTeams = await createTeam(page, 'pad-infinite', browserName, 40);
|
2024-04-02 12:13:06 +02:00
|
|
|
|
|
|
|
|
await expect(panel.locator('li')).toHaveCount(20);
|
|
|
|
|
await panel.getByText(randomTeams[24]).click();
|
|
|
|
|
|
|
|
|
|
await waitForElementCount(panel.locator('li'), 21, 10000);
|
|
|
|
|
expect(await panel.locator('li').count()).toBeGreaterThan(20);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('checks the hover and selected state', async ({ page, browserName }) => {
|
2024-04-03 11:49:14 +02:00
|
|
|
const panel = page.getByLabel('Pads panel').first();
|
|
|
|
|
await createTeam(page, 'pad-hover', browserName, 2);
|
2024-04-02 12:13:06 +02:00
|
|
|
|
|
|
|
|
const selectedTeam = panel.locator('li').nth(0);
|
|
|
|
|
await expect(selectedTeam).toHaveCSS(
|
|
|
|
|
'background-color',
|
|
|
|
|
'rgb(202, 202, 251)',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const hoverTeam = panel.locator('li').nth(1);
|
|
|
|
|
await hoverTeam.hover();
|
|
|
|
|
await expect(hoverTeam).toHaveCSS('background-color', 'rgb(227, 227, 253)');
|
|
|
|
|
});
|
|
|
|
|
});
|