Skip to content

Commit

Permalink
Merge pull request #1373 from cdrini/fix/e2e-tests
Browse files Browse the repository at this point in the history
Fix failing e2e tests
  • Loading branch information
cdrini authored Jan 30, 2025
2 parents da7e3ce + 6b86af5 commit d568bd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/autoplay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ClientFunction } from 'testcafe';
import params from './helpers/params';

const getLocationHref = ClientFunction(() => window.location.href.toString());
const FLIP_SPEED = 1000;
const FIRST_PAGE_DELAY = 2000;
const FLIP_SPEED = 2000;
const FIRST_PAGE_DELAY = 6000;

fixture `Autoplay plugin`.page `${params.baseUrl}/BookReaderDemo/demo-internetarchive.html?ocaid=goody&autoflip=1`;

Expand Down
15 changes: 6 additions & 9 deletions tests/e2e/helpers/mockSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ export const PAGE_FIRST_RESULT = 30;

export const SEARCH_INSIDE_URL_RE = /https:\/\/ia[0-9]+\.us\.archive\.org\/fulltext\/inside\.php\?item_id=.*/;

//adding jQueryxxxxxxxx-xxxxxxxx (semi-random numbers) from request url to returned search request object
/** Mock response for a matching search term. */
export function mockResponseFound(req, res) {
const requestUrl = new URL(req.url);
const jqueryUrl = requestUrl.searchParams.get("callback");
const wholeString = jqueryUrl + '(' + JSON.stringify(MOCKED_RESPONSE_FOUND) + ')';
res.setBody(wholeString);
res.headers['Access-Control-Allow-Origin'] = '*';
res.headers['Content-Type'] = 'application/json';
res.setBody(JSON.stringify(MOCKED_RESPONSE_FOUND));
}

/** Mock response for a matching search term. */
export function mockResponseNotFound(req, res) {
const requestUrl = new URL(req.url);
const jqueryUrl = requestUrl.searchParams.get("callback");
const wholeString = jqueryUrl + '(' + JSON.stringify(MOCKED_RESPONSE_NOT_FOUND) + ')';
res.setBody(wholeString);
res.headers['Access-Control-Allow-Origin'] = '*';
res.headers['Content-Type'] = 'application/json';
res.setBody(JSON.stringify(MOCKED_RESPONSE_NOT_FOUND));
}

const PAGE_FIRST_RESULT_ADJUSTED = PAGE_FIRST_RESULT + 12;
Expand Down

0 comments on commit d568bd0

Please sign in to comment.