Changed members export to contain tiers
refs https://github.com/TryGhost/Team/issues/1076 - The "products" is a legacy term for what is now "tiers" since multiple tiers feature introduction in https://github.com/TryGhost/Ghost/releases/tag/v4.39.0 - Note, the "tiers" is a field meant for informational purposes and cannot be imported back into Ghost site.
This commit is contained in:
parent
850eb611c3
commit
b552727b69
@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Members API — exportCSV Can export a member without products 1: [headers] 1`] = `
|
||||
exports[`Members API — exportCSV Can export a member without tiers 1: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
@ -13,7 +13,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API — exportCSV Can export a member without products 2: [headers] 1`] = `
|
||||
exports[`Members API — exportCSV Can export a member without tiers 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
@ -26,7 +26,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API — exportCSV Can export a member without products 3: [headers] 1`] = `
|
||||
exports[`Members API — exportCSV Can export a member without tiers 3: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
@ -234,7 +234,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API — exportCSV Can export products 1: [headers] 1`] = `
|
||||
exports[`Members API — exportCSV Can export tiers 1: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
@ -247,7 +247,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API — exportCSV Can export products 2: [headers] 1`] = `
|
||||
exports[`Members API — exportCSV Can export tiers 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
@ -260,7 +260,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API — exportCSV Can export products 3: [headers] 1`] = `
|
||||
exports[`Members API — exportCSV Can export tiers 3: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
@ -273,7 +273,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API — exportCSV Can export products 4: [headers] 1`] = `
|
||||
exports[`Members API — exportCSV Can export tiers 4: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
|
@ -2388,7 +2388,7 @@ Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-disposition": Any<String>,
|
||||
"content-length": "215",
|
||||
"content-length": "212",
|
||||
"content-type": "text/csv; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Accept-Version, Origin, Accept-Encoding",
|
||||
|
@ -51,7 +51,7 @@ async function testOutput(member, asserts, filters = []) {
|
||||
'content-disposition': anyString
|
||||
});
|
||||
|
||||
res.text.should.match(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,products/);
|
||||
res.text.should.match(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers/);
|
||||
|
||||
let csv = Papa.parse(res.text, {header: true});
|
||||
let row = csv.data.find(r => r.id === member.id);
|
||||
@ -72,8 +72,8 @@ describe('Members API — exportCSV', function () {
|
||||
await agent.loginAsOwner();
|
||||
|
||||
await models.Product.add({
|
||||
name: 'Extra Paid Product',
|
||||
slug: 'extra-product',
|
||||
name: 'Extra Paid Tier',
|
||||
slug: 'extra-tier',
|
||||
type: 'paid',
|
||||
active: true,
|
||||
visibility: 'public'
|
||||
@ -106,8 +106,8 @@ describe('Members API — exportCSV', function () {
|
||||
mockManager.restore();
|
||||
});
|
||||
|
||||
it('Can export products', async function () {
|
||||
// Create a new member with a product
|
||||
it('Can export tiers', async function () {
|
||||
// Create a new member with a product (to be renamed to "tiers" once the changes is done on model layer)
|
||||
const member = await createMember({
|
||||
name: 'Test member',
|
||||
products: tiers
|
||||
@ -119,11 +119,11 @@ describe('Members API — exportCSV', function () {
|
||||
basicAsserts(member, row);
|
||||
should(row.subscribed_to_emails).eql('false');
|
||||
should(row.complimentary_plan).eql('');
|
||||
should(row.products.split(',').sort().join(',')).eql(tiersList);
|
||||
}, [`filter=products:${tiers[0].get('slug')}`, 'filter=subscribed:false']);
|
||||
should(row.tiers.split(',').sort().join(',')).eql(tiersList);
|
||||
}, [`filter=tier:[${tiers[0].get('slug')}]`, 'filter=subscribed:false']);
|
||||
});
|
||||
|
||||
it('Can export a member without products', async function () {
|
||||
it('Can export a member without tiers', async function () {
|
||||
// Create a new member with a product
|
||||
const member = await createMember({
|
||||
name: 'Test member 2',
|
||||
@ -134,7 +134,7 @@ describe('Members API — exportCSV', function () {
|
||||
basicAsserts(member, row);
|
||||
should(row.subscribed_to_emails).eql('false');
|
||||
should(row.complimentary_plan).eql('');
|
||||
should(row.products).eql('');
|
||||
should(row.tiers).eql('');
|
||||
}, ['filter=subscribed:false']);
|
||||
});
|
||||
|
||||
@ -157,7 +157,7 @@ describe('Members API — exportCSV', function () {
|
||||
should(row.subscribed_to_emails).eql('false');
|
||||
should(row.complimentary_plan).eql('');
|
||||
should(row.labels).eql(labelsList);
|
||||
should(row.products).eql('');
|
||||
should(row.tiers).eql('');
|
||||
}, [`filter=label:${labels[0].get('slug')}`, 'filter=subscribed:false']);
|
||||
});
|
||||
|
||||
@ -174,7 +174,7 @@ describe('Members API — exportCSV', function () {
|
||||
should(row.subscribed_to_emails).eql('false');
|
||||
should(row.complimentary_plan).eql('true');
|
||||
should(row.labels).eql('');
|
||||
should(row.products).eql('');
|
||||
should(row.tiers).eql('');
|
||||
}, ['filter=status:comped', 'filter=subscribed:false']);
|
||||
});
|
||||
|
||||
@ -193,7 +193,7 @@ describe('Members API — exportCSV', function () {
|
||||
should(row.subscribed_to_emails).eql('true');
|
||||
should(row.complimentary_plan).eql('');
|
||||
should(row.labels).eql('');
|
||||
should(row.products).eql('');
|
||||
should(row.tiers).eql('');
|
||||
}, ['filter=subscribed:true']);
|
||||
});
|
||||
|
||||
@ -232,7 +232,7 @@ describe('Members API — exportCSV', function () {
|
||||
should(row.subscribed_to_emails).eql('false');
|
||||
should(row.complimentary_plan).eql('');
|
||||
should(row.labels).eql('');
|
||||
should(row.products).eql('');
|
||||
should(row.tiers).eql('');
|
||||
should(row.stripe_customer_id).eql('cus_12345');
|
||||
}, ['filter=subscribed:false', 'filter=subscriptions.subscription_id:sub_123']);
|
||||
});
|
||||
|
@ -1469,7 +1469,7 @@ describe('Members API', function () {
|
||||
.expectStatus(200);
|
||||
|
||||
const beforeMember = body2.members[0];
|
||||
assert.equal(beforeMember.tiers.length, 2, 'The member should have two products now');
|
||||
assert.equal(beforeMember.tiers.length, 2, 'The member should have two tiers now');
|
||||
|
||||
// Now try to remove only the complimentary one
|
||||
const compedPayload = {
|
||||
@ -2100,14 +2100,14 @@ describe('Members API', function () {
|
||||
'content-disposition': anyString
|
||||
});
|
||||
|
||||
res.text.should.match(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,products/);
|
||||
res.text.should.match(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers/);
|
||||
|
||||
const csv = Papa.parse(res.text, {header: true});
|
||||
should.exist(csv.data.find(row => row.name === 'Mr Egg'));
|
||||
should.exist(csv.data.find(row => row.name === 'Winston Zeddemore'));
|
||||
should.exist(csv.data.find(row => row.name === 'Ray Stantz'));
|
||||
should.exist(csv.data.find(row => row.email === 'member2@test.com'));
|
||||
should.exist(csv.data.find(row => row.products.length > 0));
|
||||
should.exist(csv.data.find(row => row.tiers.length > 0));
|
||||
should.exist(csv.data.find(row => row.labels.length > 0));
|
||||
});
|
||||
|
||||
@ -2121,14 +2121,14 @@ describe('Members API', function () {
|
||||
'content-disposition': anyString
|
||||
});
|
||||
|
||||
res.text.should.match(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,products/);
|
||||
res.text.should.match(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers/);
|
||||
|
||||
const csv = Papa.parse(res.text, {header: true});
|
||||
should.exist(csv.data.find(row => row.name === 'Mr Egg'));
|
||||
should.not.exist(csv.data.find(row => row.name === 'Egon Spengler'));
|
||||
should.not.exist(csv.data.find(row => row.name === 'Ray Stantz'));
|
||||
should.not.exist(csv.data.find(row => row.email === 'member2@test.com'));
|
||||
// note that this member doesn't have products
|
||||
// note that this member doesn't have tiers
|
||||
should.exist(csv.data.find(row => row.labels.length > 0));
|
||||
});
|
||||
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_COLUMNS = [
|
||||
'created_at',
|
||||
'deleted_at',
|
||||
'labels',
|
||||
'products'
|
||||
'tiers'
|
||||
];
|
||||
|
||||
const unparse = (members, columns = DEFAULT_COLUMNS.slice()) => {
|
||||
@ -54,7 +54,7 @@ const unparse = (members, columns = DEFAULT_COLUMNS.slice()) => {
|
||||
created_at: member.created_at,
|
||||
deleted_at: member.deleted_at,
|
||||
labels: labels,
|
||||
products: tiers,
|
||||
tiers: tiers,
|
||||
error: member.error || null
|
||||
};
|
||||
});
|
||||
|
@ -13,7 +13,7 @@ describe('unparse', function () {
|
||||
|
||||
assert.ok(result);
|
||||
|
||||
const expected = `id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,products\r\n,email@example.com,Sam Memberino,Early supporter,,,,,,,`;
|
||||
const expected = `id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers\r\n,email@example.com,Sam Memberino,Early supporter,,,,,,,`;
|
||||
assert.equal(result, expected);
|
||||
});
|
||||
|
||||
@ -96,11 +96,11 @@ third-member-email@email.com,"banana, avocado"`;
|
||||
}];
|
||||
|
||||
const columns = [
|
||||
'email', 'products'
|
||||
'email', 'tiers'
|
||||
];
|
||||
|
||||
const result = unparse(json, columns);
|
||||
const expected = `email,products\r\nmember-email@email.com,Bronze Level`;
|
||||
const expected = `email,tiers\r\nmember-email@email.com,Bronze Level`;
|
||||
assert.equal(result, expected);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user