summaryrefslogtreecommitdiffstats
path: root/tests/e2e/profile_actions.test.e2e.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
commitdd136858f1ea40ad3c94191d647487fa4f31926c (patch)
tree58fec94a7b2a12510c9664b21793f1ed560c6518 /tests/e2e/profile_actions.test.e2e.js
parentInitial commit. (diff)
downloadforgejo-debian.tar.xz
forgejo-debian.zip
Adding upstream version 9.0.0.upstream/9.0.0upstreamdebian
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'tests/e2e/profile_actions.test.e2e.js')
-rw-r--r--tests/e2e/profile_actions.test.e2e.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/e2e/profile_actions.test.e2e.js b/tests/e2e/profile_actions.test.e2e.js
new file mode 100644
index 0000000..dcec0cd
--- /dev/null
+++ b/tests/e2e/profile_actions.test.e2e.js
@@ -0,0 +1,41 @@
+// @ts-check
+import {expect} from '@playwright/test';
+import {test, login_user, load_logged_in_context} from './utils_e2e.js';
+
+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
+ // 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');
+});