Skip to content

Commit effe0b0

Browse files
committed
feat: Add share dialog with QR code and support auto-subscriptions
Introduces a new share dialog with QR code generation for saved searches. Also adds handling for a `subscribe=true` URL parameter that prompts users to log in if needed, or automatically opens the subscription dialog.
1 parent 407ed46 commit effe0b0

22 files changed

Lines changed: 824 additions & 53 deletions
8.65 KB
Loading
8.33 KB
Loading
9.66 KB
Loading
11.3 KB
Loading
9.87 KB
Loading
11.4 KB
Loading

e2e/tests/overview-page.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023 Google LLC
2+
* Copyright 2023 Google LLC.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

e2e/tests/saved-searches.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ function expectUrlsEqual(actualUrlStr: string, expectedUrlStr: string) {
3838
const USER1 = {
3939
username: 'test user 1',
4040
userID: 'abcdedf1234567890',
41-
};
41+
} as const;
4242
const USER2 = {
4343
username: 'test user 2',
4444
userID: 'abcdedf1234567891',
45-
};
45+
} as const;
4646

4747
const USER1_SEARCH1 = {
4848
id: '74bdb85f-59d3-43b0-8061-20d5818e8c97',
@@ -77,7 +77,7 @@ const saveButtonLocator = (page: Page) =>
7777
.getByTestId('saved-search-save-button')
7878
.getByRole('button', {name: 'Save'});
7979
const shareButtonLocator = (page: Page) =>
80-
controlsLocator(page).getByLabel('Copy', {exact: true});
80+
controlsLocator(page).getByLabel('Share', {exact: true});
8181
const bookmarkEmptyIconLocator = (page: Page) =>
8282
controlsLocator(page).getByRole('button', {name: 'Bookmark', exact: true});
8383
const bookmarkFilledIconLocator = (page: Page) =>
@@ -158,7 +158,9 @@ test.describe('Saved Searches on Overview Page', () => {
158158

159159
// 5. Verify dialog closes and URL updates with q=saved:ID
160160
await expect(editorDialogLocator(page)).not.toBeVisible();
161-
await page.waitForURL(url => url.searchParams.get('q')?.includes('saved:'));
161+
await page.waitForURL(
162+
url => url.searchParams.get('q')?.includes('saved:') ?? false,
163+
);
162164
const qParam = new URL(page.url()).searchParams.get('q');
163165
const searchId = qParam?.split(':')[1];
164166
expect(searchId).toBeTruthy();
@@ -404,11 +406,19 @@ test.describe('Saved Searches on Overview Page', () => {
404406
// Click the share icon
405407
await shareButtonLocator(page).click();
406408

409+
// Wait for the share dialog to appear
410+
const shareDialog = page.locator('webstatus-saved-search-share-dialog');
411+
const dialog = shareDialog.locator('sl-dialog');
412+
await expect(dialog).toBeVisible();
413+
414+
// Click the "Copy link" button inside the dialog
415+
await dialog.locator('sl-button[variant="primary"]').click();
416+
407417
// Verify clipboard content
408418
const clipboardText = await page.evaluate(() =>
409419
navigator.clipboard.readText(),
410420
);
411-
expectUrlsEqual(clipboardText, page.url());
421+
expectUrlsEqual(clipboardText, `${page.url()}&subscribe=true`);
412422
});
413423

414424
test('Edit dialog opens automatically with edit_saved_search=true URL parameter', async ({
@@ -468,7 +478,9 @@ test.describe('Saved Searches on Overview Page', () => {
468478
await editorNameInputLocator(page).fill('My Firefox Search');
469479
await editorSubmitButtonLocator(page).click();
470480
await expect(editorDialogLocator(page)).not.toBeVisible(); // Should close now
471-
await page.waitForURL(url => url.searchParams.get('q')?.includes('saved:'));
481+
await page.waitForURL(
482+
url => url.searchParams.get('q')?.includes('saved:') ?? false,
483+
);
472484
});
473485

474486
test.describe('Subscriptions', () => {

e2e/tests/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export async function loginAsUser(
202202
const popupPromise = page.waitForEvent('popup');
203203
await page.goto('http://localhost:5555/');
204204
await waitForSidebarLoaded(page);
205-
await page.getByText('Log in').click();
205+
await page.getByRole('banner').getByText('Log in').click();
206206
const popup = await popupPromise;
207207

208208
await popup.waitForLoadState();
Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)