ti2 1.0.122 → 1.0.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ const bookings = require('../bookings');
2
+
3
+ describe('resolveProductSearchTtrSeconds', () => {
4
+ const oneDay = bookings.oneDayProductSearchTtrSeconds;
5
+ const weekly = bookings.defaultProductSearchTtrSeconds;
6
+
7
+ it('uses a seven-day default when no TTR is configured', () => {
8
+ expect(bookings.resolveProductSearchTtrSeconds({}, {})).toBe(weekly);
9
+ expect(weekly).toBe(oneDay * 7);
10
+ });
11
+
12
+ it('keeps an explicit one-day token TTR', () => {
13
+ expect(bookings.resolveProductSearchTtrSeconds({
14
+ ttlForProducts: oneDay,
15
+ }, {})).toBe(oneDay);
16
+ expect(bookings.resolveProductSearchTtrSeconds({
17
+ ttlForProducts: String(oneDay),
18
+ }, {})).toBe(String(oneDay));
19
+ });
20
+
21
+ it('keeps an explicit non-legacy TTR, including short test values', () => {
22
+ expect(bookings.resolveProductSearchTtrSeconds({
23
+ ttlForProducts: 2,
24
+ }, {})).toBe(2);
25
+ expect(bookings.resolveProductSearchTtrSeconds({
26
+ ttlForProducts: oneDay * 2,
27
+ }, {})).toBe(oneDay * 2);
28
+ });
29
+
30
+ it('keeps an explicit one-day plugin cacheSettings TTR', () => {
31
+ expect(bookings.resolveProductSearchTtrSeconds({}, {
32
+ cacheSettings: {
33
+ bookingsProductSearch: {
34
+ ttr: oneDay,
35
+ },
36
+ },
37
+ })).toBe(oneDay);
38
+ });
39
+ });
@@ -40,6 +40,9 @@ describe('user', () => {
40
40
  plugins,
41
41
  } = await testUtils({
42
42
  plugins: [appName],
43
+ pluginCapabilities: {
44
+ [appName]: { weeklyProductCatalogSync: true },
45
+ },
43
46
  }));
44
47
  await db.models.UserAppKey.destroy({ where: { userId } });
45
48
  // create an App
@@ -353,10 +356,11 @@ describe('user', () => {
353
356
  expect(returnValue.success).toBe(true);
354
357
  });
355
358
  it('should be able to get all the methods for an app', async () => {
356
- const { methods } = await doApiGet({
359
+ const { capabilities, methods } = await doApiGet({
357
360
  url: `/app/${appName}/methods`,
358
361
  token: userKey,
359
362
  });
363
+ expect(capabilities).toEqual({ weeklyProductCatalogSync: true });
360
364
  expect(methods).toEqual(
361
365
  expect.arrayContaining([
362
366
  'validateToken', 'getProduct',
@@ -70,7 +70,7 @@ const tokenTemplate = async (req, res, next) => {
70
70
  ttlForProducts: {
71
71
  type: 'number',
72
72
  regExp: /.+/,
73
- default: 60 * 60 * 24, // 1 day
73
+ default: 60 * 60 * 24 * 7, // 7 days; weekly full product catalog refresh
74
74
  },
75
75
  doNotCallPluginForProducts: {
76
76
  type: 'boolean',