@@ -14,9 +14,18 @@ describe('DocumentUsage', function() {
14
14
let api : UserAPI ;
15
15
let session : gu . Session ;
16
16
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 } ) ;
19
24
api = session . createHomeApi ( ) ;
25
+ }
26
+
27
+ before ( async function ( ) {
28
+ await makeSessionAndLogin ( ) ;
20
29
} ) ;
21
30
22
31
it ( 'shows usage stats on the raw data page' , async function ( ) {
@@ -105,14 +114,9 @@ describe('DocumentUsage', function() {
105
114
} ) ;
106
115
} ) ;
107
116
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 ) {
115
118
it ( 'updates attachments size usage when uploading attachments' , async function ( ) {
119
+ const docId = getDocId ( ) ;
116
120
// Add a new 'Attachments' column of type Attachment to Table1.
117
121
await api . applyUserActions ( docId , [ [ 'AddEmptyTable' , "AttachmentsTable" ] ] ) ;
118
122
await gu . getPageItem ( 'AttachmentsTable' ) . click ( ) ;
@@ -147,6 +151,29 @@ describe('DocumentUsage', function() {
147
151
await assertDataSize ( '0.00' ) ;
148
152
await assertAttachmentsSize ( '0.00' ) ;
149
153
} ) ;
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 ) ;
150
177
} ) ;
151
178
152
179
describe ( 'doc usage access' , function ( ) {
0 commit comments