Skip to content

Commit

Permalink
Show battery/grid settings on Sessons and Confg page (evcc-io#11542)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis committed Jan 8, 2024
1 parent a55ce94 commit e8c900d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
9 changes: 7 additions & 2 deletions assets/js/views/ChargingSessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div size="s" class="mx-2 flex-grow-0 flex-shrink-0 fw-normal">/</div>
<span class="text-truncate">{{ $t("sessions.title") }}</span>
</h1>
<TopNavigation />
<TopNavigation v-bind="topNavigation" />
</header>

<div class="row">
Expand Down Expand Up @@ -263,6 +263,7 @@ import CustomSelect from "../components/CustomSelect.vue";
import ChargingSessionModal from "../components/ChargingSessionModal.vue";
import breakpoint from "../mixins/breakpoint";
import settings from "../settings";
import collector from "../mixins/collector";
const COLUMNS_PER_BREAKPOINT = {
xs: 1,
Expand All @@ -276,7 +277,7 @@ const COLUMNS_PER_BREAKPOINT = {
export default {
name: "ChargingSessions",
components: { TopNavigation, ChargingSessionModal, CustomSelect },
mixins: [formatter, breakpoint],
mixins: [formatter, breakpoint, collector],
props: {
notifications: Array,
month: { type: Number, default: () => new Date().getMonth() + 1 },
Expand All @@ -295,6 +296,10 @@ export default {
return { title: `${this.$t("sessions.title")} | evcc` };
},
computed: {
topNavigation: function () {
const vehicleLogins = store.state.auth ? store.state.auth.vehicles : {};
return { vehicleLogins, ...this.collectProps(TopNavigation, store.state) };
},
currentSessions() {
const sessionsWithDefaults = this.sessions.map((session) => {
const loadpoint = session.loadpoint || this.$t("main.loadpoint.fallbackName");
Expand Down
11 changes: 10 additions & 1 deletion assets/js/views/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</router-link>
Configuration 🧪
</h1>
<TopNavigation />
<TopNavigation v-bind="topNavigation" />
</header>

<div class="alert alert-danger mb-5" role="alert">
Expand Down Expand Up @@ -189,10 +189,13 @@ import Modal from "bootstrap/js/dist/modal";
import api from "../api";
import VehicleIcon from "../components/VehicleIcon";
import VehicleModal from "../components/Config/VehicleModal.vue";
import store from "../store";
import collector from "../mixins/collector";
export default {
name: "Config",
components: { TopNavigation, VehicleIcon, VehicleModal },
mixins: [collector],
data() {
return {
vehicles: [],
Expand All @@ -203,6 +206,12 @@ export default {
vehicleId: undefined,
};
},
computed: {
topNavigation: function () {
const vehicleLogins = store.state.auth ? store.state.auth.vehicles : {};
return { vehicleLogins, ...this.collectProps(TopNavigation, store.state) };
},
},
mounted() {
this.loadVehicles();
this.loadLoadpoints();
Expand Down
34 changes: 20 additions & 14 deletions tests/modals.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const { startSimulator, stopSimulator } = require("./simulator");
const BASICS_CONFIG = "basics.evcc.yaml";
const SIMULATOR_CONFIG = "simulator.evcc.yaml";

const UI_ROUTES = ["/", "/#/sessions", "/#/config"];

test.describe("Basics", async () => {
test.beforeAll(async () => {
await start(BASICS_CONFIG);
Expand All @@ -15,13 +17,15 @@ test.describe("Basics", async () => {
});

test("Menu options. No battery and grid.", async ({ page }) => {
await page.goto("/");

await page.getByTestId("topnavigation-button").click();
await expect(page.getByRole("button", { name: "General Settings" })).toBeVisible();
await expect(page.getByRole("button", { name: "Battery Settings" })).not.toBeVisible();
await expect(page.getByRole("button", { name: "Smart Grid Charging" })).not.toBeVisible();
await expect(page.getByRole("button", { name: "Need help?" })).toBeVisible();
for (const route of UI_ROUTES) {
await page.goto(route);

await page.getByTestId("topnavigation-button").click();
await expect(page.getByRole("button", { name: "General Settings" })).toBeVisible();
await expect(page.getByRole("button", { name: "Battery Settings" })).not.toBeVisible();
await expect(page.getByRole("button", { name: "Smart Grid Charging" })).not.toBeVisible();
await expect(page.getByRole("button", { name: "Need help?" })).toBeVisible();
}
});

test("Need help?", async ({ page }) => {
Expand Down Expand Up @@ -54,13 +58,15 @@ test.describe("Advanced", async () => {
});

test("Menu options. All available.", async ({ page }) => {
await page.goto("/");

await page.getByTestId("topnavigation-button").click();
await expect(page.getByRole("button", { name: "General Settings" })).toBeVisible();
await expect(page.getByRole("button", { name: "Battery Settings" })).toBeVisible();
await expect(page.getByRole("button", { name: "Smart Grid Charging" })).toBeVisible();
await expect(page.getByRole("button", { name: "Need help?" })).toBeVisible();
for (const route of UI_ROUTES) {
await page.goto(route);

await page.getByTestId("topnavigation-button").click();
await expect(page.getByRole("button", { name: "General Settings" })).toBeVisible();
await expect(page.getByRole("button", { name: "Battery Settings" })).toBeVisible();
await expect(page.getByRole("button", { name: "Smart Grid Charging" })).toBeVisible();
await expect(page.getByRole("button", { name: "Need help?" })).toBeVisible();
}
});

test("Battery Settings from top navigation", async ({ page }) => {
Expand Down

0 comments on commit e8c900d

Please sign in to comment.