From e5a01f7a573e6105ebb56e626a52323b910a8d28 Mon Sep 17 00:00:00 2001 From: zmagod Date: Fri, 27 Oct 2017 16:37:42 +0200 Subject: [PATCH] adds integration tests for about sciNote modal --- .../Navigation/components/InfoDropdown.jsx | 94 +++++++++++++------ app/javascript/src/config/locales/messages.js | 3 +- .../src/services/api/configurations_api.js | 6 ++ app/javascript/src/services/api/endpoints.js | 3 + config/routes.rb | 2 +- config/routes/confirmations.rb | 2 + .../navigation/addons_versions_modal.feature | 21 +++++ features/settings_page/profile.feature | 2 +- features/step_definitions/shared_steps.rb | 6 +- yarn.lock | 2 +- 10 files changed, 106 insertions(+), 35 deletions(-) create mode 100644 app/javascript/src/services/api/configurations_api.js create mode 100644 config/routes/confirmations.rb create mode 100644 features/navigation/addons_versions_modal.feature diff --git a/app/javascript/src/components/Navigation/components/InfoDropdown.jsx b/app/javascript/src/components/Navigation/components/InfoDropdown.jsx index df063f0c6..4e81ed3d0 100644 --- a/app/javascript/src/components/Navigation/components/InfoDropdown.jsx +++ b/app/javascript/src/components/Navigation/components/InfoDropdown.jsx @@ -1,4 +1,5 @@ -import React from "react"; +// @flow +import React, { Component } from "react"; import { FormattedMessage } from "react-intl"; import { NavDropdown, MenuItem } from "react-bootstrap"; import { @@ -8,35 +9,68 @@ import { PREMIUM_LINK, CONTACT_US_LINK } from "../../../config/routes"; +import { getSciNoteInfo } from "../../../services/api/configurations_api"; -const InfoDropdown = () => - -   - - - - - } - id="nav-info-dropdown" - > - - - - - - - - - - - - - - - - ; +type State = { + modalOpen: boolean, + scinoteVersion: string, + addons: Array +}; + +class InfoDropdown extends Component<*, State> { + constructor(props: any) { + super(props); + this.state = { modalOpen: false, scinoteVersion: "", addons: [] }; + (this: any).showAboutUsModal = this.showAboutUsModal.bind(this); + } + + showAboutUsModal(): void { + getSciNoteInfo().then(response => { + const { scinoteVersion, addons } = response; + (this: any).setState({ + scinoteVersion, + addons, + modalOpen: true + }); + }); + } + + render() { + return ( + +   + + + + + } + id="nav-info-dropdown" + > + + + + + + + + + + + + + + + + + + + + + ); + } +} export default InfoDropdown; diff --git a/app/javascript/src/config/locales/messages.js b/app/javascript/src/config/locales/messages.js index 4f6cd1389..c1258cdf4 100644 --- a/app/javascript/src/config/locales/messages.js +++ b/app/javascript/src/config/locales/messages.js @@ -204,7 +204,8 @@ export default { tutorials: "Tutorials", release_notes: "Release notes", premium: "Premium", - contact_us: "Contact us" + contact_us: "Contact us", + about_scinote: "About sciNote" }, user_account_dropdown: { greeting: "Hi, {name}", diff --git a/app/javascript/src/services/api/configurations_api.js b/app/javascript/src/services/api/configurations_api.js new file mode 100644 index 000000000..0797ea244 --- /dev/null +++ b/app/javascript/src/services/api/configurations_api.js @@ -0,0 +1,6 @@ +// @flow +import axiosInstance from "./config"; +import { ABOUT_SCINOTE_PATH } from "./endpoints"; + +export const getSciNoteInfo = (): Promise<*> => + axiosInstance.get(ABOUT_SCINOTE_PATH).then(({ data }) => data); diff --git a/app/javascript/src/services/api/endpoints.js b/app/javascript/src/services/api/endpoints.js index 83a2ac416..edaa3d752 100644 --- a/app/javascript/src/services/api/endpoints.js +++ b/app/javascript/src/services/api/endpoints.js @@ -42,3 +42,6 @@ export const INVITE_USERS_PATH = "/client_api/users/invite_users"; // settings export const SETTINGS_TEAMS = "/settings/teams"; + +// scinote configurations +export const ABOUT_SCINOTE_PATH = "/client_api/about_scinote"; diff --git a/config/routes.rb b/config/routes.rb index b00d30ee1..77bea4053 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,7 @@ Rails.application.routes.draw do get '/settings/*all', to: 'client_api/settings#index' namespace :client_api, defaults: { format: 'json' } do - %i(activities teams notifications users).each do |path| + %i(activities teams notifications users confirmations).each do |path| draw path end end diff --git a/config/routes/confirmations.rb b/config/routes/confirmations.rb new file mode 100644 index 000000000..8cb5cbcf2 --- /dev/null +++ b/config/routes/confirmations.rb @@ -0,0 +1,2 @@ +# scinote configurations routes +get '/about_scinote', to: 'configurations_controller#about_scinote' diff --git a/features/navigation/addons_versions_modal.feature b/features/navigation/addons_versions_modal.feature new file mode 100644 index 000000000..139004d33 --- /dev/null +++ b/features/navigation/addons_versions_modal.feature @@ -0,0 +1,21 @@ +Feature: Addon versions + As a sciNote User + I want know what addon are activated + So that I know what features are enabled + + Background: + Given the "BioSistemika Process" team exists + Given the following users are registered + | email | password | password_confirmation | full_name | initials | + | admin@myorg.com | mypassword1234 | mypassword1234 | Karli Novak | KN | + And "admin@myorg.com" is in "BioSistemika Process" team as a "admin" + And is signed in with "admin@myorg.com", "mypassword1234" + + @javascript + Scenario: Open the sciNote addons modal + Given I'm on the profile page + And I click "#nav-info-dropdown" icon + And I click "About sciNote" link within ".dropdown.open" + Then I should see "About sciNote" + And I should see "sciNote core version" + And I should see "Addon versions" diff --git a/features/settings_page/profile.feature b/features/settings_page/profile.feature index ff968c9b6..b1571f500 100644 --- a/features/settings_page/profile.feature +++ b/features/settings_page/profile.feature @@ -15,7 +15,7 @@ Background: Scenario: Successful navigate to profile page Given I'm on the home page of "BioSistemika Process" team And I click on Avatar - And I click "Settings" link within "user-account-dropdown" + And I click "Settings" link within "#user-account-dropdown" Then I should see "My Profile" @javascript diff --git a/features/step_definitions/shared_steps.rb b/features/step_definitions/shared_steps.rb index 87b792bf6..c4abd72b7 100644 --- a/features/step_definitions/shared_steps.rb +++ b/features/step_definitions/shared_steps.rb @@ -15,7 +15,7 @@ Given(/^I click "(.+)" link$/) do |link| end Given(/^I click "(.+)" link within "(.+)"$/) do |link, element| - within("##{element}") do + within(element) do click_link link end end @@ -92,3 +92,7 @@ Then(/^I should see "([^"]*)" in "([^"]*)" input field$/) do |text, container_id container = page.find_by_id(container_id) expect(container).to have_xpath("//input[@value='#{text}']") end + +Given("I click {string} icon") do |id| + find(:css, id).click +end diff --git a/yarn.lock b/yarn.lock index d2b42b099..d3498b4ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4865,7 +4865,7 @@ prop-types-extra@^1.0.1: dependencies: warning "^3.0.0" -prop-types@^15.5.10: +prop-types@^15.5.10, prop-types@^15.5.6: version "15.6.0" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856" dependencies: