Skip to content

Commit

Permalink
adiitional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JewelTee committed Aug 19, 2024
1 parent 0bee0d2 commit b3c55c2
Show file tree
Hide file tree
Showing 22 changed files with 1,393 additions and 0 deletions.
62 changes: 62 additions & 0 deletions packages/playwright/sc-dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');
const { url } = require('inspector');


(async () => {
const screenshotsDir = path.join(__dirname, 'screenshots');
if (!fs.existsSync(screenshotsDir)) {
fs.mkdirSync(screenshotsDir);
}


const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();


// Capture console logs
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
// Capture page errors
page.on('pageerror', error => console.error('PAGE ERROR:', error));


const resolutions = [
{ width: 1920, height: 1080, name: 'desktop' },
{ width: 3440, height: 1440, name: 'big desktop screen' },
{ width: 1280, height: 800, name: 'tablet' },
{ width: 1366, height: 1024, name: 'iPad Pro'},
{ width: 375, height: 667, name: 'small mobile' },
{ width: 390, height: 844, name: 'Android mobile'},
{ width: 393, height: 852, name: 'iPhone'},
{ width: 430, height: 932, name: 'iPhone Pro Max'},
{ width: 1366, height: 768, name: 'laptop'},


];


const pages = [
{ url: 'https://packrat.world/',name: 'dashboard'},

];


for (const resolution of resolutions) {
await page.setViewportSize({ width: resolution.width, height: resolution.height });
for (const { url, name } of pages) {
try {
console.log(`Navigating to ${url} at ${resolution.name} resolution...`);
await page.goto(url, { waitUntil: 'networkidle' });
console.log(`Taking full-page screenshot of ${url} at ${resolution.name} resolution...`);
await page.screenshot({ path: path.join(screenshotsDir, `${name}-${resolution.name}.png`), fullPage: false });
} catch (error) {
console.error(`Failed to navigate to ${url}:`, error);
}
}
}


console.log('Closing browser...');
await browser.close();
})();
89 changes: 89 additions & 0 deletions packages/playwright/sc-destination-query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');


(async () => {
// Directory to save screenshots
const screenshotsDir = path.join(__dirname, 'screenshots');
if (!fs.existsSync(screenshotsDir)) {
fs.mkdirSync(screenshotsDir);
}


// Launch browser
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();


// Capture console logs and page errors
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('pageerror', error => console.error('PAGE ERROR:', error));


// Define resolutions and pages
const resolutions = [

{ width: 1920, height: 1080, name: 'desktop' },
{ width: 3440, height: 1440, name: 'big desktop screen' },
{ width: 1280, height: 800, name: 'tablet' },
{ width: 1366, height: 1024, name: 'iPad Pro'},
{ width: 375, height: 667, name: 'small mobile' },
{ width: 390, height: 844, name: 'Android mobile'},
{ width: 393, height: 852, name: 'iPhone'},
{ width: 430, height: 932, name: 'iPhone Pro Max'},
{ width: 1366, height: 768, name: 'laptop'},

];


const pages = [
{ url: 'https://packrat.world/destination/query?osmType=R&osmId=207359&name=Los%20Angeles', name: 'destination-query'},

// Add more pages as needed
];


// Function to perform login
const login = async () => {
console.log('Navigating to login page...');
await page.goto('https://packrat.world/sign-in', { waitUntil: 'networkidle' });


console.log('Filling login form...');
await page.locator('input[type="email"]').fill('[email protected]'); // Replace with actual username field selector and value
await page.locator('input[type="password"]').fill('12345678'); // Replace with actual password field selector and value
await page.getByRole('button', { name: 'Sign In' }).click();// Replace with actual login button selector
await page.getByPlaceholder('Search by park, city, or trail').click();
await page.getByPlaceholder('Search by park, city, or trail').fill('Los Angeles');
await page.getByText('Los Angelescity').click();
await page.goto('https://packrat.world/destination/query?osmType=R&osmId=207359&name=Los%20Angeles');

};


// Perform login
await login();


// Take screenshots for each resolution and page
for (const resolution of resolutions) {
await page.setViewportSize({ width: resolution.width, height: resolution.height });
for (const { url, name } of pages) {
try {
console.log(`Navigating to ${url} at ${resolution.name} resolution...`);
await page.goto(url, { waitUntil: 'networkidle' });

await page.screenshot({ path: path.join(screenshotsDir, `${name}-${resolution.name}.png`), fullPage: true});
} catch (error) {
console.error(`Failed to navigate to ${url}:`, error);
}
}
}


console.log('Closing browser...');
await browser.close();
})();


93 changes: 93 additions & 0 deletions packages/playwright/sc-feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');


