mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05:00
40551de313
Goals: - speedup - less flakiness - best practices and more use - documentation config: - sync ports in Makefile and playwright config (otherwise, some tests fail locally because they assert the full URL including the (wrong) port) - even more generous timeouts - limit workers to one again (because I finally understand how Playwright works) - allow nested functions to group them together with the related test all: - deprecate waitForLoadState('networkidle') - it is discouraged as per https://playwright.dev/docs/api/class-page#page-wait-for-load-state - I could not find a usage that seems to require it actually (see added documentation in README) - adding an exception should be made explicitly - it does not do what you might expect anyway in most cases - only log in when necessary webauthn: - verify that login is possible after disabling key - otherwise, the cleanup was not necessary after the previous refactor to create a fresh user each issue-sidebar / WIP toggle: - split into smaller chunks - restore original state first - add missed assertion to fix race condition (not waiting before state was reached) - explicitly toggle the state to detect mismatch earlier issue-sidebar / labels: - restore original state first - better waiting for background request
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
// @watch start
|
|
// routers/web/user/**
|
|
// templates/shared/user/**
|
|
// web_src/js/features/common-global.js
|
|
// @watch end
|
|
|
|
import {expect} from '@playwright/test';
|
|
import {test, login_user, load_logged_in_context} from './utils_e2e.ts';
|
|
|
|
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');
|
|
|
|
// Check if following and then unfollowing works.
|
|
// This checks that the event listeners of
|
|
// the buttons aren't disappearing.
|
|
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');
|
|
await expect(page.locator('#block-user')).toBeHidden();
|
|
|
|
// 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');
|
|
});
|