describe('Label editor smoke', () => {
  it('loads the label editor shell', () => {
    cy.openLabelEditor();

    cy.get('[data-testid="label-name-input"]', { timeout: 30000 }).should('be.visible');
    cy.get('[data-testid="add-generic-text"]', { timeout: 30000 }).should('be.visible');
    cy.get('[data-testid="label-editor-save"]', { timeout: 30000 }).should('be.visible');
  });

  it('opens the generic text item modal', () => {
    cy.openLabelEditor();

    cy.get('[data-testid="add-generic-text"]', { timeout: 30000 }).should('be.visible').click();
    cy.get('[data-testid="item-settings-title"]', { timeout: 30000 }).should('be.visible');
    cy.get('[data-testid="generic-text-format-hint"]', { timeout: 30000 }).should('be.visible');
    cy.get('[data-testid="auto-downscale-label"]', { timeout: 30000 }).should('be.visible');
  });

  it('allows editing generic text settings and closing the modal', () => {
    cy.openLabelEditor();

    cy.get('[data-testid="add-generic-text"]', { timeout: 30000 }).click();
    cy.get('[data-testid="generic-text-input"]', { timeout: 30000 })
      .should('be.visible')
      .clear()
      .type('[b]Sale[/b] {product_price}', { parseSpecialCharSequences: false });
    cy.get('[data-testid="generic-text-font-size"]').clear().type('28');
    cy.get('[data-testid="generic-text-font-weight"]').select('700');
    cy.get('[data-testid="generic-text-auto-downscale"]').check().should('be.checked');
    cy.get('[data-testid="item-modal-save"]').click();
    cy.get('[data-testid="item-settings-title"]').should('not.exist');
  });
});