(async () => {
// Directory to save screenshots
const screenshotsDir = path.join(__dirname, 'screenshots');
if (!fs.existsSync(screenshotsDir)) {
fs.mkdirSync(screenshotsDir);
}


// Launch browser
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();


// Capture console logs and page errors
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('pageerror', error => console.error('PAGE ERROR:', error));


// Define resolutions and pages
const resolutions = [

{ width: 1920, height: 1080, name: 'desktop' },
{ width: 3440, height: 1440, name: 'big desktop screen' },
{ width: 1280, height: 800, name: 'tablet' },
{ width: 1366, height: 1024, name: 'iPad Pro'},
{ width: 375, height: 667, name: 'small mobile' },
{ width: 390, height: 844, name: 'Android mobile'},
{ width: 393, height: 852, name: 'iPhone'},
{ width: 430, height: 932, name: 'iPhone Pro Max'},
{ width: 1366, height: 768, name: 'laptop'},

];


const pages = [
{ url: 'https://packrat.world/feed', name: 'feed'},

// Add more pages as needed
];


// Function to perform login
const login = async () => {
console.log('Navigating to login page...');
await page.goto('https://packrat.world/sign-in', { waitUntil: 'networkidle' });


console.log('Filling login form...');
await page.locator('input[type="email"]').fill('[email protected]'); // Replace with actual username field selector and value
await page.locator('input[type="password"]').fill('12345678'); // Replace with actual password field selector and value
await page.getByRole('button', { name: 'Sign In' }).click();// Replace with actual login button selector
await page.getByRole('button', { name: 'Menu' }).hover();
await page.getByRole('button', { name: 'Profile' }).click();
await page.getByRole('button', { name: '󱀁 Feed' }).click();
await page.goto('https://packrat.world/feed');





};


// Perform login
await login();


// Take screenshots for each resolution and page
for (const resolution of resolutions) {
await page.setViewportSize({ width: resolution.width, height: resolution.height });
for (const { url, name } of pages) {
try {
console.log(`Navigating to ${url} at ${resolution.name} resolution...`);
await page.goto(url, { waitUntil: 'networkidle' });

await page.screenshot({ path: path.join(screenshotsDir, `${name}-${resolution.name}.png`), fullPage: false});
} catch (error) {
console.error(`Failed to navigate to ${url}:`, error);
}
}
}


console.log('Closing browser...');
await browser.close();
})();


90 changes: 90 additions & 0 deletions packages/playwright/sc-items-fullscreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');


(async () => {
// Directory to save screenshots
const screenshotsDir = path.join(__dirname, 'screenshots');
if (!fs.existsSync(screenshotsDir)) {
fs.mkdirSync(screenshotsDir);
}


// Launch browser
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();


// Capture console logs and page errors
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('pageerror', error => console.error('PAGE ERROR:', error));


// Define resolutions and pages
const resolutions = [

{ width: 1280, height: 800, name: 'tablet' },
{ width: 1366, height: 1024, name: 'iPad Pro'},
{ width: 375, height: 667, name: 'small mobile' },
{ width: 390, height: 844, name: 'Android mobile'},
{ width: 393, height: 852, name: 'iPhone'},
{ width: 430, height: 932, name: 'iPhone Pro Max'},

];


const pages = [
{ url: 'https://packrat.world/items', name: 'items-page (full-screen)'},

// Add more pages as needed
];


// Function to perform login
const login = async () => {
console.log('Navigating to login page...');
await page.goto('https://packrat.world/sign-in', { waitUntil: 'networkidle' });


console.log('Filling login form...');
await page.locator('input[type="email"]').fill('[email protected]'); // Replace with actual username field selector and value
await page.locator('input[type="password"]').fill('12345678'); // Replace with actual password field selector and value
await page.getByRole('button', { name: 'Sign In' }).click();// Replace with actual login button selector
await page.getByRole('button', { name: 'Menu' }).hover();
await page.getByRole('button', { name: 'Profile' }).click();
await page.locator('div').filter({ hasText: /^Items$/ }).first().click()
await page.goto('https://packrat.world/items');





};


// Perform login
await login();


// Take screenshots for each resolution and page
for (const resolution of resolutions) {
await page.setViewportSize({ width: resolution.width, height: resolution.height });
for (const { url, name } of pages) {
try {
console.log(`Navigating to ${url} at ${resolution.name} resolution...`);
await page.goto(url, { waitUntil: 'networkidle' });

await page.screenshot({ path: path.join(screenshotsDir, `${name}-${resolution.name}.png`), fullPage: true});
} catch (error) {
console.error(`Failed to navigate to ${url}:`, error);
}
}
}


console.log('Closing browser...');
await browser.close();
})();


Loading

0 comments on commit b3c55c2

Please sign in to comment.