Skip to content

Commit 871b9e1

Browse files
committed
Enables external attachments in DocumentUsage
1 parent 5294fc1 commit 871b9e1

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

test/nbrowser/DocumentUsage.ts

+36-9
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ describe('DocumentUsage', function() {
1414
let api: UserAPI;
1515
let session: gu.Session;
1616

17-
before(async function () {
18-
session = await gu.session().user(ownerUser).login();
17+
gu.enableExternalAttachments();
18+
19+
async function makeSessionAndLogin() {
20+
// login() needs an options object passing to bypass an optimization that causes .login()
21+
// to think we're already logged in when we're not after using `server.restart()`.
22+
// Without this we end up with bad credentials.
23+
session = await gu.session().user(ownerUser).login({ retainExistingLogin: false });
1924
api = session.createHomeApi();
25+
}
26+
27+
before(async function () {
28+
await makeSessionAndLogin();
2029
});
2130

2231
it('shows usage stats on the raw data page', async function() {
@@ -105,14 +114,9 @@ describe('DocumentUsage', function() {
105114
});
106115
});
107116

108-
describe('attachment usage', function() {
109-
let docId: string;
110-
111-
before(async () => {
112-
docId = await session.tempNewDoc(cleanup, "AttachmentUsageTestDoc");
113-
});
114-
117+
function testAttachmentsUsage(getDocId: () => string) {
115118
it('updates attachments size usage when uploading attachments', async function () {
119+
const docId = getDocId();
116120
// Add a new 'Attachments' column of type Attachment to Table1.
117121
await api.applyUserActions(docId, [['AddEmptyTable', "AttachmentsTable"]]);
118122
await gu.getPageItem('AttachmentsTable').click();
@@ -147,6 +151,29 @@ describe('DocumentUsage', function() {
147151
await assertDataSize('0.00');
148152
await assertAttachmentsSize('0.00');
149153
});
154+
}
155+
156+
describe('attachment usage without external attachments', function() {
157+
let docId: string;
158+
159+
before(async () => {
160+
docId = await session.tempNewDoc(cleanup, `AttachmentUsageTestDoc - internal`);
161+
});
162+
163+
testAttachmentsUsage(() => docId);
164+
});
165+
166+
describe('attachment usage with external attachments', function() {
167+
let docId: string;
168+
169+
before(async () => {
170+
docId = await session.tempNewDoc(cleanup, `AttachmentUsageTestDoc - internal`);
171+
const docApi = api.getDocAPI(docId);
172+
await docApi.setAttachmentStore("external");
173+
assert.equal((await docApi.getAttachmentStore()).type, "external");
174+
});
175+
176+
testAttachmentsUsage(() => docId);
150177
});
151178

152179
describe('doc usage access', function() {

0 commit comments

Comments
 (0)