rss-feedmonitor/tests/alert-setup.spec.js

68 lines
2.2 KiB
JavaScript

import { test, expect } from '@playwright/test';
/**
* Test that documents the process of setting up a new Google Alert
*
* This test can be used as a reference for the alert setup process.
* To record a new version, use: npm run record:alert-setup
*
* Example query to use:
* site:reddit.com/r/techsupport "macbook" ("won't turn on" OR "dead" OR "no power" OR "won't boot")
*/
test('Document alert setup process', async ({ page }) => {
// Navigate to Google Alerts
await page.goto('https://www.google.com/alerts');
// Wait for the page to load
await page.waitForLoadState('networkidle');
// Example query - replace with actual query from docs
const exampleQuery = 'site:reddit.com/r/techsupport "macbook" ("won\'t turn on" OR "dead" OR "no power" OR "won\'t boot")';
// Find the search input and paste the query
// Note: The selector may need to be updated based on Google Alerts UI
const searchInput = page.locator('input[type="text"]').first();
await searchInput.fill(exampleQuery);
// Click "Show options" to expand settings
await page.getByText('Show options', { exact: false }).click();
// Configure alert settings
// How often: As-it-happens
await page.locator('select').first().selectOption('0'); // As-it-happens
// Sources: Automatic
await page.locator('select').nth(1).selectOption('automatic');
// Language: English
await page.locator('select').nth(2).selectOption('en');
// Region: Canada
await page.locator('select').nth(3).selectOption('ca');
// How many: All results
await page.locator('select').nth(4).selectOption('all');
// Deliver to: RSS feed
await page.getByText('RSS feed').click();
// Click "Create Alert"
await page.getByRole('button', { name: 'Create Alert' }).click();
// Wait for alert to be created
await page.waitForLoadState('networkidle');
// Click RSS icon to get feed URL
// Note: This selector may need adjustment based on actual UI
const rssIcon = page.locator('a[href*="feed"]').first();
await rssIcon.click();
// Get the RSS feed URL
const rssUrl = page.url();
console.log('RSS Feed URL:', rssUrl);
// Verify we have an RSS feed URL
expect(rssUrl).toContain('feed');
});