@@ -6,6 +6,11 @@ import * as themes from "options/themes";
66
77const defaultConfig = new Config ( new StorageShim ( ) , window . __CONFIG__ ) ;
88
9+ const createTestConfig = ( ) => {
10+ const values = JSON . parse ( JSON . stringify ( window . __CONFIG__ ) ) ;
11+ return new Config ( new StorageShim ( ) , values ) ;
12+ } ;
13+
914describe ( "common/config" , ( ) => {
1015 it ( "should get all config values" , ( ) => {
1116 const storage = new StorageShim ( ) ;
@@ -164,6 +169,86 @@ describe("common/config", () => {
164169 expect ( defaultConfig . feature ( "download" ) ) . toBe ( true ) ;
165170 } ) ;
166171
172+ it ( "returns albums when library access is restricted" , ( ) => {
173+ const cfg = createTestConfig ( ) ;
174+ const settings = JSON . parse ( JSON . stringify ( cfg . getSettings ( ) ) ) ;
175+ settings . features = {
176+ ...settings . features ,
177+ search : true ,
178+ albums : true ,
179+ settings : true ,
180+ } ;
181+ cfg . set ( "settings" , settings ) ;
182+ cfg . set ( "acl" , {
183+ photos : { full_access : false , access_library : false } ,
184+ albums : { full_access : false , view : true } ,
185+ settings : { full_access : false , update : false } ,
186+ } ) ;
187+
188+ expect ( cfg . getDefaultRoute ( ) ) . toBe ( "albums" ) ;
189+ } ) ;
190+
191+ it ( "returns settings when library and albums are unavailable" , ( ) => {
192+ const cfg = createTestConfig ( ) ;
193+ const settings = JSON . parse ( JSON . stringify ( cfg . getSettings ( ) ) ) ;
194+ settings . features = {
195+ ...settings . features ,
196+ search : true ,
197+ albums : false ,
198+ settings : true ,
199+ } ;
200+ cfg . set ( "settings" , settings ) ;
201+ cfg . set ( "acl" , {
202+ photos : { full_access : false , access_library : false } ,
203+ albums : { full_access : false , view : false } ,
204+ settings : { full_access : false , update : false } ,
205+ } ) ;
206+
207+ expect ( cfg . getDefaultRoute ( ) ) . toBe ( "settings" ) ;
208+ } ) ;
209+
210+ it ( "honors settings start page when permitted" , ( ) => {
211+ const cfg = createTestConfig ( ) ;
212+ const settings = JSON . parse ( JSON . stringify ( cfg . getSettings ( ) ) ) ;
213+ settings . ui = {
214+ ...settings . ui ,
215+ startPage : "settings" ,
216+ } ;
217+ settings . features = {
218+ ...settings . features ,
219+ search : true ,
220+ settings : true ,
221+ } ;
222+ cfg . set ( "settings" , settings ) ;
223+ cfg . set ( "acl" , {
224+ photos : { full_access : false , access_library : true } ,
225+ settings : { full_access : false , update : true } ,
226+ } ) ;
227+
228+ expect ( cfg . getDefaultRoute ( ) ) . toBe ( "settings" ) ;
229+ } ) ;
230+
231+ it ( "falls back to default route when settings feature is disabled" , ( ) => {
232+ const cfg = createTestConfig ( ) ;
233+ const settings = JSON . parse ( JSON . stringify ( cfg . getSettings ( ) ) ) ;
234+ settings . ui = {
235+ ...settings . ui ,
236+ startPage : "settings" ,
237+ } ;
238+ settings . features = {
239+ ...settings . features ,
240+ search : true ,
241+ settings : false ,
242+ } ;
243+ cfg . set ( "settings" , settings ) ;
244+ cfg . set ( "acl" , {
245+ photos : { full_access : false , access_library : true } ,
246+ settings : { full_access : false , update : true } ,
247+ } ) ;
248+
249+ expect ( cfg . getDefaultRoute ( ) ) . toBe ( "browse" ) ;
250+ } ) ;
251+
167252 it ( "should test get name" , ( ) => {
168253 const result = defaultConfig . getPerson ( "a" ) ;
169254 expect ( result ) . toBeNull ( ) ;
0 commit comments