unflake
This commit is contained in:
parent
0ffbe0ea78
commit
b0c56c0a0d
2 changed files with 28 additions and 10 deletions
|
|
@ -31,7 +31,7 @@
|
||||||
data-bs-backdrop="true"
|
data-bs-backdrop="true"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-hidden="true"
|
:aria-hidden="modalVisible ? 'false' : 'true'"
|
||||||
data-testid="savings-modal"
|
data-testid="savings-modal"
|
||||||
>
|
>
|
||||||
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
|
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
|
||||||
|
|
@ -306,10 +306,21 @@ export default defineComponent({
|
||||||
return {
|
return {
|
||||||
communityView: false,
|
communityView: false,
|
||||||
telemetryEnabled: false,
|
telemetryEnabled: false,
|
||||||
|
modalVisible: false,
|
||||||
period: settings.savingsPeriod || ("30d" as StatisticsPeriod),
|
period: settings.savingsPeriod || ("30d" as StatisticsPeriod),
|
||||||
selectedRegion: settings.savingsRegion || ("Germany" as string),
|
selectedRegion: settings.savingsRegion || ("Germany" as string),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
const modal = this.$refs["modal"] as HTMLElement;
|
||||||
|
modal.addEventListener("shown.bs.modal", this.handleShown);
|
||||||
|
modal.addEventListener("hidden.bs.modal", this.handleHidden);
|
||||||
|
},
|
||||||
|
unmounted() {
|
||||||
|
const modal = this.$refs["modal"] as HTMLElement;
|
||||||
|
modal?.removeEventListener("shown.bs.modal", this.handleShown);
|
||||||
|
modal?.removeEventListener("hidden.bs.modal", this.handleHidden);
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
sponsorActive(): boolean {
|
sponsorActive(): boolean {
|
||||||
return !!this.sponsor?.status?.name;
|
return !!this.sponsor?.status?.name;
|
||||||
|
|
@ -429,6 +440,12 @@ export default defineComponent({
|
||||||
const modal = Modal.getOrCreateInstance(this.$refs["modal"] as HTMLElement);
|
const modal = Modal.getOrCreateInstance(this.$refs["modal"] as HTMLElement);
|
||||||
modal.show();
|
modal.show();
|
||||||
},
|
},
|
||||||
|
handleShown() {
|
||||||
|
this.modalVisible = true;
|
||||||
|
},
|
||||||
|
handleHidden() {
|
||||||
|
this.modalVisible = false;
|
||||||
|
},
|
||||||
selectPeriod(period: StatisticsPeriod) {
|
selectPeriod(period: StatisticsPeriod) {
|
||||||
this.period = period;
|
this.period = period;
|
||||||
settings.savingsPeriod = period;
|
settings.savingsPeriod = period;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { test, expect } from "@playwright/test";
|
import { test, expect } from "@playwright/test";
|
||||||
import { start, stop, baseUrl } from "./evcc";
|
import { start, stop, baseUrl } from "./evcc";
|
||||||
|
import { expectModalVisible, expectModalHidden } from "./utils";
|
||||||
|
|
||||||
test.use({ baseURL: baseUrl() });
|
test.use({ baseURL: baseUrl() });
|
||||||
|
|
||||||
|
|
@ -20,21 +21,21 @@ test.describe("footer", async () => {
|
||||||
// last 365 days
|
// last 365 days
|
||||||
await page.getByTestId("savings-button").click();
|
await page.getByTestId("savings-button").click();
|
||||||
const savingsModal = page.getByTestId("savings-modal");
|
const savingsModal = page.getByTestId("savings-modal");
|
||||||
await expect(savingsModal).toBeVisible();
|
await expectModalVisible(savingsModal);
|
||||||
await page
|
await page
|
||||||
.getByTestId("savings-period-select")
|
.getByTestId("savings-period-select")
|
||||||
.getByRole("combobox")
|
.getByRole("combobox")
|
||||||
.selectOption("last 365 days");
|
.selectOption("last 365 days");
|
||||||
await page.getByRole("button", { name: "Close" }).click();
|
await page.getByRole("button", { name: "Close" }).click();
|
||||||
await expect(savingsModal).not.toBeVisible();
|
await expectModalHidden(savingsModal);
|
||||||
await expect(page.getByTestId("savings-button")).toContainText("30%");
|
await expect(page.getByTestId("savings-button")).toContainText("30%");
|
||||||
|
|
||||||
// all time
|
// all time
|
||||||
await page.getByTestId("savings-button").click();
|
await page.getByTestId("savings-button").click();
|
||||||
await expect(savingsModal).toBeVisible();
|
await expectModalVisible(savingsModal);
|
||||||
await page.getByTestId("savings-period-select").getByRole("combobox").selectOption("all time");
|
await page.getByTestId("savings-period-select").getByRole("combobox").selectOption("all time");
|
||||||
await page.getByRole("button", { name: "Close" }).click();
|
await page.getByRole("button", { name: "Close" }).click();
|
||||||
await expect(savingsModal).not.toBeVisible();
|
await expectModalHidden(savingsModal);
|
||||||
await expect(page.getByTestId("savings-button")).toContainText("50%");
|
await expect(page.getByTestId("savings-button")).toContainText("50%");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -43,7 +44,7 @@ test.describe("statistics values", async () => {
|
||||||
test("last 30 days", async ({ page }) => {
|
test("last 30 days", async ({ page }) => {
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
await page.getByTestId("savings-button").click();
|
await page.getByTestId("savings-button").click();
|
||||||
await expect(page.getByTestId("savings-modal")).toBeVisible();
|
await expectModalVisible(page.getByTestId("savings-modal"));
|
||||||
|
|
||||||
await page
|
await page
|
||||||
.getByTestId("savings-period-select")
|
.getByTestId("savings-period-select")
|
||||||
|
|
@ -64,7 +65,7 @@ test.describe("statistics values", async () => {
|
||||||
test("last 365 days", async ({ page }) => {
|
test("last 365 days", async ({ page }) => {
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
await page.getByTestId("savings-button").click();
|
await page.getByTestId("savings-button").click();
|
||||||
await expect(page.getByTestId("savings-modal")).toBeVisible();
|
await expectModalVisible(page.getByTestId("savings-modal"));
|
||||||
await page
|
await page
|
||||||
.getByTestId("savings-period-select")
|
.getByTestId("savings-period-select")
|
||||||
.getByRole("combobox")
|
.getByRole("combobox")
|
||||||
|
|
@ -84,7 +85,7 @@ test.describe("statistics values", async () => {
|
||||||
test("reference data", async ({ page }) => {
|
test("reference data", async ({ page }) => {
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
await page.getByTestId("savings-button").click();
|
await page.getByTestId("savings-button").click();
|
||||||
await expect(page.getByTestId("savings-modal")).toBeVisible();
|
await expectModalVisible(page.getByTestId("savings-modal"));
|
||||||
|
|
||||||
await expect(page.getByTestId("savings-reference")).toContainText("Reference data");
|
await expect(page.getByTestId("savings-reference")).toContainText("Reference data");
|
||||||
await expect(page.getByTestId("savings-reference")).toContainText("30.0 ct./kWh");
|
await expect(page.getByTestId("savings-reference")).toContainText("30.0 ct./kWh");
|
||||||
|
|
@ -117,7 +118,7 @@ test.describe("header savings", async () => {
|
||||||
// open modal, verify values still work
|
// open modal, verify values still work
|
||||||
await page.getByTestId("savings-button").click();
|
await page.getByTestId("savings-button").click();
|
||||||
const savingsModal = page.getByTestId("savings-modal");
|
const savingsModal = page.getByTestId("savings-modal");
|
||||||
await expect(savingsModal).toBeVisible();
|
await expectModalVisible(savingsModal);
|
||||||
|
|
||||||
await expect(page.getByTestId("savings-tile-solar")).toContainText("60.0%");
|
await expect(page.getByTestId("savings-tile-solar")).toContainText("60.0%");
|
||||||
await expect(page.getByTestId("savings-tile-price")).toContainText("18.0ct./kWh");
|
await expect(page.getByTestId("savings-tile-price")).toContainText("18.0ct./kWh");
|
||||||
|
|
@ -126,7 +127,7 @@ test.describe("header savings", async () => {
|
||||||
// switch indicator to "price"
|
// switch indicator to "price"
|
||||||
await page.getByTestId("savings-indicator-select").getByRole("combobox").selectOption("price");
|
await page.getByTestId("savings-indicator-select").getByRole("combobox").selectOption("price");
|
||||||
await page.getByRole("button", { name: "Close" }).click();
|
await page.getByRole("button", { name: "Close" }).click();
|
||||||
await expect(savingsModal).not.toBeVisible();
|
await expectModalHidden(savingsModal);
|
||||||
|
|
||||||
// verify button now shows price
|
// verify button now shows price
|
||||||
await expect(page.getByTestId("savings-button")).toContainText("18.0");
|
await expect(page.getByTestId("savings-button")).toContainText("18.0");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue