Skip to content

Commit

Permalink
Merge 69a2dfb into 51c62e5
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmavis committed Feb 27, 2020
2 parents 51c62e5 + 69a2dfb commit 04ff2d8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
38 changes: 22 additions & 16 deletions cypress/integration/endpoint-tests.js
Expand Up @@ -91,22 +91,28 @@ describe(`Visual regression testing for foundation.mozilla.org`, () => {

// Opportunity page tests (single and multi-page)

it(`Single-page opportunity`, function() {
cy.visit(`/en/opportunity/single-page/`);
cy.window()
.its(`main-js:react:finished`)
.should(`equal`, true);
cy.wait(500);
cy.percySnapshot();
});

it(`Multi-page opportunity`, function() {
cy.visit(`/en/opportunity/multi-page/`);
cy.window()
.its(`main-js:react:finished`)
.should(`equal`, true);
cy.wait(500);
cy.percySnapshot();
it(`Single-page opportunity should redirect to /intiatives`, function() {
cy.request({
url: `/en/opportunity/single-page-opportunity/`,
followRedirect: false
}).then(res => {
expect(res.status).to.eq(302);
expect(res.redirectedToUrl).to.eq(
`${Cypress.config().baseUrl}/en/initiatives/single-page-opportunity/`
);
});
});

it(`Multi-page opportunity should redirect to /intiatives`, function() {
cy.request({
url: `/en/opportunity/multi-page-opportunity/`,
followRedirect: false
}).then(res => {
expect(res.status).to.eq(302);
expect(res.redirectedToUrl).to.eq(
`${Cypress.config().baseUrl}/en/initiatives/multi-page-opportunity/`
);
});
});

// Campaign page tests (single and multi-page)
Expand Down
5 changes: 5 additions & 0 deletions network-api/networkapi/urls.py
Expand Up @@ -14,6 +14,7 @@
from networkapi.views import EnvVariablesView, review_app_help_view
from networkapi.buyersguide import views as buyersguide_views
from networkapi.wagtailpages.rss import RSSFeed, AtomFeed
from networkapi.wagtailpages.views import redirect_to_initiatives
from experiments import views as experiment_views

admin.autodiscover()
Expand Down Expand Up @@ -64,6 +65,10 @@
path('blog/rss/', RSSFeed()),
path('blog/atom/', AtomFeed()),

# redirect /opportunity Wagtail pages to /initiatives
# see https://github.com/mozilla/foundation.mozilla.org/issues/2971 for context
url(r'^opportunity/(?P<rest>.*)', redirect_to_initiatives),

# wagtail-managed data
url(r'', include(wagtail_urls)),
)
Expand Down
11 changes: 10 additions & 1 deletion network-api/networkapi/wagtailpages/views.py
@@ -1,5 +1,6 @@
from django.http import HttpResponseNotFound
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.utils import translation


def custom404_view(request, exception):
Expand All @@ -22,3 +23,11 @@ def custom404_view(request, exception):
else:
html = render(request, '404.html')
return HttpResponseNotFound(html.content)


def redirect_to_initiatives(request, rest):
lang = request.LANGUAGE_CODE
translation.activate(lang)
request.session[translation.LANGUAGE_SESSION_KEY] = lang

return redirect(f'/{request.LANGUAGE_CODE}/initiatives/{rest}')

0 comments on commit 04ff2d8

Please sign in to comment.