// File: dialog-object-update-entity.ts
// Author: Vinicius Martins Ferraz
// Date: 04/09/2021

import { PageObjectUpdateEntity } from "./page-object-update-entity";
import { UpdateDialogStruct } from "./i-page-structure";
import { PageElementButton } from "../page-element/page-element-button";

export abstract class DialogObjectUpdateEntity extends PageObjectUpdateEntity {

  constructor(pageStruct: UpdateDialogStruct, title: string) {
    super({...pageStruct, childTables: []}, title);
  }

  override get saveButton() {
    return new PageElementButton({id: 'mat-dialog-container mat-dialog-actions button[color="primary"]', text: 'Save'});
  }

  get closeButton() {
    return new PageElementButton({id: 'mat-dialog-container mat-dialog-actions button[class*="mat-unthemed"]', text: 'Cancel'});
  }

  public override validatePage(): void {
    this.validatePageStructure();

    cy.get('h2[mat-dialog-title]').invoke('text').should('include', this.title);

    this.saveButton.validateDefaultFieldValues();
    this.closeButton.validateDefaultFieldValues();
  }

}
