mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-02-12 22:44:59 +00:00
At the moment, paying for a product typically involves first clicking the subscribe link added to the navigation bar, selecting a product and then adding card details to to make the purchase. This change skips the product selection step if the site has only one product.
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
|
|
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
|
|
import { click, visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
|
|
|
function singleProductPretender() {
|
|
pretender.get("/s", () => {
|
|
const products = [
|
|
{
|
|
id: "prod_23o8I7tU4g56",
|
|
name: "Awesome Product",
|
|
description:
|
|
"Subscribe to our awesome product. For only $230.10 per month, you can get access. This is a test site. No real credit card transactions.",
|
|
},
|
|
];
|
|
|
|
return response(products);
|
|
});
|
|
}
|
|
|
|
acceptance("Discourse Subscriptions", function (needs) {
|
|
needs.user();
|
|
needs.hooks.beforeEach(function () {
|
|
stubStripe();
|
|
});
|
|
|
|
test("subscribing", async function (assert) {
|
|
await visit("/s");
|
|
await click(".product:first-child a");
|
|
|
|
assert.ok(
|
|
count(".discourse-subscriptions-section-columns") > 0,
|
|
"has the sections for billing"
|
|
);
|
|
|
|
assert.ok(
|
|
count(".subscribe-buttons button") > 0,
|
|
"has buttons for subscribe"
|
|
);
|
|
});
|
|
|
|
test("skips products list on sites with one product", async function (assert) {
|
|
singleProductPretender();
|
|
|
|
await visit("/s");
|
|
|
|
assert.dom(".subscribe-buttons button").exists({ count: 1 });
|
|
assert.dom("input.subscribe-promo-code").exists();
|
|
assert.dom("button.btn-payment").exists();
|
|
});
|
|
});
|