Skip to content

Commit b46d850

Browse files
authored
[Autofill password import] Misc fixes (#1184)
* fix: supported path * feat: add a more resilient animation * fixme: hardcode some offsets * chore: lint-fix * fix: use calc * feat: use overlay to style elements * style: lint fix * chore: add some comments * fix: remove offset * chore: PR comments * test: update for expecting overlay * fix: domcontentloaded event instead of timeout * feat: refactor for scroll * refactor: add state * refactor: store domloaded promise * fix: remove overlay early * fix: account for slow inejction
1 parent caeede3 commit b46d850

File tree

7 files changed

+355
-77
lines changed

7 files changed

+355
-77
lines changed

injected/integration-test/autofill-password-import.spec.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
import { test } from '@playwright/test';
1+
import { test, expect } from '@playwright/test';
22
import { readFileSync } from 'fs';
33
import { mockAndroidMessaging, wrapWebkitScripts } from '@duckduckgo/messaging/lib/test-utils.mjs';
44
import { perPlatform } from './type-helpers.mjs';
5+
import { OVERLAY_ID } from '../src/features/autofill-password-import';
56

67
test('Password import feature', async ({ page }, testInfo) => {
78
const passwordImportFeature = AutofillPasswordImportSpec.create(page, testInfo);
89
await passwordImportFeature.enabled();
910
await passwordImportFeature.navigate();
10-
const didAnimatePasswordOptions = passwordImportFeature.waitForAnimation('a[aria-label="Password options"]');
1111
await passwordImportFeature.clickOnElement('Home page');
12-
await didAnimatePasswordOptions;
12+
await passwordImportFeature.waitForAnimation();
1313

14-
const didAnimateSignin = passwordImportFeature.waitForAnimation('a[aria-label="Sign in"]');
1514
await passwordImportFeature.clickOnElement('Signin page');
16-
await didAnimateSignin;
15+
await passwordImportFeature.waitForAnimation();
1716

18-
const didAnimateExport = passwordImportFeature.waitForAnimation('button[aria-label="Export"]');
1917
await passwordImportFeature.clickOnElement('Export page');
20-
await didAnimateExport;
18+
await passwordImportFeature.waitForAnimation();
19+
20+
// Test unsupported path
21+
await passwordImportFeature.clickOnElement('Unsupported page');
22+
const overlay = page.locator(`#${OVERLAY_ID}`);
23+
await expect(overlay).not.toBeVisible();
2124
});
2225

2326
export class AutofillPasswordImportSpec {
@@ -91,17 +94,10 @@ export class AutofillPasswordImportSpec {
9194

9295
/**
9396
* Helper to assert that an element is animating
94-
* @param {string} selector
9597
*/
96-
async waitForAnimation(selector) {
97-
const locator = this.page.locator(selector);
98-
return await locator.evaluate((el) => {
99-
if (el != null) {
100-
return el.getAnimations().some((animation) => animation.playState === 'running');
101-
} else {
102-
return false;
103-
}
104-
}, selector);
98+
async waitForAnimation() {
99+
const locator = this.page.locator(`#${OVERLAY_ID}`);
100+
await expect(locator).toBeVisible();
105101
}
106102

107103
/**

injected/integration-test/test-pages/autofill-password-import/index.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@
3232
<a aria-label="Sign in">Sign in</a>
3333
</div>
3434
<div id="home" class="page">
35-
<a aria-label="Password options">Password options</a>
35+
<a aria-label="Password options" style="border-radius: 100%;">PO</a>
3636
</div>
3737
<div id="options" class="page">
38-
<button aria-label="Export">Export</button>
38+
<button aria-label="Export" style="border-radius: 100%;">EP</button>
39+
</div>
40+
<div id="unsupported" class="page">
41+
<button aria-label="Unsupported">Unsupported path</button>
3942
</div>
4043

4144
<script>
4245
const routes = {
4346
'/intro': document.getElementById('intro'),
4447
'/': document.getElementById('home'),
45-
'/options': document.getElementById('options')
48+
'/options': document.getElementById('options'),
49+
'/unsupported': document.getElementById('unsupported'),
4650
};
4751

4852
function navigate(path) {
@@ -68,6 +72,7 @@
6872
<button onclick="navigate('/intro')">Signin page</button>
6973
<button onclick="navigate('/')">Home page</button>
7074
<button onclick="navigate('/options')">Export page</button>
75+
<button onclick="navigate('/unsupported')">Unsupported page</button>
7176
</nav>
7277
`);
7378
</script>

0 commit comments

Comments
 (0)