diff --git a/Makefile b/Makefile index 5f74e368..ad370f14 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -.PHONY: all clone-quickstart setup-quickstart setup-openmct-yamcs sanity-test build-example test-getopensource test-e2e clean +.PHONY: all clone-quickstart install-quickstart start-quickstart install-openmct-yamcs sanity-test build-example test-getopensource test-e2e clean -all: clone-quickstart setup-quickstart setup-openmct-yamcs sanity-test build-example test-getopensource test-e2e +all: clone-quickstart install-quickstart install-openmct-yamcs sanity-test build-example test-getopensource test-e2e clone-quickstart: @echo "Running target: clone-quickstart" @@ -11,12 +11,22 @@ clone-quickstart: echo "Directory 'quickstart' already exists."; \ fi -setup-quickstart: - @echo "Running target: setup-quickstart" - cd quickstart/docker && make wait-for-sent +install-quickstart: + @echo "Running target: install-quickstart" + @cd quickstart/docker && $(MAKE) wait-for-sent -setup-openmct-yamcs: - @echo "Running target: setup-openmct-yamcs" +start-quickstart: + @echo "Running target: start-quickstart" + @cd quickstart/docker && $(MAKE) all + +restart-quickstart: + @echo "Running target: reset-quickstart" + @cd quickstart/docker && $(MAKE) yamcs-down + @cd quickstart/docker && $(MAKE) simulator-down + @cd quickstart/docker && $(MAKE) all + +install-openmct-yamcs: + @echo "Running target: install-openmct-yamcs" npm install sanity-test: @@ -35,12 +45,9 @@ build-example: npm run build:example:master || { echo "Failed to run build:example:master"; exit 1; }; \ fi -test-getopensource: - @echo "Running target: test-getopensource" - npm run test:getopensource - test-e2e: @echo "Running target: test-e2e" + npm run test:getopensource npm run test:e2e:quickstart:local clean: diff --git a/package.json b/package.json index 29b7c982..3095a00d 100644 --- a/package.json +++ b/package.json @@ -22,16 +22,16 @@ "build:example": "npm install openmct@unstable --no-save", "build:example:master": "npm install nasa/openmct#master --no-save", "build:example:current": "npm install nasa/openmct#$(git rev-parse --abbrev-ref HEAD) --no-save --verbose", - "postbuild:example": "node check-optional-dependencies.js", - "start": "npx webpack serve --config ./.webpack/webpack.dev.js", - "start:coverage": "npx webpack serve --config ./.webpack/webpack.coverage.js", + "postbuild:example": "node check-optional-dependencies.mjs", + "start": "npx webpack serve --config ./.webpack/webpack.dev.mjs", + "start:coverage": "npx webpack serve --config ./.webpack/webpack.coverage.mjs", "prepare": "npm run build:dist", "test:getopensource": "sh ./tests/git-opensource-tests.sh", "posttest:getopensource": "npm install", - "test:e2e:smoke": "npm test --workspace tests/e2e/opensource -- --config=../playwright-quickstart.config.js --project=chromium quickstartSmoke", - "test:e2e:quickstart": "npm test --workspace tests/e2e/opensource -- --config=../playwright-quickstart.config.js --project=chromium tests/e2e/yamcs/", - "test:e2e:quickstart:local": "npm test --workspace tests/e2e/opensource -- --config=../playwright-quickstart.config.js --project=local-chrome tests/e2e/yamcs/", - "test:e2e:watch": "npm test --workspace tests/e2e/opensource -- --ui --config=../playwright-quickstart.config.js", + "test:e2e:smoke": "npm test --workspace tests/e2e/opensource -- --config=../playwright-quickstart.config.mjs --project=chromium quickstartSmoke", + "test:e2e:quickstart": "npm test --workspace tests/e2e/opensource -- --config=../playwright-quickstart.config.mjs --project=chromium tests/e2e/yamcs/", + "test:e2e:quickstart:local": "npm test --workspace tests/e2e/opensource -- --config=../playwright-quickstart.config.mjs --project=local-chrome tests/e2e/yamcs/", + "test:e2e:watch": "npm test --workspace tests/e2e/opensource -- --ui --config=../playwright-quickstart.config.mjs", "wait-for-yamcs": "wait-on http-get://localhost:8090/ -v" }, "keywords": [ diff --git a/tests/e2e/framework/quickstartFixtures.e2e.spec.js b/tests/e2e/framework/quickstartFixtures.e2e.spec.mjs similarity index 100% rename from tests/e2e/framework/quickstartFixtures.e2e.spec.js rename to tests/e2e/framework/quickstartFixtures.e2e.spec.mjs diff --git a/tests/e2e/playwright-quickstart.config.js b/tests/e2e/playwright-quickstart.config.mjs similarity index 91% rename from tests/e2e/playwright-quickstart.config.js rename to tests/e2e/playwright-quickstart.config.mjs index 525f359f..8c6b3f51 100644 --- a/tests/e2e/playwright-quickstart.config.js +++ b/tests/e2e/playwright-quickstart.config.mjs @@ -15,7 +15,7 @@ const config = { baseURL: 'http://localhost:9000/#', ignoreHTTPSErrors: true, myItemsFolderName: "My Items", - failOnConsoleError: false + failOnConsoleError: true }, webServer: { cwd: '../', @@ -28,7 +28,7 @@ const config = { projects: [ { name: "chromium", - grepInvert: /@unstable|@snapshot|@localStorage|@addInit/, + grepInvert: /@snapshot|@localStorage|@addInit/, use: { browserName: 'chromium', headless: true, @@ -40,7 +40,7 @@ const config = { // -- Local Browsers -- { name: "local-chrome", - grepInvert: /@unstable|@snapshot|@localStorage|@addInit/, + grepInvert: /@snapshot|@localStorage|@addInit/, use: { browserName: 'chromium', channel: 'chrome' diff --git a/tests/e2e/quickstartFixtures.js b/tests/e2e/quickstartFixtures.mjs similarity index 96% rename from tests/e2e/quickstartFixtures.js rename to tests/e2e/quickstartFixtures.mjs index 31ccf0b5..2b1ba290 100644 --- a/tests/e2e/quickstartFixtures.js +++ b/tests/e2e/quickstartFixtures.mjs @@ -26,7 +26,7 @@ */ // import { createDomainObjectWithDefaults } from './appActions.js'; -import { test, request, expect } from './opensource/pluginFixtures.js'; +const { test, request, expect } = await import('./opensource/pluginFixtures.js'); /** * The name of the "My Items" folder in the domain object tree. diff --git a/tests/e2e/yamcs/actions.e2e.spec.js b/tests/e2e/yamcs/actions.e2e.spec.mjs similarity index 64% rename from tests/e2e/yamcs/actions.e2e.spec.js rename to tests/e2e/yamcs/actions.e2e.spec.mjs index b6660271..01ae3d2b 100644 --- a/tests/e2e/yamcs/actions.e2e.spec.js +++ b/tests/e2e/yamcs/actions.e2e.spec.mjs @@ -24,23 +24,23 @@ * This suite verifies the network requests made by the application to ensure correct interaction with YAMCS. */ -import { test, expect, filterNonFetchRequests } from '../quickstartFixtures.js'; +import { test, expect, filterNonFetchRequests } from '../quickstartFixtures.mjs'; import { createDomainObjectWithDefaults, setFixedTimeMode } from '../opensource/appActions.js'; test.describe('Reload action', () => { - let displayLayout; - let batchGet; - let batchGet2; - let battery1tempRequest; - let battery1tempRequestCont; - let battery1voltageRequest; - let battery1voltageRequestCont; - let allNetworkRequests = []; + let displayLayout; + let batchGetResponse; + let battery1tempResponse; + let battery1tempResponseCont; + let battery1voltageResponse; + let battery1voltageResponeCont; + let allNetworkRequests = []; test.beforeEach(async ({ page }) => { await page.goto('./', { waitUntil: 'domcontentloaded' }); displayLayout = await createDomainObjectWithDefaults(page, { - type: 'Display Layout' + type: 'Display Layout', + name: 'Display Layout' }); await createDomainObjectWithDefaults(page, { @@ -48,7 +48,7 @@ test.describe('Reload action', () => { name: 'Alpha Table' }); - //Expand the quickstart myproject twice + //Expand the quickstart myproject twice to get to the telemetry in the tree await page.getByLabel('Expand myproject folder').click(); await page.getByLabel('Expand myproject folder').click(); @@ -74,26 +74,32 @@ test.describe('Reload action', () => { await page.getByLabel('Edit Object', { exact: true }).click(); await page.getByLabel('Collapse myproject folder').first().click(); await page.getByLabel('Expand My Items folder').click(); - await page.dragAndDrop(`text='Alpha Table'`, '.l-layout__grid-holder', { + + await page.getByLabel('Preview Alpha Table table') + .dragTo(page.getByLabel('Display Layout Layout Grid').locator('div').nth(1), { targetPosition: { x: 0, y: 0 } }); - await page.dragAndDrop(`text='Beta Table'`, '.l-layout__grid-holder', { + + await page.getByLabel('Preview Beta Table table') + .dragTo(page.getByLabel('Display Layout Layout Grid').locator('div').nth(1), { targetPosition: { x: 0, y: 250 } }); - await page.locator('button[title="Save"]').click(); + + + await page.getByRole('button', { name: 'Save' }).click(); await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); - await page.goto(displayLayout.url, { waitUntil: 'networkidle' }); //Set to 1 Minute to reduce the time the opportunity for paginated data // await page.getByRole('menuitem', { name: /Real-Time/ }).click(); + await page.getByLabel('Start offset: 00:30:00').click(); await page.getByLabel('Start offset minutes').fill('1'); await page.getByLabel('Submit time offsets').click(); await page.waitForLoadState('networkidle'); }); - test.only('can reload display layout and its telemetry table children', async ({ page }) => { + test('can reload display layout and its telemetry table children', async ({ page }) => { // Listening for all network requests and pushing them into allNetworkRequests array. page.on('request', request => allNetworkRequests.push(request)); @@ -112,17 +118,57 @@ test.describe('Reload action', () => { await page.waitForLoadState('networkidle'); allNetworkRequests = []; - battery1tempRequest = page.waitForResponse('**/api/archive/myproject/parameters/myproject/Battery1_Temp**') - battery1tempRequestCont = page.waitForResponse('**/api/archive/myproject/parameters/myproject/Battery1_Temp**') - batchGet = page.waitForResponse('**/api/processors/myproject/realtime/parameters:batchGet'); + //Create response promises + battery1tempResponse = page.waitForResponse('**/api/archive/myproject/parameters/myproject/Battery1_Temp**') + batchGetResponse = page.waitForResponse('**/api/processors/myproject/realtime/parameters:batchGet'); + + //Intercept the request to /api/archive/myproject/parameters/myproject/Battery1_Temp + await page.route('**/api/archive/myproject/parameters/myproject/Battery1_Temp', async route => { + const response = await route.fetch(); + const json = await response.json(); + + // Replace every "floatValue" with 1337 + json.parameter.forEach(param => { + if (param.rawValue && param.rawValue.type === 'FLOAT') { + param.rawValue.floatValue = 1337; + } + if (param.engValue && param.engValue.type === 'FLOAT') { + param.engValue.floatValue = 1337; + } + }); + + console.log('Request:', JSON.stringify({ + url: route.request().url(), + method: route.request().method(), + headers: route.request().headers(), + postData: route.request().postData() + }, null, 2)); + + console.log('Response:', JSON.stringify({ + status: response.status(), + statusText: response.statusText(), + headers: response.headers(), + body: json + }, null, 2)); + + // Fulfill using the modified JSON object + await route.fulfill({ + status: response.status(), + headers: response.headers(), + contentType: response.headers()['content-type'], + body: JSON.stringify(json) + }); + }); + + //Click on Reload Action on Alpha Table + await page.getByLabel('Alpha Table Frame Controls').getByLabel('View menu items').click(); + await page.getByLabel('Reload').click(); + + await Promise.all([battery1tempResponse, batchGetResponse]); - await page.getByTitle('View menu items').first().click(); - await page.getByRole('menuitem', { name: /Reload/ }).click(); - await Promise.all([battery1tempRequest, battery1tempRequestCont, batchGet]); await page.waitForLoadState('networkidle'); expect(allNetworkRequests.length).toBe(2); - const afterReloadAlphaTelemetryValue = await page .getByLabel('Alpha Table table content') .getByLabel('value table cell') @@ -134,21 +180,24 @@ test.describe('Reload action', () => { .first() .getAttribute('title'); + //After reload, the telemetry value should be different for Alpha Table expect(beforeReloadAlphaTelemetryValue).not.toEqual(afterReloadAlphaTelemetryValue); - expect(beforeReloadBetaTelemetryValue).toEqual(afterReloadBetaTelemetryValue); + + // expect(beforeReloadBetaTelemetryValue).toEqual(afterReloadBetaTelemetryValue); await page.waitForLoadState('networkidle'); allNetworkRequests = []; - battery1tempRequest = page.waitForResponse('**/api/archive/myproject/parameters/myproject/Battery1_Temp**') - battery1voltageRequest = page.waitForResponse('**/api/archive/myproject/parameters/myproject/Battery1_Voltage**') - batchGet = page.waitForResponse('**/api/processors/myproject/realtime/parameters:batchGet'); - batchGet2 = page.waitForResponse('**/api/processors/myproject/realtime/parameters:batchGet'); + battery1tempResponse = page.waitForResponse('**/api/archive/myproject/parameters/myproject/Battery1_Temp**') + battery1voltageResponse = page.waitForResponse('**/api/archive/myproject/parameters/myproject/Battery1_Voltage**') + batchGetResponse = page.waitForResponse('**/api/processors/myproject/realtime/parameters:batchGet'); await page.getByTitle('More actions').click(); await page.getByRole('menuitem', { name: /Reload/ }).click(); - await Promise.all([battery1tempRequest, battery1voltageRequest, batchGet, batchGet2]); + + await Promise.all([battery1tempResponse, battery1voltageResponse, batchGetResponse]); await page.waitForLoadState('networkidle'); + console.log(JSON.stringify(allNetworkRequests)); expect(allNetworkRequests.length).toBe(3); diff --git a/tests/e2e/yamcs/staleness.e2e.mjs b/tests/e2e/yamcs/staleness.e2e.spec.mjs similarity index 100% rename from tests/e2e/yamcs/staleness.e2e.mjs rename to tests/e2e/yamcs/staleness.e2e.spec.mjs diff --git a/tests/e2e/yamcs/tabs.e2e.spec.js b/tests/e2e/yamcs/tabs.e2e.spec.mjs similarity index 99% rename from tests/e2e/yamcs/tabs.e2e.spec.js rename to tests/e2e/yamcs/tabs.e2e.spec.mjs index 512f0e91..7ecc66ac 100644 --- a/tests/e2e/yamcs/tabs.e2e.spec.js +++ b/tests/e2e/yamcs/tabs.e2e.spec.mjs @@ -23,7 +23,7 @@ * Network Specific Tests for Open MCT and YAMCS connectivity with regard to tabs */ -import { test, expect, filterNonFetchRequests } from '../quickstartFixtures.js'; +import { test, expect, filterNonFetchRequests } from '../quickstartFixtures.mjs'; import { createDomainObjectWithDefaults, setFixedTimeMode } from '../opensource/appActions.js'; test.describe('Tabs View', () => {