2024-09-11 23:34:33 +03:00
|
|
|
// @watch start
|
|
|
|
// routers/web/user/**
|
|
|
|
// templates/shared/user/**
|
|
|
|
// web_src/js/features/common-global.js
|
|
|
|
// @watch end
|
|
|
|
|
2024-08-15 00:34:36 +03:00
|
|
|
import {expect} from '@playwright/test';
|
2024-11-08 11:55:54 +03:00
|
|
|
import {test, login_user, load_logged_in_context} from './utils_e2e.ts';
|
2024-07-16 22:30:47 +03:00
|
|
|
|
|
|
|
test('Follow actions', async ({browser}, workerInfo) => {
|
|
|
|
await login_user(browser, workerInfo, 'user2');
|
|
|
|
const context = await load_logged_in_context(browser, workerInfo, 'user2');
|
|
|
|
const page = await context.newPage();
|
|
|
|
|
|
|
|
await page.goto('/user1');
|
|
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
|
|
|
|
// Check if following and then unfollowing works.
|
|
|
|
// This checks that the event listeners of
|
2024-08-08 19:07:35 +03:00
|
|
|
// the buttons aren't disappearing.
|
2024-07-16 22:30:47 +03:00
|
|
|
const followButton = page.locator('.follow');
|
|
|
|
await expect(followButton).toContainText('Follow');
|
|
|
|
await followButton.click();
|
|
|
|
await expect(followButton).toContainText('Unfollow');
|
|
|
|
await followButton.click();
|
|
|
|
await expect(followButton).toContainText('Follow');
|
|
|
|
|
|
|
|
// Simple block interaction.
|
|
|
|
await expect(page.locator('.block')).toContainText('Block');
|
|
|
|
|
|
|
|
await page.locator('.block').click();
|
|
|
|
await expect(page.locator('#block-user')).toBeVisible();
|
|
|
|
await page.locator('#block-user .ok').click();
|
|
|
|
await expect(page.locator('.block')).toContainText('Unblock');
|
2024-07-22 21:03:32 +03:00
|
|
|
await expect(page.locator('#block-user')).toBeHidden();
|
2024-07-16 22:30:47 +03:00
|
|
|
|
|
|
|
// Check that following the user yields in a error being shown.
|
|
|
|
await followButton.click();
|
|
|
|
const flashMessage = page.locator('#flash-message');
|
|
|
|
await expect(flashMessage).toBeVisible();
|
|
|
|
await expect(flashMessage).toContainText('You cannot follow this user because you have blocked this user or this user has blocked you.');
|
|
|
|
|
|
|
|
// Unblock interaction.
|
|
|
|
await page.locator('.block').click();
|
|
|
|
await expect(page.locator('.block')).toContainText('Block');
|
|
|
|
});
|