Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken invitation link #1729

Closed
wants to merge 2 commits into from

Conversation

roschaefer
Copy link
Collaborator

merge after #1728

Motivation

So this is a follow up for #1728.

It will prevent rendering the whatsapp link unless activated.

We still have an inconsistency, because the channel links depend on
Setting.channels whereas the routing depends on
Setting.whatsapp_configured?. Ie. Setting.channels can be activated
for whatsapp although Setting.whatsapp_configured? is false.

How to test

  1. bin/rspec spec/system/onboarding/index.spec.rb
  2. See:
Onboarding
  visit /onboarding/
    if WhatsApp was explicitly activated or activated by configuration
      renders invitation link for WhatsApp
    but if WhatsApp is deactivated
      renders no invitation link for WhatsApp

@roschaefer roschaefer requested a review from mattwr18 November 24, 2023 04:41
Motivation
----------
It took me a while to debug the 404 error when clicking on the link to:
```
http://localhost:3000/onboarding/whats-app?jwt=eyJhbGc
```

I was expecting to see a problem in `config/routes.rb` but couldn't find anything. It was surprising to me that we programmatically throw a 404 in one of the controllers.

How to test
-----------
1. `bin/rspec ./spec/adapters/signal_adapter/api_spec.rb`
2. Tests pass

Requested changes
-----------------
@mattwr18 asked me to implement this consistently across our codebase. I have seen this only once, here's the commit that introduced it: 9a541d6.
Thankfully there is already a test (that still fails if you remove conditional routing).

In the tests there was:
```
unless Setting.signal_server_phone_number
  allow(Setting).to receive(:signal_server_phone_number).and_return('SIGNAL_SERVER_PHONE_NUMBER')
  # ..
end
```
from 07694a6.

@mattwr18 this looks intentional, why was that? Did I miss anything?
merge after #1728

Motivation
----------
So this is a follow up for #1728.

It will prevent rendering the whatsapp link unless activated.

We still have an inconsistency, because the channel links depend on
`Setting.channels` whereas the routing depends on
`Setting.whatsapp_configured?`. Ie. `Setting.channels` can be activated
for whatsapp although `Setting.whatsapp_configured?` is false.

How to test
-----------
1. `bin/rspec spec/system/onboarding/index.spec.rb`
2. See:
```
Onboarding
  visit /onboarding/
    if WhatsApp was explicitly activated or activated by configuration
      renders invitation link for WhatsApp
    but if WhatsApp is deactivated
      renders no invitation link for WhatsApp
```
@roschaefer roschaefer force-pushed the fix-broken-link-if-whatsapp-not-configured branch from e8cc810 to c65a5c1 Compare December 13, 2023 15:49
roschaefer added a commit that referenced this pull request Dec 13, 2023
 Motivation
 ----------
 Also this took me way too long to fix. #1729 suffers under some unrelated failing spec. On my machine, even when I `git switch main` on the 07694a6 I will see sometimes a failing spec, sometimes it passes.

Here is an example:
```

  1) Configuring Onboarding Channels allows activating and deactivating onboarding channels
     Failure/Error: expect(page).to have_current_path(settings_path(as: admin))
       expected "/settings" to equal "/settings?as=177"

     [Screenshot Image]: tmp/screenshots/failures_r_spec_example_groups_configuring_onboarding_channels_allows_activating_and_deactivating_onboarding_channels_617.png

     # ./spec/system/settings/onboarding_channels_spec.rb:26:in `block (2 levels) in <main>'
     # ./spec/support/better_rails_system_tests.rb:26:in `block (2 levels) in <main>'
     # -e:1:in `<main>'
```

I don't think it is necessary to check the query params here, maybe it was even an oversight. What I still don't understand: What is `some_route_path(as: some_user)` even doing? And why did it work in the past?

 How to test
 -----------
 1. `git switch main`
 2. `bin/rspec spec/system/settings/onboarding_channels_spec.rb` multiple (!) times
 3. Sometims green, sometimes red

 This should not happen on this branch anymore.
@roschaefer roschaefer mentioned this pull request Dec 13, 2023
roschaefer added a commit that referenced this pull request Jan 9, 2024
 Motivation
 ----------
 Also this took me way too long to fix. #1729 suffers under some unrelated failing spec. On my machine, even when I `git switch main` on the 07694a6 I will see sometimes a failing spec, sometimes it passes.

Here is an example:
```

  1) Configuring Onboarding Channels allows activating and deactivating onboarding channels
     Failure/Error: expect(page).to have_current_path(settings_path(as: admin))
       expected "/settings" to equal "/settings?as=177"

     [Screenshot Image]: tmp/screenshots/failures_r_spec_example_groups_configuring_onboarding_channels_allows_activating_and_deactivating_onboarding_channels_617.png

     # ./spec/system/settings/onboarding_channels_spec.rb:26:in `block (2 levels) in <main>'
     # ./spec/support/better_rails_system_tests.rb:26:in `block (2 levels) in <main>'
     # -e:1:in `<main>'
```

I don't think it is necessary to check the query params here, maybe it was even an oversight. What I still don't understand: What is `some_route_path(as: some_user)` even doing? And why did it work in the past?

 How to test
 -----------
 1. `git switch main`
 2. `bin/rspec spec/system/settings/onboarding_channels_spec.rb` multiple (!) times
 3. Sometims green, sometimes red

 This should not happen on this branch anymore.
roschaefer added a commit that referenced this pull request Jan 9, 2024
 Motivation
 ----------
 Also this took me way too long to fix. #1729 suffers under some unrelated failing spec. On my machine, even when I `git switch main` on the 07694a6 I will see sometimes a failing spec, sometimes it passes.

Here is an example:
```

  1) Configuring Onboarding Channels allows activating and deactivating onboarding channels
     Failure/Error: expect(page).to have_current_path(settings_path(as: admin))
       expected "/settings" to equal "/settings?as=177"

     [Screenshot Image]: tmp/screenshots/failures_r_spec_example_groups_configuring_onboarding_channels_allows_activating_and_deactivating_onboarding_channels_617.png

     # ./spec/system/settings/onboarding_channels_spec.rb:26:in `block (2 levels) in <main>'
     # ./spec/support/better_rails_system_tests.rb:26:in `block (2 levels) in <main>'
     # -e:1:in `<main>'
```

I don't think it is necessary to check the query params here, maybe it was even an oversight. What I still don't understand: What is `some_route_path(as: some_user)` even doing? And why did it work in the past?

 How to test
 -----------
 1. `git switch main`
 2. `bin/rspec spec/system/settings/onboarding_channels_spec.rb` multiple (!) times
 3. Sometims green, sometimes red

 This should not happen on this branch anymore.
@mattwr18
Copy link
Contributor

mattwr18 commented May 6, 2024

Closing this PR as some of the changes were introduced in #1728 and the other changes will be introduced in #1818 along with expanding the changes to include all channels.

@mattwr18 mattwr18 closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants