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
This commit is contained in:
Natalie Tay 2023-09-28 14:21:16 +08:00 committed by GitHub
parent b855ce9bb9
commit c30fea21ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 19 deletions

View File

@ -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");
},
},
});

View File

@ -2,7 +2,7 @@
<DButton <DButton
@label="log_in" @label="log_in"
@action={{this.createAccount}} @action={{route-action "showLogin"}}
@icon="user" @icon="user"
class="btn btn-primary" class="btn btn-primary login-required subscriptions"
/> />

View File

@ -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