From c30fea21efdd9bd7dccf5849f856daab716e5f35 Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Thu, 28 Sep 2023 14:21:16 +0800 Subject: [PATCH] FIX: Clicking on login should show login modal (#177) * FIX: Clicking on login should show login modal * Add system test that shows the login modal appears --- .../discourse/components/login-required.js | 17 ----------------- .../templates/components/login-required.hbs | 4 ++-- spec/system/subscription_product_spec.rb | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 assets/javascripts/discourse/components/login-required.js create mode 100644 spec/system/subscription_product_spec.rb diff --git a/assets/javascripts/discourse/components/login-required.js b/assets/javascripts/discourse/components/login-required.js deleted file mode 100644 index fc7682d..0000000 --- a/assets/javascripts/discourse/components/login-required.js +++ /dev/null @@ -1,17 +0,0 @@ -import Component from "@ember/component"; -import cookie from "discourse/lib/cookie"; -import DiscourseURL from "discourse/lib/url"; -import { default as getURL } from "discourse-common/lib/get-url"; - -export default Component.extend({ - classNames: ["login-required", "subscriptions"], - actions: { - createAccount() { - const destinationUrl = window.location.href; - const cookiePath = getURL("/"); - - cookie("destination_url", destinationUrl, { path: cookiePath }); - DiscourseURL.redirectTo("/login"); - }, - }, -}); diff --git a/assets/javascripts/discourse/templates/components/login-required.hbs b/assets/javascripts/discourse/templates/components/login-required.hbs index 21c67ce..59f3de8 100644 --- a/assets/javascripts/discourse/templates/components/login-required.hbs +++ b/assets/javascripts/discourse/templates/components/login-required.hbs @@ -2,7 +2,7 @@ \ No newline at end of file diff --git a/spec/system/subscription_product_spec.rb b/spec/system/subscription_product_spec.rb new file mode 100644 index 0000000..29da4bc --- /dev/null +++ b/spec/system/subscription_product_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +describe "Subscription products", type: :system do + fab!(:admin) { Fabricate(:admin) } + fab!(:product) { Fabricate(:product, external_id: "prod_OiKyO6ZMFCIhQa") } + + before { SiteSetting.discourse_subscriptions_enabled = true } + + it "shows the login modal" do + visit("/s") + + find("button.login-required.subscriptions").click + + expect(page).to have_css(".modal-container .login-modal") + end +end