test(portal): exercise live-style report buttons and orange markers
This commit is contained in:
1 parent
9d6e0b982e
commit
d944cb0afe
1 file changed
+7
-3
@@ -70,7 +70,7 @@ try {
|
|||||||
const duration = 30 * 86400000;
|
const duration = 30 * 86400000;
|
||||||
const staffCode = randomBytes(24).toString('hex');
|
const staffCode = randomBytes(24).toString('hex');
|
||||||
const managementCode = randomBytes(24).toString('hex');
|
const managementCode = randomBytes(24).toString('hex');
|
||||||
const styledFixture = '<section><h2>Synthetic Directory</h2><h3>Operational reports</h3><p><a class="hs-button arbitrary-legacy-class" style="position:fixed" onclick="window.portalUnsafe=true" href="https://example.invalid/report">Synthetic report</a></p><ul><li>Synthetic list item</li></ul><table><caption>Fixture directory</caption><thead><tr><th scope="col">Role</th><th scope="col">Contact</th></tr></thead><tbody><tr><td>Fixture role</td><td><a href="mailto:fixture@example.invalid">Fixture email</a></td></tr></tbody></table><p><a style="background-color:#ffbd59" href="https://example.invalid/second">Second fixture report</a></p><a href="javascript:alert(1)">Unsafe destination</a><iframe src="https://example.invalid/frame"></iframe><form action="https://example.invalid/post"><input></form></section>';
|
const styledFixture = '<section><h2>Synthetic Directory</h2><h3>Operational reports</h3><p><a class="hs-button arbitrary-legacy-class" style="position:fixed" onclick="window.portalUnsafe=true" href="https://example.invalid/report">Synthetic report</a></p><ul><li>Synthetic list item</li></ul><table><caption>Fixture directory</caption><thead><tr><th scope="col">Role</th><th scope="col">Contact</th></tr></thead><tbody><tr><td>Fixture role</td><td><a href="mailto:fixture@example.invalid">Fixture email</a></td></tr></tbody></table><p><a style="background-color:#ffbd59" href="https://example.invalid/second">Second fixture report</a></p><p><a class="unrecognized-report-legacy" href="https://example.invalid/third">Operations Monthly Lineup Report - PM</a></p><a href="javascript:alert(1)">Unsafe destination</a><iframe src="https://example.invalid/frame"></iframe><form action="https://example.invalid/post"><input></form></section>';
|
||||||
const payload = { alg: portalAlgorithm, streams: [
|
const payload = { alg: portalAlgorithm, streams: [
|
||||||
await encryptPortalStream('fixture-staff', '<h2>Synthetic Staff</h2><p>Staff fixture only</p><a href="https://example.invalid/document">Synthetic resource</a><script>window.portalUnsafe=true</script><img src="https://example.invalid/image">' + styledFixture, staffCode),
|
await encryptPortalStream('fixture-staff', '<h2>Synthetic Staff</h2><p>Staff fixture only</p><a href="https://example.invalid/document">Synthetic resource</a><script>window.portalUnsafe=true</script><img src="https://example.invalid/image">' + styledFixture, staffCode),
|
||||||
await encryptPortalStream('fixture-management', '<h2>Synthetic Management</h2><p>Management fixture only</p>' + styledFixture, managementCode),
|
await encryptPortalStream('fixture-management', '<h2>Synthetic Management</h2><p>Management fixture only</p>' + styledFixture, managementCode),
|
||||||
@@ -333,12 +333,16 @@ try {
|
|||||||
assert.equal(await input.inputValue(), '');
|
assert.equal(await input.inputValue(), '');
|
||||||
const checkPresentation = async () => {
|
const checkPresentation = async () => {
|
||||||
const content = p.locator('[data-portal-content]');
|
const content = p.locator('[data-portal-content]');
|
||||||
assert.equal(await content.locator('.portal-resource-button').count(), 2);
|
assert.equal(await content.locator('.portal-resource-button').count(), 3);
|
||||||
assert.equal(await content.locator('[style], [onclick], .arbitrary-legacy-class, iframe, form, input').count(), 0);
|
assert.equal(await content.locator('[style], [onclick], .arbitrary-legacy-class, .unrecognized-report-legacy, iframe, form, input').count(), 0);
|
||||||
assert.equal(await content.locator('a[href^="javascript:"]').count(), 0);
|
assert.equal(await content.locator('a[href^="javascript:"]').count(), 0);
|
||||||
assert.equal(await content.locator('th[scope="col"]').count(), 2);
|
assert.equal(await content.locator('th[scope="col"]').count(), 2);
|
||||||
const button = content.locator('.portal-resource-button').first();
|
const button = content.locator('.portal-resource-button').first();
|
||||||
assert.equal(await button.evaluate(e => getComputedStyle(e).backgroundColor), 'rgb(255, 189, 89)');
|
assert.equal(await button.evaluate(e => getComputedStyle(e).backgroundColor), 'rgb(255, 189, 89)');
|
||||||
|
const legacyReport = content.getByRole('link', { name: 'Operations Monthly Lineup Report - PM' });
|
||||||
|
assert.equal(await legacyReport.getAttribute('class'), 'portal-resource-button');
|
||||||
|
assert.equal(await legacyReport.evaluate(e => getComputedStyle(e).backgroundColor), 'rgb(255, 189, 89)');
|
||||||
|
assert.equal(await content.locator('li').first().evaluate(e => getComputedStyle(e, '::marker').color), 'rgb(255, 189, 89)');
|
||||||
assert.equal(await content.locator('h2').first().evaluate(e => getComputedStyle(e).color), 'rgb(37, 64, 128)');
|
assert.equal(await content.locator('h2').first().evaluate(e => getComputedStyle(e).color), 'rgb(37, 64, 128)');
|
||||||
assert.ok(await content.locator('h2').first().evaluate(e => parseFloat(getComputedStyle(e).fontSize) >= 28));
|
assert.ok(await content.locator('h2').first().evaluate(e => parseFloat(getComputedStyle(e).fontSize) >= 28));
|
||||||
assert.equal(await content.locator('.portal-contact-link').evaluate(e => getComputedStyle(e).color), 'rgb(169, 70, 0)');
|
assert.equal(await content.locator('.portal-contact-link').evaluate(e => getComputedStyle(e).color), 'rgb(169, 70, 0)');
|
||||||
|
|||||||
Reference in new issue
Block a user