Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update screenshots to current evcc version #594

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/features/screenshots/battery-buffer-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-buffer-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-buffer-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-buffer-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-bufferstart-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-bufferstart-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-bufferstart-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-bufferstart-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-navigation-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-navigation-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-navigation-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-navigation-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-priority-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-priority-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-priority-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/battery-priority-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-loadpoint-settings-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-loadpoint-settings-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-loadpoint-settings-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-loadpoint-settings-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-modal-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-modal-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-modal-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-modal-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-plan-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-plan-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-plan-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/co2-plan-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-modal-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-modal-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-modal-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-modal-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-plan-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-plan-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-plan-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/dynamicprice-plan-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/energyflow-surplus-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/energyflow-surplus-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitenergy-loadpoint-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitenergy-loadpoint-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitenergy-loadpoint-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitenergy-loadpoint-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-loadpoint-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-loadpoint-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-loadpoint-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-loadpoint-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-setting-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-setting-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-setting-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/limitsoc-setting-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/min-solar-mode-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/min-solar-mode-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/min-solar-mode-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/min-solar-mode-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-loadpoint-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-loadpoint-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-loadpoint-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-loadpoint-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-setting-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-setting-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-setting-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/minsoc-setting-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-energy-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-energy-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-energy-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-energy-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-soc-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-soc-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-soc-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/plan-soc-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-detail-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-detail-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-detail-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-detail-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-list-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-list-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-list-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-list-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-main-ui-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-main-ui-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-main-ui-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/sessions-main-ui-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/solar-mode-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/solar-mode-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/solar-mode-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/solar-mode-light-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/vehicle-select-dark-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/vehicle-select-dark-2x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/vehicle-select-light-1x.webp
Binary file not shown.
Binary file modified docs/features/screenshots/vehicle-select-light-2x.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions screenshot-generator/recipes/battery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeEach(async () => {
await start("basics.evcc.yaml");
await start("basics.evcc.yaml", "password.sql");
});
test.afterEach(async () => {
await stop();
Expand Down Expand Up @@ -80,9 +80,9 @@ loop((screenshot) => {
await removeOverlays(page);

// buffer start
await page.locator("#bufferStartSelect").selectOption("90");
await page.locator("#batterySettingsBufferStart").selectOption("90");
await wait(300);
await placeOverlay(page, "#bufferStartSelect", CURSOR, 0, 10);
await placeOverlay(page, "#batterySettingsBufferStart", CURSOR, 0, 10);
await placeOverlay(page, ".bufferStartIndicator", FOUR, -100, -21);

await screenshot(
Expand Down
7 changes: 5 additions & 2 deletions screenshot-generator/recipes/charging-sessions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeAll(async () => {
await start("sessions.yaml", "sessions.sql");
await start("charging-sessions.yaml", [
"charging-sessions.sql",
"password.sql",
]);
});
test.afterAll(async () => {
await stop();
Expand Down Expand Up @@ -34,7 +37,7 @@ loop((screenshot) => {
});

test("session", async ({ page }) => {
await page.goto(`/#/sessions`);
await page.goto(`/#/sessions?year=2024&month=3`);
await expect(
await page.getByTestId("sessions-entry").first(),
).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion screenshot-generator/recipes/co2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeAll(async () => {
await start(["basics.evcc.yaml", "co2.evcc.yaml"]);
await start(["basics.evcc.yaml", "co2.evcc.yaml"], "password.sql");
});
test.afterAll(async () => {
await stop();
Expand Down
2 changes: 1 addition & 1 deletion screenshot-generator/recipes/dynamicprice.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeAll(async () => {
await start(["basics.evcc.yaml", "dynamicprice.evcc.yaml"]);
await start(["basics.evcc.yaml", "dynamicprice.evcc.yaml"], "password.sql");
});
test.afterAll(async () => {
await stop();
Expand Down
29 changes: 15 additions & 14 deletions screenshot-generator/recipes/limits.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeEach(async () => {
await start("vehicles.evcc.yaml");
await start("vehicles.evcc.yaml", "password.sql");
});
test.afterEach(async () => {
await stop();
Expand All @@ -16,12 +16,12 @@ loop((screenshot) => {
test("min soc / limit soc / limit energy", async ({ page }) => {
await page.goto(`/`);

await expect(
page.getByRole("button", { name: "blue IONIQ 6" }),
).toBeVisible();
await expect(
page.getByRole("button", { name: "white Model 3" }),
).toBeVisible();
await expect(page.getByTestId("vehicle-name").first()).toHaveText(
"blue IONIQ 6",
);
await expect(page.getByTestId("vehicle-name").last()).toHaveText(
"white Model 3",
);

await page.locator("[data-testid=charging-plan] button").first().click();
await page
Expand All @@ -39,7 +39,7 @@ loop((screenshot) => {
},
);
await removeOverlays(page);
await page.locator("#chargingPlanModal_1 [aria-label=Close]").click();
await page.getByRole("button", { name: "Close" }).click();
await expect(page.locator("#chargingPlanModal_1")).not.toBeVisible();
await screenshot(
page,
Expand All @@ -66,7 +66,7 @@ loop((screenshot) => {
},
);
await removeOverlays(page);
await page.locator("#chargingPlanModal_2 [aria-label=Close]").click();
await page.getByRole("button", { name: "Close" }).click();
await expect(page.locator("#chargingPlanModal_2")).not.toBeVisible();
await page
.getByTestId("limit-soc")
Expand All @@ -90,11 +90,12 @@ loop((screenshot) => {
);

// limit energy
await page.getByRole("button", { name: "white Model 3" }).click();
await page.getByRole("button", { name: "red Fiat 500e" }).click();
await expect(
page.getByRole("button", { name: "red Fiat 500e" }),
).toBeVisible();
await page
.locator("#vehicleOptionsDropdown2")
.selectOption("red Fiat 500e");
await expect(page.getByTestId("vehicle-name").last()).toHaveText(
"red Fiat 500e",
);
await page
.getByTestId("limit-energy")
.locator("select")
Expand Down
8 changes: 8 additions & 0 deletions screenshot-generator/recipes/password.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS `settings` (
`key` text
, `value` text
, PRIMARY KEY(`key`)
);

-- password: secret
INSERT INTO settings("key", value) VALUES('adminPassword', '$2a$10$HNLoqiTO5oLwopczA/wcPOebfO79S.hnAA5HOkx5p6o3g5a2E30v2');
7 changes: 4 additions & 3 deletions screenshot-generator/recipes/plan.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeEach(async () => {
await start(["vehicles.evcc.yaml", "dynamicprice.evcc.yaml"]);
await start(["vehicles.evcc.yaml", "dynamicprice.evcc.yaml"], "password.sql");
});
test.afterEach(async () => {
await stop();
Expand Down Expand Up @@ -35,8 +35,9 @@ loop((screenshot) => {
test("charging plan energy", async ({ page }) => {
await page.goto(`/`);

await page.getByRole("button", { name: "blue IONIQ 6" }).click();
await page.getByRole("button", { name: "red Fiat 500e" }).click();
await page
.locator("#vehicleOptionsDropdown1")
.selectOption("red Fiat 500e");

await page.locator("[data-testid=charging-plan] button").first().click();
await wait(300);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeAll(async () => {
await start("basics.evcc.yaml");
await start("basics.evcc.yaml", "password.sql");
});
test.afterAll(async () => {
await stop();
Expand Down
29 changes: 20 additions & 9 deletions screenshot-generator/recipes/utils/evcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ const BASE_URL = playwrightConfig.use.baseURL;
const DB_PATH = "./evcc.db";
const BINARY = "./evcc";

export async function start(config, database) {
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

export async function start(config, sqlDumps) {
await _clean();
if (database) {
await _restoreDatabase(database);
if (sqlDumps) {
await _restoreDatabase(sqlDumps);
}
await _start(config);
}
Expand All @@ -34,35 +36,44 @@ export async function cleanRestart(config) {
await _start(config);
}

async function _restoreDatabase(database) {
console.log("loading database", { database });
execSync(`sqlite3 ${DB_PATH} < recipes/${database}`);
async function _restoreDatabase(sqlDumps) {
const dumps = Array.isArray(sqlDumps) ? sqlDumps : [sqlDumps];
for (const dump of dumps) {
console.log("loading database", dump);
execSync(`sqlite3 ${DB_PATH} < recipes/${dump}`, {
encoding: "utf-8",
stdio: ["pipe", "pipe", "ignore"],
});
}
}

let instance = null;

async function _start(config) {
const configPath =
typeof config === "string"
? `recipes/${config}`
: mergeYaml(`recipes/${config[0]}`, `recipes/${config[1]}`);

console.log("starting evcc", { config });
const instance = exec(
instance = exec(
`EVCC_DATABASE_DSN=${DB_PATH} ${BINARY} --config ${configPath}`,
);
instance.stdout.pipe(process.stdout);
instance.stderr.pipe(process.stderr);
instance.on("exit", (code) => {
if (code !== 0) {
throw new Error("evcc terminated", code);
console.log("evcc terminated");
}
});
await waitOn({ resources: [BASE_URL] });
}

async function _stop() {
console.log("shutting down evcc");
await axios.post(BASE_URL + "/api/shutdown");
instance.kill("SIGKILL");
await waitOn({ resources: [BASE_URL], reverse: true });
await sleep(300);
}

async function _clean() {
Expand Down
24 changes: 14 additions & 10 deletions screenshot-generator/recipes/utils/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ const screenshotBase = {
en: "../i18n/en/docusaurus-plugin-content-docs/current",
};

const sleep = async function (ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
};

async function convertToWebp(pngPath) {
const webpPath1x = pngPath.replace(/\.png$/, "-1x.webp");
await sharp(pngPath)
.metadata()
.then(({ width }) =>
sharp(pngPath)
.resize(Math.round(width * 0.5))
.toFile(webpPath1x),
);
try {
const webpPath1x = pngPath.replace(/\.png$/, "-1x.webp");
const meta = await sharp(pngPath).metadata();
const halfWidth = Math.round(meta.width * 0.5);
await sharp(pngPath).resize(halfWidth).toFile(webpPath1x);

const webpPath2x = pngPath.replace(/\.png$/, "-2x.webp");
await sharp(pngPath).toFormat("webp").toFile(webpPath2x);
const webpPath2x = pngPath.replace(/\.png$/, "-2x.webp");
await sharp(pngPath).toFormat("webp").toFile(webpPath2x);
} catch (e) {
console.error("Error converting to webp", e);
}
}

export function loop(body) {
Expand Down
10 changes: 2 additions & 8 deletions screenshot-generator/recipes/vehicles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { start, stop } = require("./utils/evcc");
const BASE_PATH = "features/screenshots";

test.beforeEach(async () => {
await start("vehicles.evcc.yaml");
await start("vehicles.evcc.yaml", "password.sql");
});
test.afterEach(async () => {
await stop();
Expand All @@ -17,13 +17,7 @@ loop((screenshot) => {
await page.goto(`/`);

await page.getByRole("button", { name: "blue IONIQ 6" }).click();
await placeOverlay(
page,
"[aria-labelledby=vehicleOptionsDropdown1] li:nth-child(2)",
CURSOR,
50,
-5,
);
await placeOverlay(page, "[data-testid='vehicle-name']", CURSOR, 50, -5);
await screenshot(
page,
`${BASE_PATH}/vehicle-select`,
Expand Down