Skip to content

Commit 73161db

Browse files
authored
When lazy iframes are hidden, visualdiff tests fail with timeouts (#16)
If your page has hidden lazy iframes, visualdiff tests will fail with a timeout.
2 parents ee10bce + 9664275 commit 73161db

14 files changed

+154
-142
lines changed

lib/cli/drush.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference types="node" />
21
/**
32
* Run task either inside of the web container or from the host.
43
*

lib/cli/drush.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.drush = exports.drushSync = void 0;
3+
exports.drushSync = drushSync;
4+
exports.drush = drush;
45
var exec_1 = require("./exec");
56
/**
67
* Run task either inside of the web container or from the host.
@@ -11,7 +12,6 @@ var exec_1 = require("./exec");
1112
function drushSync(command, options) {
1213
return (0, exec_1.execSync)('drush', command, options);
1314
}
14-
exports.drushSync = drushSync;
1515
/**
1616
* Run drush asynchronously. Console output is streamed.
1717
*
@@ -20,4 +20,3 @@ exports.drushSync = drushSync;
2020
function drush(command) {
2121
return (0, exec_1.exec)('drush', command);
2222
}
23-
exports.drush = drush;

lib/cli/exec.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference types="node" />
21
import child_process from "child_process";
32
/**
43
* Run a command either inside of the web container or from the host.

lib/cli/exec.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
return (mod && mod.__esModule) ? mod : { "default": mod };
44
};
55
Object.defineProperty(exports, "__esModule", { value: true });
6-
exports.exec = exports.execSync = void 0;
6+
exports.execSync = execSync;
7+
exports.exec = exec;
78
var child_process_1 = __importDefault(require("child_process"));
89
/**
910
* Run a command either inside of the web container or from the host.
@@ -19,7 +20,6 @@ function execSync(baseCommand, command, options) {
1920
options.cwd = process.env.DDEV_HOSTNAME ? '/var/www/html' : process.cwd();
2021
return child_process_1.default.execSync("".concat(ddev, " ").concat(command), options);
2122
}
22-
exports.execSync = execSync;
2323
/**
2424
* Run a command asynchronously. Console output is streamed.
2525
*
@@ -41,4 +41,3 @@ function exec(baseCommand, command) {
4141
}
4242
return childProcess;
4343
}
44-
exports.exec = exec;

lib/cli/task.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference types="node" />
21
/**
32
* Run task either inside of the web container or from the host.
43
*

lib/cli/task.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.task = exports.taskSync = void 0;
3+
exports.taskSync = taskSync;
4+
exports.task = task;
45
var exec_1 = require("./exec");
56
/**
67
* Run task either inside of the web container or from the host.
@@ -11,7 +12,6 @@ var exec_1 = require("./exec");
1112
function taskSync(command, options) {
1213
return (0, exec_1.execSync)('task', command, options);
1314
}
14-
exports.taskSync = taskSync;
1515
/**
1616
* Run a task asynchronously. Console output is streamed.
1717
*
@@ -20,4 +20,3 @@ exports.taskSync = taskSync;
2020
function task(command) {
2121
return (0, exec_1.exec)('task', command);
2222
}
23-
exports.task = task;

lib/setup/global-setup.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1515
}) : function(o, v) {
1616
o["default"] = v;
1717
});
18-
var __importStar = (this && this.__importStar) || function (mod) {
19-
if (mod && mod.__esModule) return mod;
20-
var result = {};
21-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22-
__setModuleDefault(result, mod);
23-
return result;
24-
};
18+
var __importStar = (this && this.__importStar) || (function () {
19+
var ownKeys = function(o) {
20+
ownKeys = Object.getOwnPropertyNames || function (o) {
21+
var ar = [];
22+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23+
return ar;
24+
};
25+
return ownKeys(o);
26+
};
27+
return function (mod) {
28+
if (mod && mod.__esModule) return mod;
29+
var result = {};
30+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31+
__setModuleDefault(result, mod);
32+
return result;
33+
};
34+
})();
2535
var __importDefault = (this && this.__importDefault) || function (mod) {
2636
return (mod && mod.__esModule) ? mod : { "default": mod };
2737
};

lib/testcase/test.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference types="node" />
21
import { expect, TestFixture } from '@playwright/test';
32
/**
43
* Set a simpletest cookie for routing the tests to a separate database.

lib/testcase/test.js

+42-34
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1515
}) : function(o, v) {
1616
o["default"] = v;
1717
});
18-
var __importStar = (this && this.__importStar) || function (mod) {
19-
if (mod && mod.__esModule) return mod;
20-
var result = {};
21-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22-
__setModuleDefault(result, mod);
23-
return result;
24-
};
18+
var __importStar = (this && this.__importStar) || (function () {
19+
var ownKeys = function(o) {
20+
ownKeys = Object.getOwnPropertyNames || function (o) {
21+
var ar = [];
22+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23+
return ar;
24+
};
25+
return ownKeys(o);
26+
};
27+
return function (mod) {
28+
if (mod && mod.__esModule) return mod;
29+
var result = {};
30+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31+
__setModuleDefault(result, mod);
32+
return result;
33+
};
34+
})();
2535
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2636
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2737
return new (P || (P = Promise))(function (resolve, reject) {
@@ -32,8 +42,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3242
});
3343
};
3444
var __generator = (this && this.__generator) || function (thisArg, body) {
35-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
45+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
46+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
3747
function verb(n) { return function (v) { return step([n, v]); }; }
3848
function step(op) {
3949
if (f) throw new TypeError("Generator is already executing.");
@@ -62,7 +72,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6272
return (mod && mod.__esModule) ? mod : { "default": mod };
6373
};
6474
Object.defineProperty(exports, "__esModule", { value: true });
65-
exports.execDrushInTestSite = exports.expect = exports.test = void 0;
75+
exports.expect = exports.test = void 0;
76+
exports.execDrushInTestSite = execDrushInTestSite;
6677
var test_1 = require("@playwright/test");
6778
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_1.expect; } });
6879
var task_1 = require("../cli/task");
@@ -77,18 +88,18 @@ var drupal_test_id;
7788
* Set a simpletest cookie for routing the tests to a separate database.
7889
*/
7990
var test = test_1.test.extend({
80-
context: function (_a, use) {
81-
var context = _a.context, request = _a.request;
82-
return __awaiter(this, void 0, void 0, function () {
91+
context: function (_a, use_1) {
92+
return __awaiter(this, arguments, void 0, function (_b, use) {
8393
var id, install;
8494
var _this = this;
85-
return __generator(this, function (_b) {
86-
switch (_b.label) {
95+
var context = _b.context, request = _b.request;
96+
return __generator(this, function (_c) {
97+
switch (_c.label) {
8798
case 0:
8899
if (!process.env.PLAYWRIGHT_NO_TEST_ISOLATION) return [3 /*break*/, 2];
89100
return [4 /*yield*/, use(context)];
90101
case 1:
91-
_b.sent();
102+
_c.sent();
92103
return [2 /*return*/];
93104
case 2:
94105
id = Math.round(Math.random() * 1000000);
@@ -146,24 +157,22 @@ exports.test = test;
146157
/**
147158
* Attach the PHP error log to the test results.
148159
*/
149-
test.afterEach(function (_a, testInfo) {
150-
var page = _a.page;
151-
return __awaiter(void 0, void 0, void 0, function () {
152-
var logPath;
153-
return __generator(this, function (_b) {
154-
switch (_b.label) {
155-
case 0:
156-
logPath = '../../web/sites/simpletest/' + drupal_test_id + '/error.log';
157-
if (!fs.existsSync(logPath)) return [3 /*break*/, 2];
158-
return [4 /*yield*/, testInfo.attach('error.log', { path: logPath })];
159-
case 1:
160-
_b.sent();
161-
_b.label = 2;
162-
case 2: return [2 /*return*/];
163-
}
164-
});
160+
test.afterEach(function (_a, testInfo_1) { return __awaiter(void 0, [_a, testInfo_1], void 0, function (_b, testInfo) {
161+
var logPath;
162+
var page = _b.page;
163+
return __generator(this, function (_c) {
164+
switch (_c.label) {
165+
case 0:
166+
logPath = '../../web/sites/simpletest/' + drupal_test_id + '/error.log';
167+
if (!fs.existsSync(logPath)) return [3 /*break*/, 2];
168+
return [4 /*yield*/, testInfo.attach('error.log', { path: logPath })];
169+
case 1:
170+
_c.sent();
171+
_c.label = 2;
172+
case 2: return [2 /*return*/];
173+
}
165174
});
166-
});
175+
}); });
167176
/**
168177
* Run a Drush command in a test site.
169178
*
@@ -194,4 +203,3 @@ function execDrushInTestSite(command) {
194203
});
195204
});
196205
}
197-
exports.execDrushInTestSite = execDrushInTestSite;

lib/testcase/visualdiff.js

+46-50
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
99
});
1010
};
1111
var __generator = (this && this.__generator) || function (thisArg, body) {
12-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1414
function verb(n) { return function (v) { return step([n, v]); }; }
1515
function step(op) {
1616
if (f) throw new TypeError("Generator is already executing.");
@@ -36,59 +36,57 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
3636
}
3737
};
3838
Object.defineProperty(exports, "__esModule", { value: true });
39-
exports.VisualDiffTestCases = exports.defaultTestFunction = exports.defineVisualDiffConfig = void 0;
39+
exports.VisualDiffTestCases = void 0;
40+
exports.defineVisualDiffConfig = defineVisualDiffConfig;
41+
exports.defaultTestFunction = defaultTestFunction;
4042
var test_1 = require("@playwright/test");
4143
var util_1 = require("../util");
4244
function defineVisualDiffConfig(cases) {
4345
return new VisualDiffTestCases(cases);
4446
}
45-
exports.defineVisualDiffConfig = defineVisualDiffConfig;
4647
function defaultTestFunction(testCase, group) {
4748
var _this = this;
4849
// @ts-ignore
49-
return function (_a, testInfo) {
50-
var page = _a.page, context = _a.context;
51-
return __awaiter(_this, void 0, void 0, function () {
52-
var representativeUrl, path;
53-
return __generator(this, function (_b) {
54-
switch (_b.label) {
55-
case 0:
56-
// Log any errors to the Playwright console too.
57-
context.on('weberror', function (webError) { return console.log(webError.error()); });
50+
return function (_a, testInfo_1) { return __awaiter(_this, [_a, testInfo_1], void 0, function (_b, testInfo) {
51+
var representativeUrl, path;
52+
var page = _b.page, context = _b.context;
53+
return __generator(this, function (_c) {
54+
switch (_c.label) {
55+
case 0:
56+
// Log any errors to the Playwright console too.
57+
context.on('weberror', function (webError) { return console.log(webError.error()); });
58+
testInfo.annotations.push({
59+
type: 'Description',
60+
description: testCase.description,
61+
});
62+
representativeUrl = "";
63+
if (testCase.representativeUrl) {
64+
representativeUrl = testCase.representativeUrl;
65+
}
66+
else if (group.representativeUrl) {
67+
representativeUrl = group.representativeUrl;
68+
}
69+
if (representativeUrl) {
5870
testInfo.annotations.push({
59-
type: 'Description',
60-
description: testCase.description,
71+
type: 'Representative URL',
72+
description: representativeUrl,
6173
});
62-
representativeUrl = "";
63-
if (testCase.representativeUrl) {
64-
representativeUrl = testCase.representativeUrl;
65-
}
66-
else if (group.representativeUrl) {
67-
representativeUrl = group.representativeUrl;
68-
}
69-
if (representativeUrl) {
70-
testInfo.annotations.push({
71-
type: 'Representative URL',
72-
description: representativeUrl,
73-
});
74-
}
75-
path = testCase.path;
76-
if (group.pathPrefix) {
77-
path = group.pathPrefix + path;
78-
}
79-
return [4 /*yield*/, page.goto(path)];
80-
case 1:
81-
_b.sent();
82-
return [4 /*yield*/, (0, util_1.takeAccessibleScreenshot)(page, testInfo, { fullPage: true })];
83-
case 2:
84-
_b.sent();
85-
return [2 /*return*/];
86-
}
87-
});
74+
}
75+
path = testCase.path;
76+
if (group.pathPrefix) {
77+
path = group.pathPrefix + path;
78+
}
79+
return [4 /*yield*/, page.goto(path)];
80+
case 1:
81+
_c.sent();
82+
return [4 /*yield*/, (0, util_1.takeAccessibleScreenshot)(page, testInfo, { fullPage: true })];
83+
case 2:
84+
_c.sent();
85+
return [2 /*return*/];
86+
}
8887
});
89-
};
88+
}); };
9089
}
91-
exports.defaultTestFunction = defaultTestFunction;
9290
/**
9391
* Execute a set of visual diffs against groups of test cases.
9492
*/
@@ -112,14 +110,12 @@ var VisualDiffTestCases = /** @class */ (function () {
112110
var _this = this;
113111
if (typeof testCase.skip !== 'undefined' && (typeof testCase.skip.callback == 'undefined' || testCase.skip.callback(testCase))) {
114112
// eslint-disable-ext-line @typescript-eslint/no-unused-vars
115-
test_1.test.skip("".concat(testCase.name, ": ").concat(testCase.skip.reason, " <").concat(testCase.skip.willBeFixedIn, ">"), function (_a, testInfo) {
116-
var page = _a.page;
117-
return __awaiter(_this, void 0, void 0, function () {
118-
return __generator(this, function (_b) {
119-
return [2 /*return*/];
120-
});
113+
test_1.test.skip("".concat(testCase.name, ": ").concat(testCase.skip.reason, " <").concat(testCase.skip.willBeFixedIn, ">"), function (_a, testInfo_1) { return __awaiter(_this, [_a, testInfo_1], void 0, function (_b, testInfo) {
114+
var page = _b.page;
115+
return __generator(this, function (_c) {
116+
return [2 /*return*/];
121117
});
122-
});
118+
}); });
123119
}
124120
}
125121
this.config.groups.forEach(function (group) {

0 commit comments

Comments
 (0)