mirror of https://github.com/zulip/zulip.git
page_params: Make seperate `page_params` for billing module.
This commit introduces a seperate `page_params` file for billing module since we only use certain page_params in billing module only that it does not make sense to include them in the main `page_params.ts`. Also introduced `zpage_billing_params` for proper testing new `page_params` in billing module.
This commit is contained in:
parent
e360a896f6
commit
1f4dd0705d
|
@ -1,7 +1,8 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
|
||||||
import * as loading from "../loading";
|
import * as loading from "../loading";
|
||||||
import {page_params} from "../page_params";
|
|
||||||
|
import {page_params} from "./page_params";
|
||||||
|
|
||||||
export function create_ajax_request(
|
export function create_ajax_request(
|
||||||
url,
|
url,
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import $ from "jquery";
|
||||||
|
|
||||||
|
// Don't remove page_params here yet, since we still use them later.
|
||||||
|
// For example, "#page_params" is used again through `sentry.ts`, which
|
||||||
|
// imports the main `src/page_params` module.
|
||||||
|
export const page_params: {
|
||||||
|
annual_price: number;
|
||||||
|
monthly_price: number;
|
||||||
|
percent_off: number;
|
||||||
|
seat_count: number;
|
||||||
|
} = $("#page-params").data("params");
|
||||||
|
|
||||||
|
if (!page_params) {
|
||||||
|
throw new Error("Missing page-params");
|
||||||
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
|
||||||
import {page_params} from "../page_params";
|
|
||||||
|
|
||||||
import * as helpers from "./helpers";
|
import * as helpers from "./helpers";
|
||||||
|
import {page_params} from "./page_params";
|
||||||
|
|
||||||
export const initialize = () => {
|
export const initialize = () => {
|
||||||
helpers.set_tab("upgrade");
|
helpers.set_tab("upgrade");
|
||||||
|
|
|
@ -10,7 +10,7 @@ const {mock_esm, set_global, zrequire} = require("./lib/namespace");
|
||||||
const jQueryFactory = require("./lib/real_jquery");
|
const jQueryFactory = require("./lib/real_jquery");
|
||||||
const {run_test} = require("./lib/test");
|
const {run_test} = require("./lib/test");
|
||||||
const $ = require("./lib/zjquery");
|
const $ = require("./lib/zjquery");
|
||||||
const {page_params} = require("./lib/zpage_params");
|
const {page_params} = require("./lib/zpage_billing_params");
|
||||||
|
|
||||||
const template = fs.readFileSync(
|
const template = fs.readFileSync(
|
||||||
path.resolve(__dirname, "../../templates/corporate/upgrade.html"),
|
path.resolve(__dirname, "../../templates/corporate/upgrade.html"),
|
||||||
|
|
|
@ -15,6 +15,7 @@ const namespace = require("./namespace");
|
||||||
const test = require("./test");
|
const test = require("./test");
|
||||||
const blueslip = require("./zblueslip");
|
const blueslip = require("./zblueslip");
|
||||||
const zjquery = require("./zjquery");
|
const zjquery = require("./zjquery");
|
||||||
|
const zpage_billing_params = require("./zpage_billing_params");
|
||||||
const zpage_params = require("./zpage_params");
|
const zpage_params = require("./zpage_params");
|
||||||
|
|
||||||
process.env.NODE_ENV = "test";
|
process.env.NODE_ENV = "test";
|
||||||
|
@ -110,12 +111,15 @@ test.set_verbose(files.length === 1);
|
||||||
ls_container.clear();
|
ls_container.clear();
|
||||||
_.throttle = immediate;
|
_.throttle = immediate;
|
||||||
_.debounce = immediate;
|
_.debounce = immediate;
|
||||||
|
zpage_billing_params.reset();
|
||||||
zpage_params.reset();
|
zpage_params.reset();
|
||||||
|
|
||||||
namespace.mock_esm("../../src/blueslip", blueslip);
|
namespace.mock_esm("../../src/blueslip", blueslip);
|
||||||
require("../../src/blueslip");
|
require("../../src/blueslip");
|
||||||
namespace.mock_esm("../../src/i18n", stub_i18n);
|
namespace.mock_esm("../../src/i18n", stub_i18n);
|
||||||
require("../../src/i18n");
|
require("../../src/i18n");
|
||||||
|
namespace.mock_esm("../../src/billing/page_params", zpage_billing_params);
|
||||||
|
require("../../src/billing/page_params");
|
||||||
namespace.mock_esm("../../src/page_params", zpage_params);
|
namespace.mock_esm("../../src/page_params", zpage_params);
|
||||||
require("../../src/page_params");
|
require("../../src/page_params");
|
||||||
namespace.mock_esm("../../src/user_settings", zpage_params);
|
namespace.mock_esm("../../src/user_settings", zpage_params);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
const namespace = require("./namespace");
|
const namespace = require("./namespace");
|
||||||
const zblueslip = require("./zblueslip");
|
const zblueslip = require("./zblueslip");
|
||||||
const $ = require("./zjquery");
|
const $ = require("./zjquery");
|
||||||
|
const zpage_billing_params = require("./zpage_billing_params");
|
||||||
const zpage_params = require("./zpage_params");
|
const zpage_params = require("./zpage_params");
|
||||||
|
|
||||||
let current_file_name;
|
let current_file_name;
|
||||||
|
@ -29,6 +30,7 @@ async function execute_test(label, f, opts) {
|
||||||
if (!sloppy_$ && $.clear_all_elements) {
|
if (!sloppy_$ && $.clear_all_elements) {
|
||||||
$.clear_all_elements();
|
$.clear_all_elements();
|
||||||
}
|
}
|
||||||
|
zpage_billing_params.reset();
|
||||||
zpage_params.reset();
|
zpage_params.reset();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.page_params = {};
|
||||||
|
|
||||||
|
exports.reset = () => {
|
||||||
|
for (const field in exports.page_params) {
|
||||||
|
if (Object.hasOwn(exports.page_params, field)) {
|
||||||
|
delete exports.page_params[field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -9,7 +9,7 @@ const {JSDOM} = require("jsdom");
|
||||||
const {set_global, zrequire} = require("./lib/namespace");
|
const {set_global, zrequire} = require("./lib/namespace");
|
||||||
const {run_test} = require("./lib/test");
|
const {run_test} = require("./lib/test");
|
||||||
const $ = require("./lib/zjquery");
|
const $ = require("./lib/zjquery");
|
||||||
const {page_params} = require("./lib/zpage_params");
|
const {page_params} = require("./lib/zpage_billing_params");
|
||||||
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
const template = fs.readFileSync(
|
const template = fs.readFileSync(
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"./styles/portico/activity.css"
|
"./styles/portico/activity.css"
|
||||||
],
|
],
|
||||||
"billing": [
|
"billing": [
|
||||||
|
"./src/billing/page_params",
|
||||||
"./src/bundles/portico",
|
"./src/bundles/portico",
|
||||||
"./src/portico/landing-page",
|
"./src/portico/landing-page",
|
||||||
"./styles/portico/landing_page.css",
|
"./styles/portico/landing_page.css",
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
"./styles/portico/billing.css"
|
"./styles/portico/billing.css"
|
||||||
],
|
],
|
||||||
"upgrade": [
|
"upgrade": [
|
||||||
|
"./src/billing/page_params",
|
||||||
"./src/bundles/portico",
|
"./src/bundles/portico",
|
||||||
"./src/portico/tippyjs",
|
"./src/portico/tippyjs",
|
||||||
"./src/portico/landing-page",
|
"./src/portico/landing-page",
|
||||||
|
@ -27,6 +29,7 @@
|
||||||
"./styles/portico/billing.css"
|
"./styles/portico/billing.css"
|
||||||
],
|
],
|
||||||
"billing-event-status": [
|
"billing-event-status": [
|
||||||
|
"./src/billing/page_params",
|
||||||
"./src/bundles/portico",
|
"./src/bundles/portico",
|
||||||
"./styles/portico/landing_page.css",
|
"./styles/portico/landing_page.css",
|
||||||
"./src/billing/event_status.js",
|
"./src/billing/event_status.js",
|
||||||
|
|
Loading…
Reference in New Issue