Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into test/consolidate-co…
Browse files Browse the repository at this point in the history
…mment-tests
  • Loading branch information
noi5e committed Dec 16, 2020
2 parents ffb9cd5 + 6e0d55f commit 76422d1
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 88 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: continuous-integration
on: [push]
jobs:
test-runner:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379

steps:

- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically (not working?)

- uses: nanasess/setup-chromedriver@v1.0.1
- uses: actions/checkout@v2

# Trying to cache yarn deps but they're in public/assets/**/**, but application.js is also
# compiled there so we have to create an exception for that for any in-app js changes
# - name: Cache yarn
# uses: actions/cache@v2
# with:
# path: public/assets/**/**
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-

# shouldn't be required w/ setup-ruby bundler-cache, but that isn't working?
- name: Cache gems
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Install Ruby gems with Bundler
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3 --path vendor/bundle
bundle exec gem list
- name: Setup database
env:
RAILS_ENV: test
DB_PASSWORD: root
# tell Rails to use proper port for MySQL
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: |
cp config/database.yml.example config/database.yml
cp db/schema.rb.example db/schema.rb
sudo systemctl start mysql
mysql -uroot -proot -e "SET @@global.sql_mode=(SELECT REPLACE(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', ''));"
mysql -uroot -proot -e "CREATE DATABASE plots;"
bundle exec rake db:schema:load db:migrate --trace
# above SET @@global.sql_mode is to address https://github.com/publiclab/plots2/issues/3120
- name: Install JavaScript dependencies with Yarn
run: |
yarn check || yarn install;
- name: "Unit Tests"
env:
RAILS_ENV: test
DB_PASSWORD: root
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: bundle exec rails test test/unit

- name: "Functional Tests"
env:
RAILS_ENV: test
DB_PASSWORD: root
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: bundle exec rails test test/functional

- name: "Integration Tests"
env:
RAILS_ENV: test
DB_PASSWORD: root
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: bundle exec rails test test/integration

- name: "System Tests"
env:
RAILS_ENV: test
DB_PASSWORD: root
DB_PORT: ${{ job.services.mysql.ports[3306] }}
REDIS_HOST: localhost
REDIS_PORT: 6379
run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
bundle exec rails test:system
2 changes: 1 addition & 1 deletion app/views/tag/show/_nav_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<a class="nav-link <% if @node_type=="wiki" %> active <% end %>" href="/wiki/tag/<%= params[:id] %>">
<i class="fa fa-book"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"><%= t('tag.show.wiki_pages') %></span>
<span class="tags-tab-wiki d-none d-md-inline"><%= t('tag.show.wiki_pages') %></span>
<span class="d-none d-sm-inline badge badge-primary"><%= params[:counts][:wiki] %></span>
</span>
</a>
Expand Down
7 changes: 5 additions & 2 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
development:
adapter: redis
url: <%= "redis://localhost:6379/0" %>
url: "redis://localhost:6379/0"
channel_prefix: plots_development

test:
adapter: async
adapter: redis
url: "redis://localhost:6379/0"
channel_prefix: plots_test

production:
adapter: redis
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
test:
adapter: mysql2
username: root
password:
password: root
database: plots
encoding: utf8
host: 127.0.0.1
Expand Down
81 changes: 0 additions & 81 deletions test/editor_test.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/functional/tag_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def setup
get :suggested, params: { id: 'spectr' }

assert_equal 4, assigns(:suggestions).length
assert_equal ['question:spectrometer', 'spectrometer', 'activity:spectrometer', 'activities:spectrometer'], JSON.parse(response.body)
assert_equal ['question:spectrometer', 'spectrometer', 'activity:spectrometer', 'activities:spectrometer'].sort, JSON.parse(response.body).sort
end

test 'should choose I18n for tag controller' do
Expand Down
4 changes: 2 additions & 2 deletions test/integration/I18n_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class I18nTest < ActionDispatch::IntegrationTest
follow_redirect!

get '/wiki/' + nodes(:organizers).title.parameterize
assert_select 'a[rel=tooltip] i.fa.fa-comment'
assert_select '.fa-comment'
end
end

