test improvements

This commit is contained in:
Skyler Lehmkuhl
2025-11-08 10:03:51 -05:00
parent 7ec69ce950
commit a1e2368468
4 changed files with 354 additions and 11 deletions
+17 -5
View File
@@ -9,11 +9,23 @@
export async function waitForAppReady(timeout = 5000) {
await browser.waitForApp();
// Check for "Create New File" dialog and click Create if present
const createButton = await browser.$('button*=Create');
if (await createButton.isExisting()) {
await createButton.click();
await browser.pause(500); // Wait for dialog to close
// Check for "Animation" card on start screen and click it if present
// The card has a label div with text "Animation"
const animationCard = await browser.$('.focus-card-label*=Animation');
if (await animationCard.isExisting()) {
// Click the parent focus-card element
const card = await animationCard.parentElement();
await card.waitForClickable({ timeout: 2000 });
await card.click();
await browser.pause(1000); // Wait longer for animation view to load
} else {
// Legacy: Check for "Create New File" dialog and click Create if present
const createButton = await browser.$('button*=Create');
if (await createButton.isExisting()) {
await createButton.waitForClickable({ timeout: 2000 });
await createButton.click();
await browser.pause(500); // Wait for dialog to close
}
}
// Wait for the main canvas to be present
+15 -6
View File
@@ -31,17 +31,21 @@ export async function dragCanvas(fromX, fromY, toX, toY) {
* @param {number} width - Rectangle width
* @param {number} height - Rectangle height
* @param {boolean} filled - Whether to fill the shape (default: true)
* @param {string} color - Fill color in hex format (e.g., '#ff0000')
*/
export async function drawRectangle(x, y, width, height, filled = true) {
export async function drawRectangle(x, y, width, height, filled = true, color = null) {
// Select the rectangle tool
await selectTool('rectangle');
// Set fill option
await browser.execute((filled) => {
// Set fill option and color if provided
await browser.execute((filled, color) => {
if (window.context) {
window.context.fillShape = filled;
if (color) {
window.context.fillStyle = color;
}
}
}, filled);
}, filled, color);
// Draw by dragging from start to end point
await dragCanvas(x, y, x + width, y + height);
@@ -192,14 +196,19 @@ export async function doubleClickCanvas(x, y) {
export async function setPlayheadTime(time) {
await browser.execute(function(timeValue) {
if (window.context && window.context.activeObject) {
// Set time on both the active object and timeline state
window.context.activeObject.currentTime = timeValue;
// Update timeline widget if it exists
if (window.context.timelineWidget && window.context.timelineWidget.timelineState) {
window.context.timelineWidget.timelineState.currentTime = timeValue;
}
// Trigger timeline redraw to show updated playhead position
if (window.context.timelineWidget && window.context.timelineWidget.requestRedraw) {
window.context.timelineWidget.requestRedraw();
}
}
}, time);
await browser.pause(100);
await browser.pause(200);
}
/**
+68
View File
@@ -0,0 +1,68 @@
/**
* Manual testing utilities for user-in-the-loop verification
* These helpers pause execution and wait for user confirmation
*/
/**
* Pause and wait for user to verify something visually with a confirm dialog
* @param {string} message - What the user should verify
* @param {boolean} waitForConfirm - If true, show confirm dialog and wait for user input
* @throws {Error} If user clicks Cancel to indicate verification failed
*/
export async function verifyManually(message, waitForConfirm = true) {
console.log('\n=== MANUAL VERIFICATION ===');
console.log(message);
console.log('===========================\n');
if (waitForConfirm) {
// Show a confirm dialog in the browser and wait for user response
const result = await browser.execute(function(msg) {
return confirm(msg);
}, message);
if (!result) {
console.log('User clicked Cancel - verification failed');
throw new Error('Manual verification failed: User clicked Cancel');
} else {
console.log('User clicked OK - verification passed');
}
return result;
} else {
// Just pause for observation
await browser.pause(3000);
return true;
}
}
/**
* Add a visual marker/annotation to describe what should be visible
* @param {string} description - Description of current state
*/
export async function logStep(description) {
console.log(`\n>>> STEP: ${description}`);
}
/**
* Extended pause with a description of what's happening
* @param {string} action - What action just occurred
* @param {number} pauseTime - How long to pause
*/
export async function pauseAndDescribe(action, pauseTime = 2000) {
console.log(`>>> ${action}`);
await browser.pause(pauseTime);
}
/**
* Ask user a yes/no question via confirm dialog
* @param {string} question - Question to ask the user
* @returns {Promise<boolean>} True if user clicked OK, false if Cancel
*/
export async function askUser(question) {
console.log(`\n>>> QUESTION: ${question}`);
const result = await browser.execute(function(msg) {
return confirm(msg);
}, question);
console.log(`User answered: ${result ? 'YES (OK)' : 'NO (Cancel)'}`);
return result;
}