Skip to content

Commit a9f5b4c

Browse files
committed
add e2e tests for dataset uploading
1 parent a933e74 commit a9f5b4c

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
time_utc,TotalPower,BatteryStateOfCharge,Temperature
2+
2024-245T00:01:00.0,0.0,143.15,0.0
3+
2024-245T00:02:00.0,384.999999940483,1.4,-12.0964867663028
4+
2024-245T00:03:00.0,384.999999399855,137.45,-12.0974993557598
5+
2024-245T00:04:00.0,385.000010807604,134.85,-12.0985125609155
6+
2024-245T00:05:00.0,381.80000002749,132.4,-12.0995253838464
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"datasetStart": "2024-245T14:00:00",
3+
"profileSet": {
4+
"/orientation": {
5+
"schema": {
6+
"items": {
7+
"x": {
8+
"type": "real"
9+
},
10+
"y": {
11+
"type": "real"
12+
},
13+
"z": {
14+
"type": "real"
15+
}
16+
},
17+
"type": "struct"
18+
},
19+
"segments": [
20+
{
21+
"duration": 3600000000,
22+
"dynamics": {
23+
"x": 0,
24+
"y": 0,
25+
"z": 1
26+
}
27+
},
28+
{
29+
"duration": 3600000000
30+
},
31+
{
32+
"duration": 3600000000,
33+
"dynamics": {
34+
"x": 1,
35+
"y": 1,
36+
"z": 0
37+
}
38+
}
39+
],
40+
"type": "discrete"
41+
}
42+
}
43+
}

e2e-tests/fixtures/Plan.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export class Plan {
9393
}
9494

9595
async addActivity(name: string = 'GrowBanana') {
96+
await this.showPanel(PanelNames.TIMELINE_ITEMS);
9697
const currentNumOfActivitiesWithName = await this.panelActivityDirectivesTable.getByRole('row', { name }).count();
9798
const activityListItem = this.page.locator(`.list-item :text-is("${name}")`);
9899
const activityRow = this.page
@@ -252,6 +253,13 @@ export class Plan {
252253
await this.panelActivityForm.getByPlaceholder('Enter preset name').blur();
253254
}
254255

256+
async fillExternalDatasetFileInput(importFilePath: string) {
257+
const inputFile = this.page.locator('input[name="file"]');
258+
await inputFile.focus();
259+
await inputFile.setInputFiles(importFilePath);
260+
await inputFile.evaluate(e => e.blur());
261+
}
262+
255263
async fillPlanName(name: string) {
256264
await this.planNameInput.fill(name);
257265
await this.planNameInput.evaluate(e => e.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' })));
@@ -552,6 +560,14 @@ export class Plan {
552560
this.schedulingSatisfiedActivity = page.locator('.scheduling-goal-analysis-activities-list > .satisfied-activity');
553561
}
554562

563+
async uploadExternalDatasets(importFilePath: string) {
564+
await this.panelActivityTypes.getByRole('button', { exact: true, name: 'Resources' }).click();
565+
await this.panelActivityTypes.getByRole('button', { exact: true, name: 'Upload Resources' }).click();
566+
await this.fillExternalDatasetFileInput(importFilePath);
567+
await expect(this.panelActivityTypes.getByRole('button', { exact: true, name: 'Upload' })).toBeEnabled();
568+
await this.panelActivityTypes.getByRole('button', { exact: true, name: 'Upload' }).click();
569+
}
570+
555571
async waitForActivityCheckingStatus(status: Status) {
556572
await expect(this.page.locator(this.activityCheckingStatusSelector(status))).toBeAttached({ timeout: 10000 });
557573
await expect(this.page.locator(this.activityCheckingStatusSelector(status))).toBeVisible();
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import test, { expect, type BrowserContext, type Page } from '@playwright/test';
2+
import { Constraints } from '../fixtures/Constraints.js';
3+
import { Models } from '../fixtures/Models.js';
4+
import { Plan } from '../fixtures/Plan.js';
5+
import { Plans } from '../fixtures/Plans.js';
6+
import { SchedulingConditions } from '../fixtures/SchedulingConditions.js';
7+
import { SchedulingGoals } from '../fixtures/SchedulingGoals.js';
8+
9+
let constraints: Constraints;
10+
let context: BrowserContext;
11+
let models: Models;
12+
let page: Page;
13+
let plan: Plan;
14+
let plans: Plans;
15+
let schedulingConditions: SchedulingConditions;
16+
let schedulingGoals: SchedulingGoals;
17+
18+
test.beforeAll(async ({ baseURL, browser }) => {
19+
context = await browser.newContext();
20+
page = await context.newPage();
21+
22+
models = new Models(page);
23+
plans = new Plans(page, models);
24+
constraints = new Constraints(page);
25+
schedulingConditions = new SchedulingConditions(page);
26+
schedulingGoals = new SchedulingGoals(page);
27+
plan = new Plan(page, plans, constraints, schedulingGoals, schedulingConditions);
28+
29+
await models.goto();
30+
await models.createModel(baseURL);
31+
await plans.goto();
32+
await plans.createPlan();
33+
await plan.goto();
34+
});
35+
36+
test.afterAll(async () => {
37+
await plans.goto();
38+
await plans.deletePlan();
39+
await models.goto();
40+
await models.deleteModel();
41+
await page.close();
42+
await context.close();
43+
});
44+
45+
test.describe.serial('Plan Resources', () => {
46+
test('Uploading external plan dataset file - JSON', async () => {
47+
await plan.uploadExternalDatasets('e2e-tests/data/external-dataset.json');
48+
await expect(plan.panelActivityTypes.getByText('/orientation')).toBeVisible();
49+
});
50+
51+
test('Uploading external plan dataset file - CSV', async () => {
52+
await plan.uploadExternalDatasets('e2e-tests/data/external-dataset.csv');
53+
await expect(plan.panelActivityTypes.getByText('TotalPower')).toBeVisible();
54+
await expect(plan.panelActivityTypes.getByText('BatteryStateOfCharge')).toBeVisible();
55+
await expect(plan.panelActivityTypes.getByText('Temperature')).toBeVisible();
56+
});
57+
});

0 commit comments

Comments
 (0)