DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-07 09:26:58 +08:00
|
|
|
describe "Bookmarking posts and topics", type: :system do
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:topic)
|
2023-12-13 17:18:42 +08:00
|
|
|
fab!(:current_user) { Fabricate(:user, refresh_auto_groups: true) }
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
fab!(:post) { Fabricate(:post, topic: topic, raw: "This is some post to bookmark") }
|
2023-07-17 08:14:17 +08:00
|
|
|
fab!(:post_2) { Fabricate(:post, topic: topic, raw: "Some interesting post content") }
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
|
2023-07-17 08:14:17 +08:00
|
|
|
let(:timezone) { "Australia/Brisbane" }
|
2024-04-15 20:45:11 +08:00
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
2023-01-05 06:43:58 +08:00
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
let(:bookmark_modal) { PageObjects::Modals::Bookmark.new }
|
2024-04-05 07:25:30 +08:00
|
|
|
let(:bookmark_menu) { PageObjects::Components::BookmarkMenu.new }
|
2023-01-05 06:43:58 +08:00
|
|
|
|
2023-07-17 08:14:17 +08:00
|
|
|
before do
|
|
|
|
current_user.user_option.update!(timezone: timezone)
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
2023-01-05 06:43:58 +08:00
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
def visit_topic_and_open_bookmark_menu(post, expand_actions: true)
|
2023-01-05 06:43:58 +08:00
|
|
|
topic_page.visit_topic(topic)
|
2024-04-15 20:45:11 +08:00
|
|
|
open_bookmark_menu(post, expand_actions: expand_actions)
|
|
|
|
end
|
2024-04-05 07:25:30 +08:00
|
|
|
|
2024-04-15 20:45:11 +08:00
|
|
|
def open_bookmark_menu(post, expand_actions: true)
|
2024-04-05 07:25:30 +08:00
|
|
|
topic_page.expand_post_actions(post) if expand_actions
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
topic_page.click_post_action_button(post, :bookmark)
|
2023-01-05 06:43:58 +08:00
|
|
|
end
|
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
it "creates a bookmark on the post as soon as the bookmark button is clicked" do
|
|
|
|
visit_topic_and_open_bookmark_menu(post)
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
expect(bookmark_menu).to be_open
|
|
|
|
expect(page).to have_content(I18n.t("js.bookmarks.bookmarked_success"))
|
2024-04-09 14:14:59 +08:00
|
|
|
expect(topic_page).to have_post_bookmarked(post, with_reminder: false)
|
2024-10-03 12:34:36 +08:00
|
|
|
try_until_success(frequency: 0.5) do
|
|
|
|
expect(Bookmark.find_by(bookmarkable: post, user: current_user)).to be_truthy
|
|
|
|
end
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
end
|
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
it "updates the created bookmark with a selected reminder option from the bookmark menu" do
|
|
|
|
visit_topic_and_open_bookmark_menu(post)
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
expect(bookmark_menu).to be_open
|
|
|
|
expect(page).to have_content(I18n.t("js.bookmarks.bookmarked_success"))
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
bookmark_menu.click_menu_option("tomorrow")
|
2024-04-08 14:18:50 +08:00
|
|
|
|
2024-04-09 14:14:59 +08:00
|
|
|
expect(topic_page).to have_post_bookmarked(post, with_reminder: true)
|
2024-04-18 17:06:12 +08:00
|
|
|
expect(page).to have_no_css(".bookmark-menu-content.-expanded")
|
2024-10-03 12:34:36 +08:00
|
|
|
try_until_success(frequency: 0.5) do
|
|
|
|
expect(Bookmark.find_by(bookmarkable: post, user: current_user).reminder_at).not_to be_blank
|
|
|
|
end
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
end
|
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
it "can set a reminder from the bookmark modal using the custom bookmark menu option" do
|
|
|
|
visit_topic_and_open_bookmark_menu(post)
|
|
|
|
bookmark_menu.click_menu_option("custom")
|
|
|
|
bookmark_modal.select_preset_reminder(:tomorrow)
|
2024-04-09 14:14:59 +08:00
|
|
|
expect(topic_page).to have_post_bookmarked(post, with_reminder: true)
|
2024-10-03 12:34:36 +08:00
|
|
|
try_until_success(frequency: 0.5) do
|
|
|
|
expect(Bookmark.find_by(bookmarkable: post, user: current_user).reminder_at).not_to be_blank
|
|
|
|
end
|
2023-01-05 06:43:58 +08:00
|
|
|
end
|
|
|
|
|
2023-07-17 08:14:17 +08:00
|
|
|
it "allows choosing a different auto_delete_preference to the user preference and remembers it when reopening the modal" do
|
|
|
|
current_user.user_option.update!(
|
|
|
|
bookmark_auto_delete_preference: Bookmark.auto_delete_preferences[:on_owner_reply],
|
|
|
|
)
|
2024-04-05 07:25:30 +08:00
|
|
|
visit_topic_and_open_bookmark_menu(post_2)
|
|
|
|
bookmark_menu.click_menu_option("custom")
|
|
|
|
expect(bookmark_modal).to be_open
|
|
|
|
|
2024-07-01 13:32:30 +08:00
|
|
|
# NOTE: (martin) Not sure why, but I need to click this twice for the panel to open :/
|
2023-07-17 08:14:17 +08:00
|
|
|
bookmark_modal.open_options_panel
|
2024-04-05 07:25:30 +08:00
|
|
|
bookmark_modal.open_options_panel
|
|
|
|
|
2023-07-17 08:14:17 +08:00
|
|
|
expect(bookmark_modal).to have_auto_delete_preference(
|
|
|
|
Bookmark.auto_delete_preferences[:on_owner_reply],
|
|
|
|
)
|
|
|
|
bookmark_modal.select_auto_delete_preference(Bookmark.auto_delete_preferences[:clear_reminder])
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
bookmark_modal.save
|
2024-04-09 14:14:59 +08:00
|
|
|
expect(topic_page).to have_post_bookmarked(post_2, with_reminder: false)
|
2023-07-17 08:14:17 +08:00
|
|
|
topic_page.click_post_action_button(post_2, :bookmark)
|
2024-04-05 07:25:30 +08:00
|
|
|
bookmark_menu.click_menu_option("edit")
|
2023-07-17 08:14:17 +08:00
|
|
|
expect(bookmark_modal).to have_open_options_panel
|
|
|
|
expect(bookmark_modal).to have_auto_delete_preference(
|
|
|
|
Bookmark.auto_delete_preferences[:clear_reminder],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "topic level bookmarks" do
|
|
|
|
it "allows the topic to be bookmarked" do
|
|
|
|
topic_page.visit_topic(topic)
|
2024-04-18 17:06:12 +08:00
|
|
|
topic_page.click_topic_bookmark_button
|
|
|
|
expect(topic_page).to have_topic_bookmarked(topic)
|
2023-07-17 08:14:17 +08:00
|
|
|
expect(Bookmark.exists?(bookmarkable: topic, user: current_user)).to be_truthy
|
|
|
|
end
|
|
|
|
|
2024-04-18 17:06:12 +08:00
|
|
|
it "opens the edit bookmark modal from the topic bookmark button and saves edits" do
|
|
|
|
bookmark = Fabricate(:bookmark, bookmarkable: topic, user: current_user)
|
2023-07-17 08:14:17 +08:00
|
|
|
topic_page.visit_topic(topic)
|
2024-04-18 17:06:12 +08:00
|
|
|
topic_page.click_topic_bookmark_button
|
|
|
|
bookmark_menu.click_menu_option("edit")
|
2023-07-17 08:14:17 +08:00
|
|
|
expect(bookmark_modal).to be_open
|
|
|
|
expect(bookmark_modal).to be_editing_id(bookmark.id)
|
2024-04-18 17:06:12 +08:00
|
|
|
bookmark_modal.fill_name("something important")
|
|
|
|
bookmark_modal.click_primary_button
|
2023-07-17 08:14:17 +08:00
|
|
|
|
2024-04-18 17:06:12 +08:00
|
|
|
try_until_success(frequency: 0.5) do
|
|
|
|
expect(bookmark.reload.name).to eq("something important")
|
|
|
|
end
|
2023-07-17 08:14:17 +08:00
|
|
|
end
|
2024-04-26 16:59:51 +08:00
|
|
|
|
|
|
|
it "allows to set a relative time" do
|
|
|
|
bookmark = Fabricate(:bookmark, bookmarkable: topic, user: current_user)
|
|
|
|
topic_page.visit_topic(topic)
|
|
|
|
topic_page.click_topic_bookmark_button
|
|
|
|
bookmark_menu.click_menu_option("edit")
|
|
|
|
bookmark_modal.select_relative_time_duration(10)
|
|
|
|
bookmark_modal.select_relative_time_interval("days")
|
|
|
|
|
|
|
|
expect(bookmark_modal.custom_time_picker.value).to eq(
|
|
|
|
bookmark.reminder_at_in_zone(timezone).strftime("%H:%M"),
|
|
|
|
)
|
|
|
|
end
|
2023-07-17 08:14:17 +08:00
|
|
|
end
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
|
2023-07-17 08:14:17 +08:00
|
|
|
describe "editing existing bookmarks" do
|
|
|
|
fab!(:bookmark) do
|
|
|
|
Fabricate(
|
|
|
|
:bookmark,
|
|
|
|
bookmarkable: post_2,
|
|
|
|
user: current_user,
|
|
|
|
name: "test name",
|
|
|
|
reminder_at: 10.days.from_now,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "prefills the name of the bookmark and the custom reminder date and time" do
|
2024-04-05 07:25:30 +08:00
|
|
|
visit_topic_and_open_bookmark_menu(post_2, expand_actions: false)
|
|
|
|
bookmark_menu.click_menu_option("edit")
|
2023-07-17 08:14:17 +08:00
|
|
|
expect(bookmark_modal).to have_open_options_panel
|
|
|
|
expect(bookmark_modal.name.value).to eq("test name")
|
|
|
|
expect(bookmark_modal.existing_reminder_alert).to have_content(
|
|
|
|
bookmark_modal.existing_reminder_alert_message(bookmark),
|
|
|
|
)
|
|
|
|
expect(bookmark_modal.custom_date_picker.value).to eq(
|
|
|
|
bookmark.reminder_at_in_zone(timezone).strftime("%Y-%m-%d"),
|
|
|
|
)
|
|
|
|
expect(bookmark_modal.custom_time_picker.value).to eq(
|
|
|
|
bookmark.reminder_at_in_zone(timezone).strftime("%H:%M"),
|
|
|
|
)
|
|
|
|
expect(bookmark_modal).to have_active_preset("custom")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "can delete the bookmark" do
|
2024-04-05 07:25:30 +08:00
|
|
|
visit_topic_and_open_bookmark_menu(post_2, expand_actions: false)
|
|
|
|
bookmark_menu.click_menu_option("edit")
|
2023-07-17 08:14:17 +08:00
|
|
|
bookmark_modal.delete
|
|
|
|
bookmark_modal.confirm_delete
|
|
|
|
expect(topic_page).to have_no_post_bookmarked(post_2)
|
|
|
|
end
|
|
|
|
|
2024-04-05 07:25:30 +08:00
|
|
|
it "can delete the bookmark from within the menu" do
|
|
|
|
visit_topic_and_open_bookmark_menu(post_2, expand_actions: false)
|
|
|
|
bookmark_menu.click_menu_option("delete")
|
|
|
|
expect(topic_page).to have_no_post_bookmarked(post_2)
|
|
|
|
end
|
|
|
|
|
2023-07-17 08:14:17 +08:00
|
|
|
it "does not save edits when pressing cancel" do
|
2024-04-05 07:25:30 +08:00
|
|
|
visit_topic_and_open_bookmark_menu(post_2, expand_actions: false)
|
|
|
|
bookmark_menu.click_menu_option("edit")
|
2023-07-17 08:14:17 +08:00
|
|
|
bookmark_modal.fill_name("something important")
|
|
|
|
bookmark_modal.cancel
|
|
|
|
topic_page.click_post_action_button(post_2, :bookmark)
|
2024-04-05 07:25:30 +08:00
|
|
|
bookmark_menu.click_menu_option("edit")
|
|
|
|
expect(bookmark_modal.name.value).to eq("something important")
|
2023-07-17 08:14:17 +08:00
|
|
|
expect(bookmark.reload.name).to eq("test name")
|
|
|
|
end
|
DEV: Minimal first pass of rails system test setup (#16311)
This commit introduces rails system tests run with chromedriver, selenium,
and headless chrome to our testing toolbox.
We use the `webdrivers` gem and `selenium-webdriver` which is what
the latest Rails uses so the tests run locally and in CI out of the box.
You can use `SELENIUM_VERBOSE_DRIVER_LOGS=1` to show extra
verbose logs of what selenium is doing to communicate with the system
tests.
By default JS logs are verbose so errors from JS are shown when
running system tests, you can disable this with
`SELENIUM_DISABLE_VERBOSE_JS_LOGS=1`
You can use `SELENIUM_HEADLESS=0` to run the system
tests inside a chrome browser instead of headless, which can be useful to debug things
and see what the spec sees. See note above about `bin/ember-cli` to avoid
surprises.
I have modified `bin/turbo_rspec` to exclude `spec/system` by default,
support for parallel system specs is a little shaky right now and we don't
want them slowing down the turbo by default either.
### PageObjects and System Tests
To make querying and inspecting parts of the page easier
and more reusable inbetween system tests, we are using the
concept of [PageObjects](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) in
our system tests. A "Page" here is generally corresponds to
an overarching ember route, e.g. "Topic" for `/t/324345/some-topic`,
and this contains logic for querying components within the topic
such as "Posts".
I have also split "Modals" into their own entity. Further down the
line we may want to explore creating independent "Component"
contexts.
Capybara DSL should be included in each PageObject class,
reference for this can be found at https://rubydoc.info/github/teamcapybara/capybara/master#the-dsl
For system tests, since they are so slow, we want to focus on
the "happy path" and not do every different possible context
and branch check using them. They are meant to be overarching
tests that check a number of things are correct using the full stack
from JS and ember to rails to ruby and then the database.
### CI Setup
Whenever a system spec fails, a screenshot
is taken and a build artifact is produced _after the entire CI run is complete_,
which can be downloaded from the Actions UI in the repo.
Most importantly, a step to build the Ember app using Ember CLI
is needed, otherwise the JS assets cannot be found by capybara:
```
- name: Build Ember CLI
run: bin/ember-cli --build
```
A new `--build` argument has been added to `bin/ember-cli` for this
case, which is not needed locally if you already have the discourse
rails server running via `bin/ember-cli -u` since the whole server is built and
set up by default.
Co-authored-by: David Taylor <david@taylorhq.com>
2022-09-28 09:48:16 +08:00
|
|
|
end
|
|
|
|
end
|