Skip to content
Open
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
7 changes: 6 additions & 1 deletion ui/app/manager/src/pages/page-alarms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,12 @@ export class PageAlarms extends Page<AppStateKeyed> {
.some((input) => !input.checkValidity());
}

if (this.alarm && !this.alarm.title) {
// The title is required, and in the create state the model behind the button is
// this.creationState.alarmModel, which the edit-state guard (this.alarm) never saw.
// Without this check the create button stayed enabled with an empty title, and
// pressing it did nothing because the backend guard drops the request.
const model = this.alarm ?? this.creationState?.alarmModel;
if (!model?.title?.trim()) {
saveBtn.disabled = true;
}
}
Expand Down
24 changes: 24 additions & 0 deletions ui/app/manager/test/alarms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ test("should change the status of an existing alarm", async ({ manager, alarmsPa
expect(stored.status).toBe(AlarmStatus.IN_PROGRESS);
});

/**
* @given Logged into the "master" realm as "admin"
* @when A new alarm is started and a property is changed before the required title is filled in
* @then The create button stays disabled until the title has content
*/
test("should keep the create button disabled while the required title is empty", async ({ manager, alarmsPage }) => {
await manager.goToRealmStartPage("master");
await alarmsPage.goto();
await alarmsPage.getAddButton().click();

// Changing a property fired onAlarmChanged, which used to re-enable the button even with an
// empty title, because the guard only looked at the model of an edited alarm and never at the
// model being created.
await alarmsPage.setStatus("Resolved");
await expect(alarmsPage.getSaveButton()).toBeDisabled();

// Filling in the title unlocks the button, and emptying it again locks it back down
await alarmsPage.getTitleInput().fill("E2E alarm with a title");
await expect(alarmsPage.getSaveButton()).toBeEnabled();

await alarmsPage.getTitleInput().fill("");
await expect(alarmsPage.getSaveButton()).toBeDisabled();
});

/**
* @given Logged into the "master" realm as "admin"
* @and An open alarm seeded via REST
Expand Down
9 changes: 9 additions & 0 deletions ui/app/manager/test/fixtures/pages/alarms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ export class AlarmsPage implements BasePage {
return this.page.locator("#savebtn");
}

/** The required title field in the details panel of the single-alarm view. */
getTitleInput(): Locator {
return this.page
.locator("#details-panel")
.locator("or-vaadin-text-field")
.filter({ has: this.page.locator('or-translate[value="alarm.title"]') })
.locator("input");
}

/** Open the single-alarm view of the (first) row containing the given text. */
async openAlarmByText(text: string) {
await this.getRowByText(text).first().click();
Expand Down