From 8809a3e3c8351d47b3fa7437322360a2471cf092 Mon Sep 17 00:00:00 2001 From: vjrj Date: Wed, 14 Feb 2018 10:26:22 +0100 Subject: [PATCH] Some work with spiderable --- cucumber/features/general.feature | 1 - cucumber/features/pages.feature | 2 ++ cucumber/features/steps_definitions/pages.js | 9 ++++++ imports/ui/components/History/History.js | 7 ----- imports/ui/layouts/App/App.js | 32 +++++++++++++++++++- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/cucumber/features/general.feature b/cucumber/features/general.feature index c3ea6a8..3cf078d 100644 --- a/cucumber/features/general.feature +++ b/cucumber/features/general.feature @@ -11,4 +11,3 @@ Feature: This app should generate a correct sitemap, etc | fires | Active Fires | | login | Login | | signup | Signup | - # And should be spiderables diff --git a/cucumber/features/pages.feature b/cucumber/features/pages.feature index 9814434..ed3f4fe 100644 --- a/cucumber/features/pages.feature +++ b/cucumber/features/pages.feature @@ -9,6 +9,7 @@ Feature: Test all secundary pages | activeFires | Active Fires | Then I check that all pages works properly + @watch Scenario: Check that all secondary pages work well Given a list of page urls and contents | login | Login | true | @@ -20,6 +21,7 @@ Feature: Test all secundary pages | fire/inexistent | This page doesn't exist | false | | fire/Fe26.2**1a0361ed0384f741403682e26b4bbc3850bee24e775da13c9782b22365ea895f*r_3gmVad5vzkeyqPpo6UcA*1s5fFz3iDGKTYP2RCvXMshof00QCHf4ErDl9K2dxoX0u-J-t6scyOWG8pGp3ehg_FfEtyR_kYcEKU3rE0jaSlZbD09TIvhiIJeS3C6Uc8YD-rit0XBrgsVKfYSxKzTRoOYiYFJ8JYd298hMtfiASePjS05Z58hhicyCcJYYRlarqDScG3LiVY3lL5y2nfcdIMNuSjCiKOJWuMkxwd9nR1UHMudLl0hEoy56mPdnHpDYtP9IYUlIOk1LlWBxcmHKifbXeqHu94p8j13Kk20dh2R49Hw3KsSoE9UbWmGQA9wAZXT82301i3rGF5GPAKjlTlRYcWisQurnPwHSVmx3DhUdiYwKGxt4KeaM5QVI4BE9octvE41OOprB_-Il105diQEh2Y9vdvX51ZVWIRfCboICPM6rJb0Oin7U7F1iM-oD_5s3DGnelfM5LGBcKwiB5paMo5M5vdBMaO-zR216cW9yGVXw9IZqHx8xDQWnoHAZjt8NLHeiGF2QOmIGtEUH7qnwhGpkcvszajmAZzR8saZgoH1qfBfvpVA41YfV14gU**4d030f05e23ad75409cebc609107467fc60be5077d52cf041087cd024fc4dc45*GY97aGFc1MyAsoO3Qxqtgwk9j-MbAPdEGBmEHq6r8VU | Additional information | false | Then I check that all page urls works properly + # And they are spiderable Scenario: Check that other non visible pages work well Given a list of non visible pages ids and contents diff --git a/cucumber/features/steps_definitions/pages.js b/cucumber/features/steps_definitions/pages.js index 1ce3c8c..5074d52 100644 --- a/cucumber/features/steps_definitions/pages.js +++ b/cucumber/features/steps_definitions/pages.js @@ -71,4 +71,13 @@ module.exports = function () { } callback(); }); + + this.Then(/^they are spiderable$/, (callback) => { + // Write code here that turns the phrase above into concrete actions + for (let i = 0; i < pages.length; i += 1) { + client.url(`${process.env.ROOT_URL}/${pages[i][0]}?_escaped_fragment_=`); + client.waitForText('#react-root', pages[i][1]); + } + callback(); + }); }; diff --git a/imports/ui/components/History/History.js b/imports/ui/components/History/History.js index f72523c..a33464f 100644 --- a/imports/ui/components/History/History.js +++ b/imports/ui/components/History/History.js @@ -1,12 +1,5 @@ -import { Meteor } from 'meteor/meteor'; import createHistory from 'history/createBrowserHistory'; const history = createHistory(); -history.listen((location) => { // , action ) => { - // console.log(location.pathname); - // console.log(action); // PUSH, etc - Meteor.Piwik.trackPage(location.pathname); -}); - export default history; diff --git a/imports/ui/layouts/App/App.js b/imports/ui/layouts/App/App.js index 9a11c69..f4cfc36 100644 --- a/imports/ui/layouts/App/App.js +++ b/imports/ui/layouts/App/App.js @@ -1,7 +1,7 @@ /* eslint-disable jsx-a11y/no-href */ /* eslint import/no-absolute-path: [2, { esmodule: false, commonjs: false, amd: false }] */ -import React from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Router, Switch, Route } from 'react-router-dom'; import { Grid } from 'react-bootstrap'; @@ -54,11 +54,40 @@ import history from '../../components/History/History'; import '../../components/NotificationsObserver/NotificationsObserver'; import './App.scss'; +class LocationListener extends Component { + // https://stackoverflow.com/questions/43512450/react-router-v4-route-onchange-event + static contextTypes = { + router: PropTypes.object + }; + + componentDidMount() { + this.handleLocationChange(this.context.router.history.location); + this.unlisten = + this.context.router.history.listen(this.handleLocationChange); + } + + componentWillUnmount() { + this.unlisten(); + } + + handleLocationChange(location) { + // your staff here + console.log(`----- location: '${location.pathname}'`); + Meteor.Piwik.trackPage(location.pathname); + // Meteor.isReadyForSpiderable = true; + } + + render() { + return this.props.children; + } +} + const App = props => ( /* https://react.i18next.com/components/i18nextprovider.html */ + { !props.loading ?
@@ -112,6 +141,7 @@ const App = props => ( }
: ''} +