Maintenance: Migrate Twitter browser test to RSpec
This commit migrates `test/integration/twitter_browser_test.rb` to RSpec as directly as possible.
This commit is contained in:
parent
65d1ba133d
commit
889dd92aea
5 changed files with 186 additions and 73 deletions
|
@ -593,22 +593,6 @@ test:browser:autowizard_ff:
|
|||
<<: *test_browser_integration_definition
|
||||
<<: *script_integration_auto_wizard_definition
|
||||
|
||||
test:browser:integration:twitter_chrome:
|
||||
<<: *browser_integration_auto_wizard_definition
|
||||
variables:
|
||||
<<: *variables_browser_definition
|
||||
BROWSER: "chrome"
|
||||
AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json"
|
||||
TEST_FILE: "test/integration/twitter_browser_test.rb"
|
||||
|
||||
test:browser:integration:twitter_ff:
|
||||
<<: *browser_integration_auto_wizard_definition
|
||||
variables:
|
||||
<<: *variables_browser_definition
|
||||
BROWSER: "firefox"
|
||||
AUTO_WIZARD_FILE: "contrib/auto_wizard_test.json"
|
||||
TEST_FILE: "test/integration/twitter_browser_test.rb"
|
||||
|
||||
test:browser:integration:facebook_chrome:
|
||||
<<: *browser_integration_auto_wizard_definition
|
||||
variables:
|
||||
|
|
34
spec/system/admin/channel/twitter_spec.rb
Normal file
34
spec/system/admin/channel/twitter_spec.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Panel > Channels > Twitter', :authenticated, :use_vcr, type: :system do
|
||||
context 'with incomplete credentials' do
|
||||
it 'displays a 401 error modal' do
|
||||
visit '/#channels/twitter'
|
||||
within(:active_content) do
|
||||
find('.js-configApp').click
|
||||
fill_in 'Twitter Consumer Key *', with: 'some_key', exact: true
|
||||
fill_in 'Twitter Consumer Secret *', with: 'some_secret', exact: true
|
||||
click_on 'Submit'
|
||||
|
||||
expect(page).to have_css('.modal .alert', text: '401 Authorization Required')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid credentials' do
|
||||
it 'displays a 401 error modal' do
|
||||
visit '/#channels/twitter'
|
||||
within(:active_content) do
|
||||
find('.js-configApp').click
|
||||
fill_in 'Twitter Consumer Key *', with: 'some_key', exact: true
|
||||
fill_in 'Twitter Consumer Secret *', with: 'some_secret', exact: true
|
||||
fill_in 'Twitter Access Token *', with: 'some_oauth_token', exact: true
|
||||
fill_in 'Twitter Access Token Secret *', with: 'some_oauth_token_secret', exact: true
|
||||
fill_in 'Twitter Dev environment label *', with: 'some_env', exact: true
|
||||
click_on 'Submit'
|
||||
|
||||
expect(page).to have_css('.modal .alert', text: '401 Authorization Required')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.twitter.com/oauth/request_token
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: ''
|
||||
headers:
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
User-Agent:
|
||||
- OAuth gem v0.5.4
|
||||
Content-Length:
|
||||
- '0'
|
||||
Authorization:
|
||||
- OAuth oauth_callback="http%3A%2F%2Fzammad.example.com%2Fapi%2Fv1%2Fexternal_credentials%2Ftwitter%2Fcallback",
|
||||
oauth_consumer_key="some_key", oauth_nonce="IagNJMosiC5LrtN0bNIcGkctrIWJejAhI1PA9DKFA8",
|
||||
oauth_signature="2f6IrVntUDtz9UOJ159p%2FF1NWWs%3D", oauth_signature_method="HMAC-SHA1",
|
||||
oauth_timestamp="1573544688", oauth_version="1.0"
|
||||
response:
|
||||
status:
|
||||
code: 401
|
||||
message: Authorization Required
|
||||
headers:
|
||||
Cache-Control:
|
||||
- no-cache, no-store, must-revalidate, pre-check=0, post-check=0
|
||||
Content-Disposition:
|
||||
- attachment; filename=json.json
|
||||
Content-Length:
|
||||
- '89'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Date:
|
||||
- Tue, 12 Nov 2019 07:44:49 GMT
|
||||
Expires:
|
||||
- Tue, 31 Mar 1981 05:00:00 GMT
|
||||
Last-Modified:
|
||||
- Tue, 12 Nov 2019 07:44:49 GMT
|
||||
Pragma:
|
||||
- no-cache
|
||||
Server:
|
||||
- tsa_m
|
||||
Set-Cookie:
|
||||
- guest_id=v1%3A157354468916670365; Max-Age=63072000; Expires=Thu, 11 Nov 2021
|
||||
07:44:49 GMT; Path=/; Domain=.twitter.com
|
||||
- personalization_id="v1_1vmi2r8RoFgMCL+SgD77bw=="; Max-Age=63072000; Expires=Thu,
|
||||
11 Nov 2021 07:44:49 GMT; Path=/; Domain=.twitter.com
|
||||
Status:
|
||||
- 401 Unauthorized
|
||||
Strict-Transport-Security:
|
||||
- max-age=631138519
|
||||
Www-Authenticate:
|
||||
- OAuth realm="https://api.twitter.com"
|
||||
X-Connection-Hash:
|
||||
- bf220064d30e7c53def04cd0401bedd9
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Response-Time:
|
||||
- '103'
|
||||
X-Transaction:
|
||||
- '0080644900ce1d14'
|
||||
X-Twitter-Response-Tags:
|
||||
- BouncerCompliant
|
||||
X-Xss-Protection:
|
||||
- '0'
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: '{"errors":[{"code":32,"message":"Could not authenticate you."}]}'
|
||||
http_version:
|
||||
recorded_at: Tue, 12 Nov 2019 07:44:49 GMT
|
||||
recorded_with: VCR 4.0.0
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.twitter.com/oauth/request_token
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: ''
|
||||
headers:
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
Accept:
|
||||
- "*/*"
|
||||
User-Agent:
|
||||
- OAuth gem v0.5.4
|
||||
Content-Length:
|
||||
- '0'
|
||||
Authorization:
|
||||
- OAuth oauth_callback="http%3A%2F%2Fzammad.example.com%2Fapi%2Fv1%2Fexternal_credentials%2Ftwitter%2Fcallback",
|
||||
oauth_consumer_key="some_key", oauth_nonce="eSDyub3KNoiB6ius4ncrgMX9sEoAW3jYRsNwJzZDdSw",
|
||||
oauth_signature="PK4O8hnKqm9I5H6bObYHI6RPZWA%3D", oauth_signature_method="HMAC-SHA1",
|
||||
oauth_timestamp="1573544692", oauth_version="1.0"
|
||||
response:
|
||||
status:
|
||||
code: 401
|
||||
message: Authorization Required
|
||||
headers:
|
||||
Cache-Control:
|
||||
- no-cache, no-store, must-revalidate, pre-check=0, post-check=0
|
||||
Content-Disposition:
|
||||
- attachment; filename=json.json
|
||||
Content-Length:
|
||||
- '89'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Date:
|
||||
- Tue, 12 Nov 2019 07:44:52 GMT
|
||||
Expires:
|
||||
- Tue, 31 Mar 1981 05:00:00 GMT
|
||||
Last-Modified:
|
||||
- Tue, 12 Nov 2019 07:44:52 GMT
|
||||
Pragma:
|
||||
- no-cache
|
||||
Server:
|
||||
- tsa_m
|
||||
Set-Cookie:
|
||||
- guest_id=v1%3A157354469261589333; Max-Age=63072000; Expires=Thu, 11 Nov 2021
|
||||
07:44:52 GMT; Path=/; Domain=.twitter.com
|
||||
- personalization_id="v1_6zZaPL3yO9TwlBYf9Pi/fg=="; Max-Age=63072000; Expires=Thu,
|
||||
11 Nov 2021 07:44:52 GMT; Path=/; Domain=.twitter.com
|
||||
Status:
|
||||
- 401 Unauthorized
|
||||
Strict-Transport-Security:
|
||||
- max-age=631138519
|
||||
Www-Authenticate:
|
||||
- OAuth realm="https://api.twitter.com"
|
||||
X-Connection-Hash:
|
||||
- 1ccb25aa6671b93b342083811c290299
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Response-Time:
|
||||
- '104'
|
||||
X-Transaction:
|
||||
- 002b22bf00a6ac1d
|
||||
X-Twitter-Response-Tags:
|
||||
- BouncerCompliant
|
||||
X-Xss-Protection:
|
||||
- '0'
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: '{"errors":[{"code":32,"message":"Could not authenticate you."}]}'
|
||||
http_version:
|
||||
recorded_at: Tue, 12 Nov 2019 07:44:52 GMT
|
||||
recorded_with: VCR 4.0.0
|
|
@ -1,57 +0,0 @@
|
|||
require 'browser_test_helper'
|
||||
|
||||
class TwitterBrowserTest < TestCase
|
||||
def test_add_config
|
||||
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'master@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
auto_wizard: true,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
click(css: 'a[href="#manage"]')
|
||||
click(css: '.content.active a[href="#channels/twitter"]')
|
||||
click(css: '.content.active .js-configApp')
|
||||
sleep 2
|
||||
set(
|
||||
css: '.content.active .modal [name=consumer_key]',
|
||||
value: 'some_key',
|
||||
)
|
||||
set(
|
||||
css: '.content.active .modal [name=consumer_secret]',
|
||||
value: 'some_secret',
|
||||
)
|
||||
click(css: '.content.active .modal .js-submit')
|
||||
|
||||
watch_for(
|
||||
css: '.content.active .modal .alert',
|
||||
value: '401 Authorization Required',
|
||||
)
|
||||
|
||||
set(
|
||||
css: '.content.active .modal [name=oauth_token]',
|
||||
value: 'some_oauth_token',
|
||||
)
|
||||
|
||||
set(
|
||||
css: '.content.active .modal [name=oauth_token_secret]',
|
||||
value: 'some_oauth_token_secret',
|
||||
)
|
||||
|
||||
set(
|
||||
css: '.content.active .modal [name=env]',
|
||||
value: 'some_env',
|
||||
)
|
||||
|
||||
click(css: '.content.active .modal .js-submit')
|
||||
|
||||
watch_for(
|
||||
css: '.content.active .modal .alert',
|
||||
value: '401 Authorization Required',
|
||||
)
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue