[e2e] Fix some of the plot tests (#5158)

* small general fixes

* Rename testsuite and use snapshot alias

* remove only

* Add some more determinism by waiting for Save Banner

* rename

* reduce time to fail

* add determinism

* log the process

Co-authored-by: unlikelyzero <jchill2@gmail.com>
This commit is contained in:
John Hill 2022-05-04 09:15:39 -07:00 committed by GitHub
parent c089a4760d
commit ab4d0dd37f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 31 deletions

View File

@ -6,9 +6,9 @@ const { devices } = require('@playwright/test');
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
retries: 2,
retries: 1,
testDir: 'tests',
timeout: 90 * 1000,
timeout: 60 * 1000,
webServer: {
command: 'npm run start',
port: 8080,

View File

@ -98,6 +98,7 @@ test.describe('Example Imagery', () => {
await page.mouse.move(imageCenterX, imageCenterY);
// Pan Imagery Hints
console.log(process.platform);
const expectedAltText = process.platform === 'linux' ? 'Ctrl+Alt drag to pan' : 'Alt drag to pan';
const imageryHintsText = await page.locator('.c-imagery__hints').innerText();
expect(expectedAltText).toEqual(imageryHintsText);

View File

@ -21,7 +21,7 @@
*****************************************************************************/
/*
Test for plot autoscale.
Testsuite for plot autoscale.
*/
const { test: _test, expect } = require('@playwright/test');
@ -47,7 +47,7 @@ test.use({
});
test.describe('ExportAsJSON', () => {
test('autoscale off causes no error from undefined user range', async ({ page }) => {
test('User can set autoscale with a valid range @snapshot', async ({ page }) => {
await page.goto('/', { waitUntil: 'networkidle' });
await setTimeRange(page);
@ -68,14 +68,6 @@ test.describe('ExportAsJSON', () => {
.then(shot => expect(shot).toMatchSnapshot('autoscale-canvas-prepan.png', { maxDiffPixels: 40 }))
]);
let errorCount = 0;
function onError() {
errorCount++;
}
page.on('pageerror', onError);
await page.keyboard.down('Alt');
await canvas.dragTo(canvas, {
@ -91,12 +83,6 @@ test.describe('ExportAsJSON', () => {
await page.keyboard.up('Alt');
page.off('pageerror', onError);
// There would have been an error at this point. So if there isn't, then
// we fixed it.
expect(errorCount).toBe(0);
// Ensure the drag worked.
await Promise.all([
testYTicks(page, ['0.00', '0.50', '1.00', '1.50', '2.00']),
@ -134,9 +120,12 @@ async function createSinewaveOverlayPlot(page) {
// add overlay plot with defaults
await page.locator('li:has-text("Overlay Plot")').click();
await Promise.all([
page.waitForNavigation(/*{ url: 'http://localhost:8080/#/browse/mine/a9268c6f-45cc-4bcd-a6a0-50ac4036e396?tc.mode=fixed&tc.startBound=1649305424163&tc.endBound=1649307224163&tc.timeSystem=utc&view=plot-overlay' }*/),
page.locator('text=OK').click()
page.waitForNavigation(),
//Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// save (exit edit mode)
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
@ -148,14 +137,17 @@ async function createSinewaveOverlayPlot(page) {
// add sine wave generator with defaults
await page.locator('li:has-text("Sine Wave Generator")').click();
await Promise.all([
page.waitForNavigation(/*{ url: 'http://localhost:8080/#/browse/mine/a9268c6f-45cc-4bcd-a6a0-50ac4036e396/5cfa5c69-17bc-4a99-9545-4da8125380c5?tc.mode=fixed&tc.startBound=1649305424163&tc.endBound=1649307224163&tc.timeSystem=utc&view=plot-single' }*/),
page.locator('text=OK').click()
page.waitForNavigation(),
//Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// focus the overlay plot
await page.locator('text=Open MCT My Items >> span').nth(3).click();
await Promise.all([
page.waitForNavigation(/*{ url: 'http://localhost:8080/#/browse/mine/a9268c6f-45cc-4bcd-a6a0-50ac4036e396?tc.mode=fixed&tc.startBound=1649305424163&tc.endBound=1649307224163&tc.timeSystem=utc&view=plot-overlay' }*/),
page.waitForNavigation(),
page.locator('text=Unnamed Overlay Plot').first().click()
]);
}

View File

@ -27,7 +27,7 @@ Tests to verify log plot functionality.
const { test, expect } = require('@playwright/test');
test.describe('Log plot tests', () => {
test.only('Can create a log plot.', async ({ page }) => {
test('Can create a log plot', async ({ page }) => {
await makeOverlayPlot(page);
await testRegularTicks(page);
await enableEditMode(page);
@ -49,7 +49,7 @@ test.describe('Log plot tests', () => {
await testLogPlotPixels(page);
});
test.only('Verify that log mode option is reflected in import/export JSON', async ({ page }) => {
test('Verify that log mode option is reflected in import/export JSON', async ({ page }) => {
await makeOverlayPlot(page);
await enableEditMode(page);
await enableLogMode(page);
@ -88,9 +88,13 @@ async function makeOverlayPlot(page) {
await page.locator('button.c-create-button').click();
await page.locator('li:has-text("Overlay Plot")').click();
await Promise.all([
page.waitForNavigation(/*{ url: 'http://localhost:8080/#/browse/mine/8caf7072-535b-4af6-8394-edd86e3ea35f?tc.mode=fixed&tc.startBound=1648590633191&tc.endBound=1648592433191&tc.timeSystem=utc&view=plot-overlay' }*/),
page.locator('text=OK').click()
page.waitForNavigation(),
page.locator('text=OK').click(),
//Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// save the overlay plot
@ -116,15 +120,19 @@ async function makeOverlayPlot(page) {
// Click OK to make generator
await Promise.all([
page.waitForNavigation(/*{ url: 'http://localhost:8080/#/browse/mine/8caf7072-535b-4af6-8394-edd86e3ea35f/6e58b26a-8a73-4df6-b3a6-918decc0bbfa?tc.mode=fixed&tc.startBound=1648590633191&tc.endBound=1648592433191&tc.timeSystem=utc&view=plot-single' }*/),
page.locator('text=OK').click()
page.waitForNavigation(),
page.locator('text=OK').click(),
//Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// click on overlay plot
await page.locator('text=Open MCT My Items >> span').nth(3).click();
await Promise.all([
page.waitForNavigation(/*{ url: 'http://localhost:8080/#/browse/mine/8caf7072-535b-4af6-8394-edd86e3ea35f?tc.mode=fixed&tc.startBound=1648590633191&tc.endBound=1648592433191&tc.timeSystem=utc&view=plot-overlay' }*/),
page.waitForNavigation(),
page.locator('text=Unnamed Overlay Plot').first().click()
]);
}
@ -210,7 +218,15 @@ async function disableLogMode(page) {
async function saveOverlayPlot(page) {
// save overlay plot
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
await page.locator('text=Save and Finish Editing').click();
await Promise.all([
page.waitForNavigation(),
page.locator('text=Save and Finish Editing').click(),
//Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message')
]);
//Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message');
}
/**