Expand Down Expand Up @@ -433,7 +433,7 @@ class I18nTest < ActionDispatch::IntegrationTest
follow_redirect!

get '/tag/some-tag'
assert_select 'a span.d-none', I18n.t('tag.show.wiki_pages')
assert_select '.tags-tab-wiki', I18n.t('tag.show.wiki_pages')
end
end

Expand Down
81 changes: 81 additions & 0 deletions test/system/editor_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
require "application_system_test_case"

class EditorTest < ApplicationSystemTestCase
include ActiveJob::TestHelper
Capybara.default_max_wait_time = 60

def setup
visit '/'
find(".nav-link.loginToggle").click()
fill_in("username-login", with: "palpatine")
fill_in("password-signup", with: "secretive")
find(".login-modal-form #login-button").click()
end

# test "check that rich wiki editor functions correctly" do
# visit "/wiki/wiki-page-path"
# find("a[data-original-title='Try the beta inline Rich Wiki editor.'").click()
# first("div.inline-section").hover()

# # click edit btn
# using_wait_time(2) { first("a.inline-edit-btn").click() }

# find("div.wk-wysiwyg").set("wiki text")

# click_on "Save"
# page.assert_selector("p", text: "wiki text")
# end

# test "check that markdown wiki editor functions correctly" do
# visit "/wiki/wiki-page-path"
# find("a[data-original-title='Edit this wiki page.'").click()

# find("#text-input").set("wiki text")
# find("a#publish").click()

# page.assert_selector("p", text: "wiki text")
# end

# test "check rich editor features are functional" do
# visit "/wiki/wiki-page-path"
# find("a[data-original-title='Try the beta inline Rich Wiki editor.'").click()
# first("div.inline-section").hover()

# using_wait_time(2) { first("a.inline-edit-btn").click() }

# # test the following features
# ["bold", "italic", "code", "heading"].each do |element|
# # clicking on the button generates the element with dummy text
# find("button.woofmark-command-#{element}").click()
# # these keys are called to deselect the previous elements
# find("div.wk-wysiwyg").native.send_key(:arrow_left, :enter)
# end

# click_on "Save"

# # assert that the features have worked and that the correct wiki elements are displayed
# page.assert_selector("strong", text: "strong text")
# page.assert_selector("h1", text: "Heading Text")
# page.assert_selector("em", text: "emphasized text")
# page.assert_selector("code", text: "code goes here")
# end

# test "check markdown editor features are functional" do
# visit "/wiki/wiki-page-path"
# find("a[data-original-title='Edit this wiki page.']").click()

# # test the following features
# ["**strong text**", "_emphasized text_", "`code goes here`", "# Heading Text"].each do |element|
# find("#text-input").native.send_keys(element)
# find("#text-input").native.send_keys(:enter)
# end

# find("a#publish").click()

# # assert that the features have worked and that the correct wiki elements are displayed
# page.assert_selector("strong", text: "strong text")
# page.assert_selector("h1", text: "Heading Text")
# page.assert_selector("em", text: "emphasized text")
# page.assert_selector("code", text: "code goes here")
# end
end
2 changes: 2 additions & 0 deletions test/unit/node_shared_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class NodeSharedTest < ActiveSupport::TestCase
before = "Here are some nodes in a table: \n\n[nodes:test] \n\nThis is how you make it work:\n\n`[nodes:tagname]`\n\n `[nodes:tagname]`\n\nMake sense?"
nodes(:one).add_tag('pinned:test', User.first)
nodes(:one).add_tag('test', User.first) # ensure it would appear anyways (although we aren't yet asserting order below, we should)
assert nodes(:one).has_tag('pinned:test')
assert nodes(:one).has_tag('test')
html = NodeShared.nodes_grid(before)
assert html
assert_equal 1, html.scan('<table class="table inline-grid nodes-grid nodes-grid-test nodes-grid-test-').length
Expand Down

0 comments on commit 76422d1

Please sign in to comment.