Skip to content

Commit

Permalink
Merge pull request #158 from percy/PPLT-2089/poa-cache-js
Browse files Browse the repository at this point in the history
Making Caching for PoA
  • Loading branch information
Amit3200 authored Sep 27, 2023
2 parents e36c9b2 + eb044f6 commit bebceee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions percy/percyOnAutomate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const utils = require('@percy/sdk-utils');
// Collect client and environment information
const sdkPkg = require('../package.json');
const CLIENT_INFO = `${sdkPkg.name}/${sdkPkg.version}`;
const { Cache } = require('./util/cache');

let clientWdPkg = null;
try {
Expand All @@ -29,8 +30,12 @@ module.exports = async function percyOnAutomate(driver, name, options) {
// This AppiumDriver has a property of driver which contains the original driver
// Hence to access the capabilities of original driver adding this fix
// Also, note that driverWrapper.getCapabilities() returns only few capabilities and not all
const capabilities = driver.type === 'wd' ? await driver.getCapabilities() : driver.driver.capabilities;
const commandExecutorUrl = driver.commandExecutorUrl;
const capabilities = await Cache.withCache(Cache.capabilities, sessionId, async () => {
return driver.type === 'wd' ? await driver.getCapabilities() : driver.driver.capabilities;
});
const commandExecutorUrl = await Cache.withCache(Cache.commandExecutorUrl, sessionId, async () => {
return driver.commandExecutorUrl;
});

/* istanbul ignore next */
if (options) {
Expand Down
3 changes: 3 additions & 0 deletions percy/util/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class Cache {
// Common stores, const, dont modify outside
static caps = 'caps';
static systemBars = 'systemBars';
static capabilities = 'capabilities';
static sessionCapabilities = 'session_capabilites';
static commandExecutorUrl = 'command_executor_url';

// maintainance
static lastTime = Date.now();
Expand Down

0 comments on commit bebceee

Please sign in to comment.