aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/emails/user_email_test.exs2
-rw-r--r--test/fixtures/tesla_mock/fe-bundle.zipbin0 -> 318 bytes
-rw-r--r--test/fixtures/tesla_mock/gitlab-api-pleroma-fe-branches.json482
-rw-r--r--test/fixtures/tesla_mock/gitlab-api-pleroma-fe-releases.json188
-rw-r--r--test/frontend_test.exs34
-rw-r--r--test/instance_static/frontends/admin/develop/index.html1
-rw-r--r--test/instance_static/frontends/kenoma/develop/index.html2
-rw-r--r--test/instance_static/frontends/mastodon/develop/index.html1
-rw-r--r--test/instance_static/frontends/pleroma/develop/index.html2
-rw-r--r--test/plugs/frontend_plug_test.exs31
-rw-r--r--test/plugs/instance_static_test.exs64
-rw-r--r--test/tasks/frontend_test.exs69
-rw-r--r--test/tasks/instance_test.exs22
-rw-r--r--test/web/controller/frontend/admin_controller_test.exs12
-rw-r--r--test/web/controller/frontend/headless_controller_test.exs16
-rw-r--r--test/web/controller/frontend/kenoma_controller_test.exs16
-rw-r--r--test/web/controller/frontend/mastodon_controller_test.exs85
-rw-r--r--test/web/controller/frontend/pleroma_controller_test.exs24
-rw-r--r--test/web/controller/frontend/static_controller_test.exs (renamed from test/web/static_fe/static_fe_controller_test.exs)37
-rw-r--r--test/web/fallback_test.exs4
-rw-r--r--test/web/feed/user_controller_test.exs12
-rw-r--r--test/web/ostatus/ostatus_controller_test.exs2
22 files changed, 1057 insertions, 49 deletions
diff --git a/test/emails/user_email_test.exs b/test/emails/user_email_test.exs
index a75623bb4..c6044a8a5 100644
--- a/test/emails/user_email_test.exs
+++ b/test/emails/user_email_test.exs
@@ -31,7 +31,7 @@ defmodule Pleroma.Emails.UserEmailTest do
assert email.to == [{"Jonh", "test@test.com"}]
assert email.html_body =~
- Router.Helpers.redirect_url(Endpoint, :registration_page, token.token)
+ Router.Helpers.frontend_url(Endpoint, :registration_page, token.token)
end
test "build account confirmation email" do
diff --git a/test/fixtures/tesla_mock/fe-bundle.zip b/test/fixtures/tesla_mock/fe-bundle.zip
new file mode 100644
index 000000000..0199e028b
--- /dev/null
+++ b/test/fixtures/tesla_mock/fe-bundle.zip
Binary files differ
diff --git a/test/fixtures/tesla_mock/gitlab-api-pleroma-fe-branches.json b/test/fixtures/tesla_mock/gitlab-api-pleroma-fe-branches.json
new file mode 100644
index 000000000..0f1d303c6
--- /dev/null
+++ b/test/fixtures/tesla_mock/gitlab-api-pleroma-fe-branches.json
@@ -0,0 +1,482 @@
+[
+ {
+ "name": "718",
+ "commit": {
+ "id": "c55e73d06165888378f1470fda1c69eb10562b02",
+ "short_id": "c55e73d0",
+ "created_at": "2019-12-15T19:31:40.000+00:00",
+ "parent_ids": null,
+ "title": "fix mobile layout",
+ "message": "fix mobile layout",
+ "author_name": "taehoon",
+ "author_email": "th.dev91@gmail.com",
+ "authored_date": "2019-11-25T18:01:43.000+00:00",
+ "committer_name": "taehoon",
+ "committer_email": "th.dev91@gmail.com",
+ "committed_date": "2019-12-15T19:31:40.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/c55e73d06165888378f1470fda1c69eb10562b02"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "chore/improve-default-tos",
+ "commit": {
+ "id": "1946661911c97651ba5356db22a0ddd00ba04864",
+ "short_id": "19466619",
+ "created_at": "2019-11-09T06:27:09.000+00:00",
+ "parent_ids": null,
+ "title": "update terms of service instructions",
+ "message": "update terms of service instructions",
+ "author_name": "Ariadne Conill",
+ "author_email": "ariadne@dereferenced.org",
+ "authored_date": "2019-11-09T06:27:09.000+00:00",
+ "committer_name": "Ariadne Conill",
+ "committer_email": "ariadne@dereferenced.org",
+ "committed_date": "2019-11-09T06:27:09.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/1946661911c97651ba5356db22a0ddd00ba04864"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "ci-fixes",
+ "commit": {
+ "id": "ce6cac9b8a1e0780444bd2d05feb627d0f9a2c0d",
+ "short_id": "ce6cac9b",
+ "created_at": "2019-11-20T12:50:46.000+00:00",
+ "parent_ids": null,
+ "title": "update ci node version",
+ "message": "update ci node version",
+ "author_name": "lain",
+ "author_email": "lain@soykaf.club",
+ "authored_date": "2019-11-20T12:41:44.000+00:00",
+ "committer_name": "lain",
+ "committer_email": "lain@soykaf.club",
+ "committed_date": "2019-11-20T12:50:46.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/ce6cac9b8a1e0780444bd2d05feb627d0f9a2c0d"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "deploy-ci",
+ "commit": {
+ "id": "efb159fb02ca43f7583c5b05d23010be47a8fffa",
+ "short_id": "efb159fb",
+ "created_at": "2019-03-04T18:28:23.000+00:00",
+ "parent_ids": null,
+ "title": "experiment",
+ "message": "experiment",
+ "author_name": "Henry Jameson",
+ "author_email": "me@hjkos.com",
+ "authored_date": "2019-03-04T18:28:23.000+00:00",
+ "committer_name": "Henry Jameson",
+ "committer_email": "me@hjkos.com",
+ "committed_date": "2019-03-04T18:28:23.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/efb159fb02ca43f7583c5b05d23010be47a8fffa"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "develop",
+ "commit": {
+ "id": "d5457c323a186ed7890e7ba311c36d189c33d3fa",
+ "short_id": "d5457c32",
+ "created_at": "2020-04-01T14:00:22.000+00:00",
+ "parent_ids": null,
+ "title": "Merge branch 'fix/boosts-favs-private-instance' into 'develop'",
+ "message": "Merge branch 'fix/boosts-favs-private-instance' into 'develop'",
+ "author_name": "Shpuld Shpludson",
+ "author_email": "shp@cock.li",
+ "authored_date": "2020-04-01T14:00:22.000+00:00",
+ "committer_name": "Shpuld Shpludson",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2020-04-01T14:00:22.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/d5457c323a186ed7890e7ba311c36d189c33d3fa"
+ },
+ "merged": false,
+ "protected": true,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": true
+ },
+ {
+ "name": "dokku",
+ "commit": {
+ "id": "2750deb0da1a6cb323390a137b2c371e8b71b457",
+ "short_id": "2750deb0",
+ "created_at": "2019-06-11T10:28:10.000+00:00",
+ "parent_ids": null,
+ "title": "CI: Add optional review instance.",
+ "message": "CI: Add optional review instance.",
+ "author_name": "lain",
+ "author_email": "lain@soykaf.club",
+ "authored_date": "2019-06-11T10:28:10.000+00:00",
+ "committer_name": "lain",
+ "committer_email": "lain@soykaf.club",
+ "committed_date": "2019-06-11T10:28:10.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/2750deb0da1a6cb323390a137b2c371e8b71b457"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "emoji-mastoapi",
+ "commit": {
+ "id": "c651d48a8c6aa5c75e71a0b55176c3b3586ca83f",
+ "short_id": "c651d48a",
+ "created_at": "2019-09-26T18:38:03.000+00:00",
+ "parent_ids": null,
+ "title": "use mastoapi emoji endpoint since it's already sorted, should speed things up on",
+ "message": "use mastoapi emoji endpoint since it's already sorted, should speed things up on",
+ "author_name": "Henry Jameson",
+ "author_email": "me@hjkos.com",
+ "authored_date": "2019-09-26T18:38:03.000+00:00",
+ "committer_name": "Henry Jameson",
+ "committer_email": "me@hjkos.com",
+ "committed_date": "2019-09-26T18:38:03.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/c651d48a8c6aa5c75e71a0b55176c3b3586ca83f"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feat/custom-chat-scroll-to-bottom",
+ "commit": {
+ "id": "507d4469928c464fc51b34c6e569027240edc931",
+ "short_id": "507d4469",
+ "created_at": "2018-04-16T17:54:29.000+00:00",
+ "parent_ids": null,
+ "title": "Remove vue-chat-scroll, add custom scroll-to-bottom behavior (still doesn't work perfect)",
+ "message": "Remove vue-chat-scroll, add custom scroll-to-bottom behavior (still doesn't work perfect)",
+ "author_name": "shpuld",
+ "author_email": "shp@cock.li",
+ "authored_date": "2018-04-16T17:54:29.000+00:00",
+ "committer_name": "shpuld",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2018-04-16T17:54:29.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/507d4469928c464fc51b34c6e569027240edc931"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feat/custom-virtual-scrolling",
+ "commit": {
+ "id": "16408410135955036de261819667f88561a2e488",
+ "short_id": "16408410",
+ "created_at": "2020-03-18T12:23:37.000+00:00",
+ "parent_ids": null,
+ "title": "cap virtual scroll index before use",
+ "message": "cap virtual scroll index before use",
+ "author_name": "Shpuld Shpuldson",
+ "author_email": "shp@cock.li",
+ "authored_date": "2020-03-18T12:23:37.000+00:00",
+ "committer_name": "Shpuld Shpuldson",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2020-03-18T12:23:37.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/16408410135955036de261819667f88561a2e488"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feat/more-aggressive-user-search",
+ "commit": {
+ "id": "1750866545398c5f832420c9bb896e97b94d4d87",
+ "short_id": "17508665",
+ "created_at": "2019-07-18T16:33:46.000+00:00",
+ "parent_ids": null,
+ "title": "fetch users even when we have some results for better results",
+ "message": "fetch users even when we have some results for better results",
+ "author_name": "shpuld",
+ "author_email": "shp@cock.li",
+ "authored_date": "2019-07-18T16:33:46.000+00:00",
+ "committer_name": "shpuld",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2019-07-18T16:33:46.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/1750866545398c5f832420c9bb896e97b94d4d87"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feat/update_chinese_translation",
+ "commit": {
+ "id": "df5cb12af0f43d70baa3403a4a6c78302740a555",
+ "short_id": "df5cb12a",
+ "created_at": "2019-03-07T19:41:42.000+00:00",
+ "parent_ids": null,
+ "title": "Update chinese a bit",
+ "message": "Update chinese a bit",
+ "author_name": "shpuld",
+ "author_email": "shp@cock.li",
+ "authored_date": "2019-03-07T19:41:42.000+00:00",
+ "committer_name": "shpuld",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2019-03-07T19:41:42.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/df5cb12af0f43d70baa3403a4a6c78302740a555"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feat/virtual-scrolling-timeline",
+ "commit": {
+ "id": "8c9b7bf533f22ee0bf3c93b6ab49597c953e550b",
+ "short_id": "8c9b7bf5",
+ "created_at": "2020-01-15T09:54:12.000+00:00",
+ "parent_ids": null,
+ "title": "update vue, try to use vue virtual scroller, not great",
+ "message": "update vue, try to use vue virtual scroller, not great",
+ "author_name": "Shpuld Shpuldson",
+ "author_email": "shpuld@shpposter.club",
+ "authored_date": "2020-01-15T09:54:12.000+00:00",
+ "committer_name": "Shpuld Shpuldson",
+ "committer_email": "shpuld@shpposter.club",
+ "committed_date": "2020-01-15T09:54:12.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/8c9b7bf533f22ee0bf3c93b6ab49597c953e550b"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feat/virtual-with-popover",
+ "commit": {
+ "id": "900f05557ea273acadda83ebca6bcd7cd63622c6",
+ "short_id": "900f0555",
+ "created_at": "2020-02-17T14:25:26.000+00:00",
+ "parent_ids": null,
+ "title": "Merge branch 'fix/popover-performance' into feat/virtual-with-popover",
+ "message": "Merge branch 'fix/popover-performance' into feat/virtual-with-popover",
+ "author_name": "Shpuld Shpuldson",
+ "author_email": "shp@cock.li",
+ "authored_date": "2020-02-17T14:25:26.000+00:00",
+ "committer_name": "Shpuld Shpuldson",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2020-02-17T14:25:26.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/900f05557ea273acadda83ebca6bcd7cd63622c6"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feature/client-side-greentext",
+ "commit": {
+ "id": "6b9843406772c5e5286cd0f693016c68601f9770",
+ "short_id": "6b984340",
+ "created_at": "2017-08-25T08:59:46.000+00:00",
+ "parent_ids": null,
+ "title": "Make tests pass.",
+ "message": "Make tests pass.",
+ "author_name": "eal",
+ "author_email": "eal@waifu.club",
+ "authored_date": "2017-08-25T08:59:46.000+00:00",
+ "committer_name": "eal",
+ "committer_email": "eal@waifu.club",
+ "committed_date": "2017-08-25T08:59:46.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/6b9843406772c5e5286cd0f693016c68601f9770"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feature/copy-link",
+ "commit": {
+ "id": "8c5946b72881c38ce43a4b25bda8a38d4f08aac3",
+ "short_id": "8c5946b7",
+ "created_at": "2020-03-30T17:39:28.000+00:00",
+ "parent_ids": null,
+ "title": "Add button in 3dot menu to copy status link to clipboard",
+ "message": "Add button in 3dot menu to copy status link to clipboard",
+ "author_name": "Mark Felder",
+ "author_email": "feld@FreeBSD.org",
+ "authored_date": "2020-03-30T17:39:28.000+00:00",
+ "committer_name": "Mark Felder",
+ "committer_email": "feld@FreeBSD.org",
+ "committed_date": "2020-03-30T17:39:28.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/8c5946b72881c38ce43a4b25bda8a38d4f08aac3"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feature/default-scope",
+ "commit": {
+ "id": "d0ee10a433f86cf0b4aacb803f569040b87d4e95",
+ "short_id": "d0ee10a4",
+ "created_at": "2018-07-12T17:32:50.000+00:00",
+ "parent_ids": null,
+ "title": "fix lint issues",
+ "message": "fix lint issues",
+ "author_name": "William Pitcock",
+ "author_email": "nenolod@dereferenced.org",
+ "authored_date": "2018-06-27T13:28:07.000+00:00",
+ "committer_name": "William Pitcock",
+ "committer_email": "nenolod@dereferenced.org",
+ "committed_date": "2018-07-12T17:32:50.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/d0ee10a433f86cf0b4aacb803f569040b87d4e95"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feature/desktop-about-page",
+ "commit": {
+ "id": "69e551911c8855d72e32f04a09bf598b9defc9ea",
+ "short_id": "69e55191",
+ "created_at": "2019-10-01T09:31:57.000+00:00",
+ "parent_ids": null,
+ "title": "instance specific panel: style differently if docked into the about page",
+ "message": "instance specific panel: style differently if docked into the about page",
+ "author_name": "Ariadne Conill",
+ "author_email": "ariadne@dereferenced.org",
+ "authored_date": "2019-10-01T09:31:29.000+00:00",
+ "committer_name": "Ariadne Conill",
+ "committer_email": "ariadne@dereferenced.org",
+ "committed_date": "2019-10-01T09:31:57.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/69e551911c8855d72e32f04a09bf598b9defc9ea"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feature/floating-collapse-button",
+ "commit": {
+ "id": "b6d3f6f3674d605e55874f0934df01552649bef9",
+ "short_id": "b6d3f6f3",
+ "created_at": "2017-06-08T11:36:13.000+00:00",
+ "parent_ids": null,
+ "title": "fix lint",
+ "message": "fix lint",
+ "author_name": "Shpuld Shpuldson",
+ "author_email": "shpuld@gmail.com",
+ "authored_date": "2017-06-08T11:36:13.000+00:00",
+ "committer_name": "Shpuld Shpuldson",
+ "committer_email": "shpuld@gmail.com",
+ "committed_date": "2017-06-08T11:36:13.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/b6d3f6f3674d605e55874f0934df01552649bef9"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feature/force-update-timeline",
+ "commit": {
+ "id": "5396218b7983211e4fdad9080d06da2e4e02713e",
+ "short_id": "5396218b",
+ "created_at": "2016-12-23T15:52:40.000+00:00",
+ "parent_ids": null,
+ "title": "Remove 'source' text.",
+ "message": "Remove 'source' text.",
+ "author_name": "Roger Braun",
+ "author_email": "roger@rogerbraun.net",
+ "authored_date": "2016-12-23T15:52:40.000+00:00",
+ "committer_name": "Roger Braun",
+ "committer_email": "roger@rogerbraun.net",
+ "committed_date": "2016-12-23T15:52:40.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/5396218b7983211e4fdad9080d06da2e4e02713e"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ },
+ {
+ "name": "feature/groups",
+ "commit": {
+ "id": "c52173c64b67f3ed2dbd8574234110ceb5bdf4a9",
+ "short_id": "c52173c6",
+ "created_at": "2017-11-20T14:57:22.000+00:00",
+ "parent_ids": null,
+ "title": "Make babies with the linter.",
+ "message": "Make babies with the linter.",
+ "author_name": "eal",
+ "author_email": "eal@waifu.club",
+ "authored_date": "2017-11-20T14:57:22.000+00:00",
+ "committer_name": "eal",
+ "committer_email": "eal@waifu.club",
+ "committed_date": "2017-11-20T14:57:22.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/c52173c64b67f3ed2dbd8574234110ceb5bdf4a9"
+ },
+ "merged": false,
+ "protected": false,
+ "developers_can_push": false,
+ "developers_can_merge": false,
+ "can_push": false,
+ "default": false
+ }
+] \ No newline at end of file
diff --git a/test/fixtures/tesla_mock/gitlab-api-pleroma-fe-releases.json b/test/fixtures/tesla_mock/gitlab-api-pleroma-fe-releases.json
new file mode 100644
index 000000000..db74565f9
--- /dev/null
+++ b/test/fixtures/tesla_mock/gitlab-api-pleroma-fe-releases.json
@@ -0,0 +1,188 @@
+[
+ {
+ "name": "0.9.999",
+ "tag_name": "0.9.999",
+ "description": "Changes:\r\n- Fix . activating when typing a message\r\n- Fix gaps when scrolling down on a timeline after showing new\r\n- Added floating action button for posting status on mobile\r\n- Changed user-settings icon to a pencil",
+ "description_html": "\u003cp data-sourcepos=\"1:1-1:8\" dir=\"auto\"\u003eChanges:\u003c/p\u003e\u0026#x000A;\u003cul data-sourcepos=\"2:1-5:40\" dir=\"auto\"\u003e\u0026#x000A;\u003cli data-sourcepos=\"2:1-2:40\"\u003eFix . activating when typing a message\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"3:1-3:62\"\u003eFix gaps when scrolling down on a timeline after showing new\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"4:1-4:59\"\u003eAdded floating action button for posting status on mobile\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"5:1-5:40\"\u003eChanged user-settings icon to a pencil\u003c/li\u003e\u0026#x000A;\u003c/ul\u003e",
+ "created_at": "2019-03-11T18:57:05.583Z",
+ "released_at": "2019-03-11T18:57:05.583Z",
+ "author": {
+ "id": 4,
+ "name": "Shpuld Shpludson",
+ "username": "shpuld",
+ "state": "active",
+ "avatar_url": "https://git.pleroma.social/uploads/-/system/user/avatar/4/avatar.png",
+ "web_url": "https://git.pleroma.social/shpuld"
+ },
+ "commit": {
+ "id": "7c26435e66fd7e142ea4b88fbe51eede32eeb5ce",
+ "short_id": "7c26435e",
+ "created_at": "2019-03-11T18:53:34.000+00:00",
+ "parent_ids": [
+ "7e9c8c3d219aa3b787c5606efbb54a73c1738b07",
+ "f397537642a6b8a4079d8d45d835ddd50f2d2b4a"
+ ],
+ "title": "Merge branch 'develop' into 'master'",
+ "message": "Merge branch 'develop' into 'master'\n\nUpdate master with bugfixes (and other changes)\n\nSee merge request pleroma/pleroma-fe!673",
+ "author_name": "Shpuld Shpludson",
+ "author_email": "shp@cock.li",
+ "authored_date": "2019-03-11T18:53:34.000+00:00",
+ "committer_name": "Shpuld Shpludson",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2019-03-11T18:53:34.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/7c26435e66fd7e142ea4b88fbe51eede32eeb5ce"
+ },
+ "upcoming_release": false,
+ "commit_path": "/pleroma/pleroma-fe/-/commit/7c26435e66fd7e142ea4b88fbe51eede32eeb5ce",
+ "tag_path": "/pleroma/pleroma-fe/-/tags/0.9.999",
+ "assets": {
+ "count": 4,
+ "sources": [
+ {
+ "format": "zip",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.999/pleroma-fe-0.9.999.zip"
+ },
+ {
+ "format": "tar.gz",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.999/pleroma-fe-0.9.999.tar.gz"
+ },
+ {
+ "format": "tar.bz2",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.999/pleroma-fe-0.9.999.tar.bz2"
+ },
+ {
+ "format": "tar",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.999/pleroma-fe-0.9.999.tar"
+ }
+ ],
+ "links": []
+ },
+ "_links": {
+ "self": "https://git.pleroma.social/pleroma/pleroma-fe/-/releases/0.9.999"
+ }
+ },
+ {
+ "name": "0.9.99",
+ "tag_name": "0.9.99",
+ "description": "Notable changes since the previous stable release:\r\n- Added a cropper when setting avatar\r\n- Show number of follow requests for locked accounts\r\n- Added blocks management in user settings\r\n- Added a hotkey for showing new posts, it's . and not currently configurable\r\n- Added error handling for missing profiles\r\n- Added OAuth token management in the user settings\r\n- Space out status component and make the layout jump around less\r\n- Added navigation for going between pics in a post in the media modal, use the on screen buttons or left/right arrow key\r\n- Make maximum amount of thumbnails shown configurable in settings\r\n- Update translations: Portuguese, Esperanto, Occitan, Czech\r\n- Lots of minor fixes and improvements, thanks to all contributors!",
+ "description_html": "\u003cp data-sourcepos=\"1:1-1:50\" dir=\"auto\"\u003eNotable changes since the previous stable release:\u003c/p\u003e\u0026#x000A;\u003cul data-sourcepos=\"2:1-12:67\" dir=\"auto\"\u003e\u0026#x000A;\u003cli data-sourcepos=\"2:1-2:37\"\u003eAdded a cropper when setting avatar\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"3:1-3:52\"\u003eShow number of follow requests for locked accounts\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"4:1-4:42\"\u003eAdded blocks management in user settings\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"5:1-5:77\"\u003eAdded a hotkey for showing new posts, it's . and not currently configurable\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"6:1-6:43\"\u003eAdded error handling for missing profiles\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"7:1-7:51\"\u003eAdded OAuth token management in the user settings\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"8:1-8:65\"\u003eSpace out status component and make the layout jump around less\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"9:1-9:121\"\u003eAdded navigation for going between pics in a post in the media modal, use the on screen buttons or left/right arrow key\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"10:1-10:66\"\u003eMake maximum amount of thumbnails shown configurable in settings\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"11:1-11:60\"\u003eUpdate translations: Portuguese, Esperanto, Occitan, Czech\u003c/li\u003e\u0026#x000A;\u003cli data-sourcepos=\"12:1-12:67\"\u003eLots of minor fixes and improvements, thanks to all contributors!\u003c/li\u003e\u0026#x000A;\u003c/ul\u003e",
+ "created_at": "2019-03-07T15:55:05.139Z",
+ "released_at": "2019-03-07T15:55:05.139Z",
+ "author": {
+ "id": 4,
+ "name": "Shpuld Shpludson",
+ "username": "shpuld",
+ "state": "active",
+ "avatar_url": "https://git.pleroma.social/uploads/-/system/user/avatar/4/avatar.png",
+ "web_url": "https://git.pleroma.social/shpuld"
+ },
+ "commit": {
+ "id": "7e9c8c3d219aa3b787c5606efbb54a73c1738b07",
+ "short_id": "7e9c8c3d",
+ "created_at": "2019-03-07T15:11:11.000+00:00",
+ "parent_ids": [
+ "4800169f36e0a71c322b9707a797c3b1ad48bf58",
+ "c44f0a9bde08c50598207494b121ae4bdf1f0fb1"
+ ],
+ "title": "Merge branch 'develop' into 'master'",
+ "message": "Merge branch 'develop' into 'master'\n\nUpdate master\n\nSee merge request pleroma/pleroma-fe!646",
+ "author_name": "Shpuld Shpludson",
+ "author_email": "shp@cock.li",
+ "authored_date": "2019-03-07T15:11:11.000+00:00",
+ "committer_name": "Shpuld Shpludson",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2019-03-07T15:11:11.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/7e9c8c3d219aa3b787c5606efbb54a73c1738b07"
+ },
+ "upcoming_release": false,
+ "commit_path": "/pleroma/pleroma-fe/-/commit/7e9c8c3d219aa3b787c5606efbb54a73c1738b07",
+ "tag_path": "/pleroma/pleroma-fe/-/tags/0.9.99",
+ "assets": {
+ "count": 4,
+ "sources": [
+ {
+ "format": "zip",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.99/pleroma-fe-0.9.99.zip"
+ },
+ {
+ "format": "tar.gz",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.99/pleroma-fe-0.9.99.tar.gz"
+ },
+ {
+ "format": "tar.bz2",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.99/pleroma-fe-0.9.99.tar.bz2"
+ },
+ {
+ "format": "tar",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.99/pleroma-fe-0.9.99.tar"
+ }
+ ],
+ "links": []
+ },
+ "_links": {
+ "self": "https://git.pleroma.social/pleroma/pleroma-fe/-/releases/0.9.99"
+ }
+ },
+ {
+ "name": "0.9.9",
+ "tag_name": "0.9.9",
+ "description": "The version bundled with 0.9.9 of BE. First \"stable\" release.\r\n\r\nNot exactly same as content-type fix was cherry picked in after release.",
+ "description_html": "\u003cp data-sourcepos=\"1:1-1:61\" dir=\"auto\"\u003eThe version bundled with 0.9.9 of BE. First \"stable\" release.\u003c/p\u003e\u0026#x000A;\u003cp data-sourcepos=\"3:1-3:72\" dir=\"auto\"\u003eNot exactly same as content-type fix was cherry picked in after release.\u003c/p\u003e",
+ "created_at": "2019-03-07T15:04:53.563Z",
+ "released_at": "2019-03-07T15:04:53.563Z",
+ "author": {
+ "id": 4,
+ "name": "Shpuld Shpludson",
+ "username": "shpuld",
+ "state": "active",
+ "avatar_url": "https://git.pleroma.social/uploads/-/system/user/avatar/4/avatar.png",
+ "web_url": "https://git.pleroma.social/shpuld"
+ },
+ "commit": {
+ "id": "4800169f36e0a71c322b9707a797c3b1ad48bf58",
+ "short_id": "4800169f",
+ "created_at": "2019-02-22T16:34:29.000+00:00",
+ "parent_ids": [
+ "533597fe259344c763ea06f8be71f34491c4d4e9",
+ "2d453e635572dd640d4f5e1ecd7837b5874bd250"
+ ],
+ "title": "Merge branch 'cherry-pick-254b0afa' into 'master'",
+ "message": "Merge branch 'cherry-pick-254b0afa' into 'master'\n\nMerge default content-type fix into master\n\nSee merge request pleroma/pleroma-fe!609",
+ "author_name": "Shpuld Shpludson",
+ "author_email": "shp@cock.li",
+ "authored_date": "2019-02-22T16:34:29.000+00:00",
+ "committer_name": "Shpuld Shpludson",
+ "committer_email": "shp@cock.li",
+ "committed_date": "2019-02-22T16:34:29.000+00:00",
+ "web_url": "https://git.pleroma.social/pleroma/pleroma-fe/-/commit/4800169f36e0a71c322b9707a797c3b1ad48bf58"
+ },
+ "upcoming_release": false,
+ "commit_path": "/pleroma/pleroma-fe/-/commit/4800169f36e0a71c322b9707a797c3b1ad48bf58",
+ "tag_path": "/pleroma/pleroma-fe/-/tags/0.9.9",
+ "assets": {
+ "count": 4,
+ "sources": [
+ {
+ "format": "zip",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.9/pleroma-fe-0.9.9.zip"
+ },
+ {
+ "format": "tar.gz",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.9/pleroma-fe-0.9.9.tar.gz"
+ },
+ {
+ "format": "tar.bz2",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.9/pleroma-fe-0.9.9.tar.bz2"
+ },
+ {
+ "format": "tar",
+ "url": "https://git.pleroma.social/pleroma/pleroma-fe/-/archive/0.9.9/pleroma-fe-0.9.9.tar"
+ }
+ ],
+ "links": []
+ },
+ "_links": {
+ "self": "https://git.pleroma.social/pleroma/pleroma-fe/-/releases/0.9.9"
+ }
+ }
+] \ No newline at end of file
diff --git a/test/frontend_test.exs b/test/frontend_test.exs
new file mode 100644
index 000000000..54e4524a1
--- /dev/null
+++ b/test/frontend_test.exs
@@ -0,0 +1,34 @@
+defmodule Pleroma.FrontendTest do
+ use Pleroma.DataCase
+
+ describe "get_primary_fe_opts" do
+ setup do: clear_config([:frontends])
+
+ test "normal" do
+ conf = %{primary: %{"name" => "testfe", "ref" => "test"}, static: false}
+ Pleroma.Config.put([:frontends], conf)
+
+ expected = %{
+ config: conf[:primary],
+ controller: Pleroma.Web.Frontend.TestfeController,
+ static: conf[:static]
+ }
+
+ assert Pleroma.Frontend.get_primary_fe_opts() == expected
+ assert Pleroma.Frontend.get_primary_fe_opts(conf) == expected
+ end
+
+ test "headless" do
+ conf = %{primary: %{"name" => "none"}, static: false}
+ Pleroma.Config.put([:frontends], conf)
+
+ expected = %{
+ config: %{},
+ controller: Pleroma.Web.Frontend.HeadlessController,
+ static: conf[:static]
+ }
+
+ assert Pleroma.Frontend.get_primary_fe_opts() == expected
+ end
+ end
+end
diff --git a/test/instance_static/frontends/admin/develop/index.html b/test/instance_static/frontends/admin/develop/index.html
new file mode 100644
index 000000000..3adac7c80
--- /dev/null
+++ b/test/instance_static/frontends/admin/develop/index.html
@@ -0,0 +1 @@
+<h1>test Admin Develop FE</h1> \ No newline at end of file
diff --git a/test/instance_static/frontends/kenoma/develop/index.html b/test/instance_static/frontends/kenoma/develop/index.html
new file mode 100644
index 000000000..613527cbb
--- /dev/null
+++ b/test/instance_static/frontends/kenoma/develop/index.html
@@ -0,0 +1,2 @@
+<h1>test Kenoma Develop FE</h1>
+<!--server-generated-meta--> \ No newline at end of file
diff --git a/test/instance_static/frontends/mastodon/develop/index.html b/test/instance_static/frontends/mastodon/develop/index.html
new file mode 100644
index 000000000..98ae363bc
--- /dev/null
+++ b/test/instance_static/frontends/mastodon/develop/index.html
@@ -0,0 +1 @@
+<h1>test Mastodon Develop FE</h1> \ No newline at end of file
diff --git a/test/instance_static/frontends/pleroma/develop/index.html b/test/instance_static/frontends/pleroma/develop/index.html
new file mode 100644
index 000000000..6c87531a8
--- /dev/null
+++ b/test/instance_static/frontends/pleroma/develop/index.html
@@ -0,0 +1,2 @@
+<h1>test Pleroma Develop FE</h1>
+<!--server-generated-meta--> \ No newline at end of file
diff --git a/test/plugs/frontend_plug_test.exs b/test/plugs/frontend_plug_test.exs
new file mode 100644
index 000000000..5f66a5d0c
--- /dev/null
+++ b/test/plugs/frontend_plug_test.exs
@@ -0,0 +1,31 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Plugs.FrontendPlugTest do
+ use Pleroma.Web.ConnCase
+
+ setup do: clear_config([:frontends])
+
+ describe "setting private.frontend" do
+ setup do
+ conf = Pleroma.Config.get([:frontends])
+ {:ok, %{conf: conf}}
+ end
+
+ test "for admin", %{conn: conn, conf: conf} do
+ conn = get(conn, frontend_admin_path(conn, :index, []))
+ assert get_in(conn.private, [:frontend, :config, "name"]) == conf[:admin]["name"]
+ end
+
+ test "for mastodon", %{conn: conn, conf: conf} do
+ conn = get(conn, frontend_mastodon_path(conn, :index, []))
+ assert get_in(conn.private, [:frontend, :config, "name"]) == conf[:mastodon]["name"]
+ end
+
+ test "for primary", %{conn: conn, conf: conf} do
+ conn = get(conn, frontend_path(conn, :index, []))
+ assert get_in(conn.private, [:frontend, :config, "name"]) == conf[:primary]["name"]
+ end
+ end
+end
diff --git a/test/plugs/instance_static_test.exs b/test/plugs/instance_static_test.exs
index b8f070d6a..1f70f4645 100644
--- a/test/plugs/instance_static_test.exs
+++ b/test/plugs/instance_static_test.exs
@@ -6,38 +6,64 @@ defmodule Pleroma.Web.RuntimeStaticPlugTest do
use Pleroma.Web.ConnCase
@dir "test/tmp/instance_static"
+ @primary_fe %{"name" => "pleroma", "ref" => "1.2.3"}
+ @fe_dir Path.join([@dir, "frontends", @primary_fe["name"], @primary_fe["ref"]])
setup do
- File.mkdir_p!(@dir)
+ [@dir, "frontends", @primary_fe["name"], @primary_fe["ref"], "static"]
+ |> Path.join()
+ |> File.mkdir_p()
+
+ [@dir, "static"]
+ |> Path.join()
+ |> File.mkdir!()
+
on_exit(fn -> File.rm_rf(@dir) end)
+ clear_config([:instance, :static_dir], @dir)
+ clear_config([:frontends, :primary], @primary_fe)
end
- setup do: clear_config([:instance, :static_dir], @dir)
+ test "frontend files override files in priv" do
+ content = "body{ color: red; }"
- test "overrides index" do
- bundled_index = get(build_conn(), "/")
- assert html_response(bundled_index, 200) == File.read!("priv/static/index.html")
+ conn = get(build_conn(), "/static-fe.css")
+ refute response(conn, 200) == content
- File.write!(@dir <> "/index.html", "hello world")
+ [@fe_dir, "static-fe.css"]
+ |> Path.join()
+ |> File.write!(content)
- index = get(build_conn(), "/")
- assert html_response(index, 200) == "hello world"
+ conn = get(build_conn(), "/static-fe.css")
+ assert response(conn, 200) == content
end
- test "overrides any file in static/static" do
- bundled_index = get(build_conn(), "/static/terms-of-service.html")
+ test "files in instance/static overrides priv/static" do
+ content = "no room for Bender"
+
+ conn = get(build_conn(), "/robots.txt")
+ refute text_response(conn, 200) == content
+
+ [@dir, "robots.txt"]
+ |> Path.join()
+ |> File.write!(content)
+
+ conn = get(build_conn(), "/robots.txt")
+ assert text_response(conn, 200) == content
+ end
- assert html_response(bundled_index, 200) ==
- File.read!("priv/static/static/terms-of-service.html")
+ test "files in instance/static overrides frontend files" do
+ [@fe_dir, "static", "helo.html"]
+ |> Path.join()
+ |> File.write!("cofe")
- File.mkdir!(@dir <> "/static")
- File.write!(@dir <> "/static/terms-of-service.html", "plz be kind")
+ conn = get(build_conn(), "/static/helo.html")
+ assert html_response(conn, 200) == "cofe"
- index = get(build_conn(), "/static/terms-of-service.html")
- assert html_response(index, 200) == "plz be kind"
+ [@dir, "static", "helo.html"]
+ |> Path.join()
+ |> File.write!("moto")
- File.write!(@dir <> "/static/kaniini.html", "<h1>rabbit hugs as a service</h1>")
- index = get(build_conn(), "/static/kaniini.html")
- assert html_response(index, 200) == "<h1>rabbit hugs as a service</h1>"
+ conn = get(build_conn(), "/static/helo.html")
+ assert html_response(conn, 200) == "moto"
end
end
diff --git a/test/tasks/frontend_test.exs b/test/tasks/frontend_test.exs
new file mode 100644
index 000000000..410b3d2e7
--- /dev/null
+++ b/test/tasks/frontend_test.exs
@@ -0,0 +1,69 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Mix.Tasks.Pleroma.FrontendTest do
+ use ExUnit.Case
+ use Pleroma.Tests.Helpers
+
+ import Tesla.Mock, only: [mock_global: 1, json: 1]
+
+ @bundle_zip_path Path.absname("test/fixtures/tesla_mock/fe-bundle.zip")
+
+ @dir "test/tmp/instance_static"
+
+ setup_all do
+ Mix.shell(Mix.Shell.Process)
+
+ on_exit(fn ->
+ Mix.shell(Mix.Shell.IO)
+ end)
+
+ :ok
+ end
+
+ setup do
+ mock_global(fn
+ %{method: :get, url: "https://git.pleroma.social/api/v4/projects/" <> rest} ->
+ case String.ends_with?(rest, "repository/branches") do
+ true ->
+ "test/fixtures/tesla_mock/gitlab-api-pleroma-fe-branches.json"
+
+ false ->
+ "test/fixtures/tesla_mock/gitlab-api-pleroma-fe-releases.json"
+ end
+ |> Path.absname()
+ |> File.read!()
+ |> Jason.decode!()
+ |> json()
+
+ %{method: :get, url: _download_url} ->
+ %Tesla.Env{status: 200, body: File.read!(@bundle_zip_path)}
+ end)
+
+ File.mkdir_p!(@dir)
+ on_exit(fn -> File.rm_rf(@dir) end)
+
+ clear_config([:instance, :static_dir], @dir)
+
+ :ok
+ end
+
+ test "installations" do
+ frontends = ~w(pleroma kenoma mastodon admin)
+ refs = ~w(develop stable 1.2.3)
+
+ Enum.each(frontends, fn frontend ->
+ Enum.each(refs, fn ref ->
+ Mix.Tasks.Pleroma.Frontend.run([
+ "install",
+ frontend,
+ "--ref",
+ ref
+ ])
+
+ assert File.exists?(Path.join([@dir, "frontends/#{frontend}/#{ref}/index.html"]))
+ end)
+ end)
+ end
+end
diff --git a/test/tasks/instance_test.exs b/test/tasks/instance_test.exs
index f6a4ba508..e46992ac1 100644
--- a/test/tasks/instance_test.exs
+++ b/test/tasks/instance_test.exs
@@ -2,7 +2,7 @@
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.InstanceTest do
+defmodule Mix.Tasks.Pleroma.InstanceTest do
use ExUnit.Case
setup do
@@ -63,7 +63,21 @@ defmodule Pleroma.InstanceTest do
"--uploads-dir",
"test/uploads",
"--static-dir",
- "instance/static/"
+ "instance/static/",
+ "--fe-primary",
+ "pleroma",
+ "--fe-primary-ref",
+ "develop",
+ "--fe-mastodon",
+ "y",
+ "--fe-mastodon-ref",
+ "develop",
+ "--fe-admin",
+ "y",
+ "--fe-admin-ref",
+ "develop",
+ "--fe-static",
+ "y"
])
end
@@ -82,6 +96,10 @@ defmodule Pleroma.InstanceTest do
assert generated_config =~ "password: \"dbpass\""
assert generated_config =~ "configurable_from_database: true"
assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]"
+ assert generated_config =~ ~s(primary: %{"name" => "pleroma", "ref" => "develop"})
+ assert generated_config =~ ~s(mastodon: %{"name" => "mastodon", "ref" => "develop"})
+ assert generated_config =~ ~s(admin: %{"name" => "admin", "ref" => "develop"})
+ assert generated_config =~ "static: true"
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
end
diff --git a/test/web/controller/frontend/admin_controller_test.exs b/test/web/controller/frontend/admin_controller_test.exs
new file mode 100644
index 000000000..8375cefdc
--- /dev/null
+++ b/test/web/controller/frontend/admin_controller_test.exs
@@ -0,0 +1,12 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Frontend.AdminControllerTest do
+ use Pleroma.Web.ConnCase
+
+ test "renders index.html from admin fe", %{conn: conn} do
+ conn = get(conn, frontend_admin_path(conn, :index, []))
+ assert html_response(conn, 200) =~ "test Admin Develop FE"
+ end
+end
diff --git a/test/web/controller/frontend/headless_controller_test.exs b/test/web/controller/frontend/headless_controller_test.exs
new file mode 100644
index 000000000..96061c15a
--- /dev/null
+++ b/test/web/controller/frontend/headless_controller_test.exs
@@ -0,0 +1,16 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Frontend.HeadlessControllerTest do
+ use Pleroma.Web.ConnCase
+
+ setup do: clear_config([:frontends, :primary])
+
+ test "Returns 404", %{conn: conn} do
+ Pleroma.Config.put([:frontends, :primary], %{"name" => "none", "ref" => ""})
+
+ conn = get(conn, frontend_path(conn, :index, []))
+ assert text_response(conn, 404) == ""
+ end
+end
diff --git a/test/web/controller/frontend/kenoma_controller_test.exs b/test/web/controller/frontend/kenoma_controller_test.exs
new file mode 100644
index 000000000..90271c384
--- /dev/null
+++ b/test/web/controller/frontend/kenoma_controller_test.exs
@@ -0,0 +1,16 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Frontend.KenomaControllerTest do
+ use Pleroma.Web.ConnCase
+
+ setup do: clear_config([:frontends, :primary])
+
+ test "renders index.html from kenoma fe", %{conn: conn} do
+ Pleroma.Config.put([:frontends, :primary], %{"name" => "kenoma", "ref" => "develop"})
+
+ conn = get(conn, frontend_path(conn, :index, []))
+ assert html_response(conn, 200) =~ "test Kenoma Develop FE"
+ end
+end
diff --git a/test/web/controller/frontend/mastodon_controller_test.exs b/test/web/controller/frontend/mastodon_controller_test.exs
new file mode 100644
index 000000000..8dbc18354
--- /dev/null
+++ b/test/web/controller/frontend/mastodon_controller_test.exs
@@ -0,0 +1,85 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Frontend.MastodonControllerTest do
+ use Pleroma.Web.ConnCase
+
+ alias Pleroma.Config
+ alias Pleroma.User
+
+ import Pleroma.Factory
+
+ setup do: clear_config([:instance, :public])
+
+ test "put settings", %{conn: conn} do
+ user = insert(:user)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> assign(:token, insert(:oauth_token, user: user, scopes: ["write:accounts"]))
+ |> put(frontend_mastodon_path(conn, :put_settings), %{"data" => %{"programming" => "socks"}})
+
+ assert _result = json_response(conn, 200)
+
+ user = User.get_cached_by_ap_id(user.ap_id)
+ assert user.settings == %{"programming" => "socks"}
+ end
+
+ describe "index/2 redirections" do
+ setup %{conn: conn} do
+ session_opts = [
+ store: :cookie,
+ key: "_test",
+ signing_salt: "cooldude"
+ ]
+
+ conn =
+ conn
+ |> Plug.Session.call(Plug.Session.init(session_opts))
+ |> fetch_session()
+
+ test_path = frontend_mastodon_path(conn, :index, ["statuses", "test"])
+ %{conn: conn, path: test_path}
+ end
+
+ test "redirects not logged-in users to the login page", %{conn: conn, path: path} do
+ conn = get(conn, path)
+
+ assert conn.status == 302
+ assert redirected_to(conn) == auth_path(conn, :login)
+ end
+
+ test "redirects not logged-in users to the login page on private instances", %{
+ conn: conn,
+ path: path
+ } do
+ Config.put([:instance, :public], false)
+
+ conn = get(conn, path)
+
+ assert conn.status == 302
+ assert redirected_to(conn) == auth_path(conn, :login)
+ end
+
+ test "does not redirect logged in users to the login page", %{conn: conn, path: path} do
+ token = insert(:oauth_token, scopes: ["read"])
+
+ conn =
+ conn
+ |> assign(:user, token.user)
+ |> assign(:token, token)
+ |> get(path)
+
+ assert conn.status == 200
+ end
+
+ test "saves referer path to session", %{conn: conn, path: path} do
+ conn = get(conn, path)
+ return_to = Plug.Conn.get_session(conn, :return_to)
+
+ assert return_to == path
+ end
+ end
+end
diff --git a/test/web/controller/frontend/pleroma_controller_test.exs b/test/web/controller/frontend/pleroma_controller_test.exs
new file mode 100644
index 000000000..030ecf97f
--- /dev/null
+++ b/test/web/controller/frontend/pleroma_controller_test.exs
@@ -0,0 +1,24 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Frontend.PleromaControllerTest do
+ use Pleroma.Web.ConnCase
+
+ import Pleroma.Factory
+
+ test "renders index.html from pleroma fe", %{conn: conn} do
+ conn = get(conn, frontend_path(conn, :index, []))
+ assert html_response(conn, 200) =~ "test Pleroma Develop FE"
+ end
+
+ test "index_with_meta", %{conn: conn} do
+ user = insert(:user)
+
+ conn = get(conn, frontend_path(conn, :index_with_meta, "nonexistinguser"))
+ assert html_response(conn, 200) =~ "<!--server-generated-meta-->"
+
+ conn = get(conn, frontend_path(conn, :index_with_meta, user.nickname))
+ refute html_response(conn, 200) =~ "<!--server-generated-meta-->"
+ end
+end
diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/controller/frontend/static_controller_test.exs
index 430683ea0..8a04880bf 100644
--- a/test/web/static_fe/static_fe_controller_test.exs
+++ b/test/web/controller/frontend/static_controller_test.exs
@@ -1,4 +1,4 @@
-defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
+defmodule Pleroma.Web.Frontend.StaticControllerTest do
use Pleroma.Web.ConnCase
alias Pleroma.Activity
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
import Pleroma.Factory
- setup_all do: clear_config([:static_fe, :enabled], true)
+ setup_all do: clear_config([:frontends, :static], true)
setup do: clear_config([:instance, :federating], true)
setup %{conn: conn} do
@@ -20,13 +20,13 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
describe "user profile html" do
test "just the profile as HTML", %{conn: conn, user: user} do
- conn = get(conn, "/users/#{user.nickname}")
+ conn = get(conn, user_feed_path(conn, :feed_redirect, user.nickname))
assert html_response(conn, 200) =~ user.nickname
end
test "404 when user not found", %{conn: conn} do
- conn = get(conn, "/users/limpopo")
+ conn = get(conn, user_feed_path(conn, :feed_redirect, "nonexistinguser"))
assert html_response(conn, 404) =~ "not found"
end
@@ -35,7 +35,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
CommonAPI.post(user, %{"status" => "public"})
CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
- conn = get(conn, "/users/#{user.nickname}")
+ conn = get(conn, user_feed_path(conn, :feed_redirect, user.nickname))
html = html_response(conn, 200)
@@ -44,9 +44,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
end
test "pagination", %{conn: conn, user: user} do
- Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
-
- conn = get(conn, "/users/#{user.nickname}")
+ Enum.each(1..30, &CommonAPI.post(user, %{"status" => "test#{&1}"}))
+ conn = get(conn, user_feed_path(conn, :feed_redirect, user.nickname))
html = html_response(conn, 200)
@@ -60,7 +59,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
activities = Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
{:ok, a11} = Enum.at(activities, 11)
- conn = get(conn, "/users/#{user.nickname}?max_id=#{a11.id}")
+ conn = get(conn, user_feed_path(conn, :feed_redirect, user.nickname, max_id: a11.id))
html = html_response(conn, 200)
@@ -71,7 +70,11 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
end
test "it requires authentication if instance is NOT federating", %{conn: conn, user: user} do
- ensure_federating_or_authenticated(conn, "/users/#{user.nickname}", user)
+ ensure_federating_or_authenticated(
+ conn,
+ user_feed_path(conn, :feed_redirect, user.nickname),
+ user
+ )
end
end
@@ -79,7 +82,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
test "single notice page", %{conn: conn, user: user} do
{:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
- conn = get(conn, "/notice/#{activity.id}")
+ conn = get(conn, o_status_path(conn, :notice, activity.id))
html = html_response(conn, 200)
assert html =~ "<header>"
@@ -94,7 +97,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
conn =
conn
|> put_req_header("accept", "text/html")
- |> get("/notice/#{activity.id}")
+ |> get(o_status_path(conn, :notice, activity.id))
html = html_response(conn, 200)
assert html =~ ~s[&lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;]
@@ -108,7 +111,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
"in_reply_to_status_id" => activity.id
})
- conn = get(conn, "/notice/#{activity.id}")
+ conn = get(conn, o_status_path(conn, :notice, activity.id))
html = html_response(conn, 200)
assert html =~ "the final frontier"
@@ -134,7 +137,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
end
test "404 when notice not found", %{conn: conn} do
- conn = get(conn, "/notice/88c9c317")
+ conn = get(conn, o_status_path(conn, :notice, "nonexistingnotice"))
assert html_response(conn, 404) =~ "not found"
end
@@ -143,7 +146,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
{:ok, activity} =
CommonAPI.post(user, %{"status" => "don't show me!", "visibility" => "private"})
- conn = get(conn, "/notice/#{activity.id}")
+ conn = get(conn, o_status_path(conn, :notice, activity.id))
assert html_response(conn, 404) =~ "not found"
end
@@ -165,7 +168,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
assert {:ok, activity} = Transmogrifier.handle_incoming(message)
- conn = get(conn, "/notice/#{activity.id}")
+ conn = get(conn, o_status_path(conn, :notice, activity.id))
assert html_response(conn, 302) =~ "redirected"
end
@@ -173,7 +176,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
test "it requires authentication if instance is NOT federating", %{conn: conn, user: user} do
{:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
- ensure_federating_or_authenticated(conn, "/notice/#{activity.id}", user)
+ ensure_federating_or_authenticated(conn, o_status_path(conn, :notice, activity.id), user)
end
end
end
diff --git a/test/web/fallback_test.exs b/test/web/fallback_test.exs
index 3919ef93a..6331f8087 100644
--- a/test/web/fallback_test.exs
+++ b/test/web/fallback_test.exs
@@ -30,10 +30,6 @@ defmodule Pleroma.Web.FallbackTest do
|> json_response(404) == %{"error" => "Not implemented"}
end
- test "GET /pleroma/admin -> /pleroma/admin/", %{conn: conn} do
- assert redirected_to(get(conn, "/pleroma/admin")) =~ "/pleroma/admin/"
- end
-
test "GET /*path", %{conn: conn} do
assert conn
|> get("/foo")
diff --git a/test/web/feed/user_controller_test.exs b/test/web/feed/user_controller_test.exs
index 05ad427c2..e66234f25 100644
--- a/test/web/feed/user_controller_test.exs
+++ b/test/web/feed/user_controller_test.exs
@@ -170,11 +170,13 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|> get("/users/#{user.nickname}")
|> response(200)
- assert response ==
- Fallback.RedirectController.redirector_with_meta(
- conn,
- %{user: user}
- ).resp_body
+ expected =
+ conn
+ |> Map.put(:params, %{user: user})
+ |> Pleroma.Web.FrontendController.call(:index_with_meta)
+ |> Map.get(:resp_body)
+
+ assert response == expected
end
test "with html format, it returns error when user is not found", %{conn: conn} do
diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs
index bb349cb19..ff535df75 100644
--- a/test/web/ostatus/ostatus_controller_test.exs
+++ b/test/web/ostatus/ostatus_controller_test.exs
@@ -94,7 +94,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
redirect_url =
conn
|> put_req_header("accept", "application/activity+json")
- |> get("/notice/#{note_activity.id}")
+ |> get(o_status_path(conn, :notice, note_activity.id))
|> redirected_to()
assert redirect_url == expected_redirect_url