mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) add tests for site deletion
Summary: This tests site deletion with and without a plan. Test Plan: adding tests Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3017
This commit is contained in:
parent
70160fe01c
commit
3e5a292cde
@ -157,7 +157,7 @@ export class BillingModelImpl extends Disposable implements BillingModel {
|
|||||||
if (task === 'updatePlan') {
|
if (task === 'updatePlan') {
|
||||||
// Change plan from a paid plan to another paid plan or to the free plan.
|
// Change plan from a paid plan to another paid plan or to the free plan.
|
||||||
if (!planId) { throw new Error('BillingPage _submit error: no plan selected'); }
|
if (!planId) { throw new Error('BillingPage _submit error: no plan selected'); }
|
||||||
await this._billingAPI.setSubscription(planId, formData.token);
|
await this._billingAPI.setSubscription(planId, {tokenId: formData.token});
|
||||||
} else if (task === 'addCard' || task === 'updateCard') {
|
} else if (task === 'addCard' || task === 'updateCard') {
|
||||||
// Add or update payment card.
|
// Add or update payment card.
|
||||||
if (!formData.token) { throw new Error('BillingPage _submit error: missing card info token'); }
|
if (!formData.token) { throw new Error('BillingPage _submit error: missing card info token'); }
|
||||||
|
@ -121,7 +121,11 @@ export interface BillingAPI {
|
|||||||
settings: IBillingOrgSettings): Promise<OrganizationWithoutAccessInfo>;
|
settings: IBillingOrgSettings): Promise<OrganizationWithoutAccessInfo>;
|
||||||
setCard(tokenId: string): Promise<void>;
|
setCard(tokenId: string): Promise<void>;
|
||||||
removeCard(): Promise<void>;
|
removeCard(): Promise<void>;
|
||||||
setSubscription(planId: string, tokenId?: string): Promise<void>;
|
setSubscription(planId: string, options: {
|
||||||
|
tokenId?: string,
|
||||||
|
address?: IBillingAddress,
|
||||||
|
settings?: IBillingOrgSettings,
|
||||||
|
}): Promise<void>;
|
||||||
updateAddress(address?: IBillingAddress, settings?: IBillingOrgSettings): Promise<void>;
|
updateAddress(address?: IBillingAddress, settings?: IBillingOrgSettings): Promise<void>;
|
||||||
updateBillingManagers(delta: ManagerDelta): Promise<void>;
|
updateBillingManagers(delta: ManagerDelta): Promise<void>;
|
||||||
}
|
}
|
||||||
@ -178,10 +182,13 @@ export class BillingAPIImpl extends BaseAPI implements BillingAPI {
|
|||||||
return parsed.data;
|
return parsed.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setSubscription(planId: string, tokenId?: string): Promise<void> {
|
public async setSubscription(planId: string, options: {
|
||||||
|
tokenId?: string,
|
||||||
|
address?: IBillingAddress,
|
||||||
|
}): Promise<void> {
|
||||||
await this.request(`${this._url}/api/billing/subscription`, {
|
await this.request(`${this._url}/api/billing/subscription`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ tokenId, planId })
|
body: JSON.stringify({ ...options, planId })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ export class Doom {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a team site.
|
* Deletes a team site.
|
||||||
* - Remove billing (fails if no outstanding balance).
|
* - Remove billing (fails if there is an outstanding balance).
|
||||||
* - Delete workspaces.
|
* - Delete workspaces.
|
||||||
* - Delete org.
|
* - Delete org.
|
||||||
*/
|
*/
|
||||||
|
@ -1331,7 +1331,7 @@ export class HomeDBManager extends EventEmitter {
|
|||||||
...wsAcls, ...wsGroups, ...docs, ...docAcls, ...docGroups]);
|
...wsAcls, ...wsGroups, ...docs, ...docAcls, ...docGroups]);
|
||||||
|
|
||||||
// Delete billing account if this was the last org using it.
|
// Delete billing account if this was the last org using it.
|
||||||
const billingAccount = await manager.findOne(BillingAccount, org.billingAccount,
|
const billingAccount = await manager.findOne(BillingAccount, org.billingAccountId,
|
||||||
{relations: ['orgs']});
|
{relations: ['orgs']});
|
||||||
if (billingAccount && billingAccount.orgs.length === 0) {
|
if (billingAccount && billingAccount.orgs.length === 0) {
|
||||||
await manager.remove([billingAccount]);
|
await manager.remove([billingAccount]);
|
||||||
|
@ -264,6 +264,11 @@ export class FlexServer implements GristServer {
|
|||||||
return this._dbManager;
|
return this._dbManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getStorageManager(): IDocStorageManager {
|
||||||
|
if (!this._storageManager) { throw new Error('no storage manager available'); }
|
||||||
|
return this._storageManager;
|
||||||
|
}
|
||||||
|
|
||||||
public addLogging() {
|
public addLogging() {
|
||||||
if (this._check('logging')) { return; }
|
if (this._check('logging')) { return; }
|
||||||
if (process.env.GRIST_LOG_SKIP_HTTP) { return; }
|
if (process.env.GRIST_LOG_SKIP_HTTP) { return; }
|
||||||
|
@ -6,6 +6,7 @@ import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager';
|
|||||||
import * as Comm from 'app/server/lib/Comm';
|
import * as Comm from 'app/server/lib/Comm';
|
||||||
import { Hosts } from 'app/server/lib/extractOrg';
|
import { Hosts } from 'app/server/lib/extractOrg';
|
||||||
import { ICreate } from 'app/server/lib/ICreate';
|
import { ICreate } from 'app/server/lib/ICreate';
|
||||||
|
import { IDocStorageManager } from 'app/server/lib/IDocStorageManager';
|
||||||
import { IPermitStore } from 'app/server/lib/Permit';
|
import { IPermitStore } from 'app/server/lib/Permit';
|
||||||
import { Sessions } from 'app/server/lib/Sessions';
|
import { Sessions } from 'app/server/lib/Sessions';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
@ -29,6 +30,7 @@ export interface GristServer {
|
|||||||
getComm(): Comm;
|
getComm(): Comm;
|
||||||
getHosts(): Hosts;
|
getHosts(): Hosts;
|
||||||
getHomeDBManager(): HomeDBManager;
|
getHomeDBManager(): HomeDBManager;
|
||||||
|
getStorageManager(): IDocStorageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GristLoginMiddleware {
|
export interface GristLoginMiddleware {
|
||||||
|
Loading…
Reference in New Issue
Block a user