错误“在读取属性之前不得更改属性”仅在 OPA 测试中

问题描述 投票:0回答:0

我有一个要测试的 UI,如下所示:

当用户在描述字段中输入值并按保存按钮时,我尝试导航到另一个视图。我有以下代码:

opaTest("Should trigger a press event", function (Given, When, Then) { 
  When.onTheTeleworkingView.iDescriptionAdded("description").and.iPressOnTheSaveButton();
  Then.onTheTeleworkingView.iShouldSeeTheTable();
});
iPressOnTheSaveButton: function () {
  return this.waitFor({
    id: "save",
      viewName: ".component.EditObject",
      errorMessage: "The save button is not found."
  });
},

iDescriptionAdded: function (sGroup) {
  return this.waitFor({
    id: "description",
    actions: new EnterText({ text: sGroup }),
    errorMessage: "Could not find input idGroupInput"
  });
},

iShouldSeeTheTable: function () {
  return this.waitFor({
    id: "Table",
    viewName: ".Table",
    success: function () {
      Opa5.assert.ok(true, "The  table is visible");
    },
    errorMessage: "Was not able to see the table."
  });
},

视图如下所示:

<Page id="editObjectPage" showHeader="true">
  <customHeader>
    <Bar id="headerBar">
      <contentLeft>
        <Text id="titleText" />
      </contentLeft>
      <contentRight>
        <Button id="save" text="{i18n>save}" type="Emphasized" visible="true" press="onSave" />
        <Button id="cancel" text="{i18n>cancel}" visible="true" press="onCancel" />
      </contentRight>
    </Bar>
  </customHeader>
  <f:SimpleForm id="objectEditForm"
    editable="true"
    layout="ResponsiveGridLayout">
    <f:content>
      <Label id="externalLabel" text="{i18n>id}" />
      <ObjectIdentifier title="{ExternalId}" id="textExternalId" />
      <Label id="descriptionLabel" text="{i18n>description}" />
      <Input id="description" value="{Description}" required="true" />
      <Label id="companyLabel" text="{i18n>company}" />

      <MultiInput
        id="companyMultiInput"
        class="sapUiSmallMarginBottom"
        width="100%"
        showValueHelp="false"
        showSuggestion="true"
        suggestionRows="{/Company}"
        tokens="{ path: 'Company', sorter: { path: 'Company/Description' } }">
        <suggestionColumns>
          <Column hAlign="Begin" popinDisplay="Inline" demandPopin="true" id="cIdColumn">
            <Label id="cIdLabel" text="{i18n>id}" />
          </Column>
          <Column hAlign="Center" popinDisplay="Inline" demandPopin="true" id="cDescColumn">
            <Label id="cDescLabel" text="{i18n>description}" />
          </Column>
          <Column hAlign="Center" popinDisplay="Inline" demandPopin="false" id="cValidColumn">
            <Label id="cValidLabel" text="{i18n>valid}" />
          </Column>
        </suggestionColumns>
        <suggestionRows>
          <ColumnListItem id="cListItem">
            <cells>
              <ObjectIdentifier title="{ExternalId}" id="textCExternalId" />
              <Label text="{Description}" id="textCDesc" />
              <Label text="{Invalid}" id="textCInvalid" />
            </cells>
          </ColumnListItem>
        </suggestionRows>
        <tokens>
          <Token id="tokenId" key="{Company_ID}" text="{Company/Description}" />
        </tokens>
      </MultiInput>

      <Label id="invalidLabel" text="{i18n>valid}" />
      <ComboBox id="invalidCombo" selectedKey="{Invalid}" required="true">
        <core:Item id="itemValid" key="0" text="{i18n>valid}" />
        <core:Item id="itemNotValid" key="1" text="{i18n>invalid}" />
      </ComboBox>
    </f:content>
  </f:SimpleForm>
</Page>

数据绑定在控制器中是这样的:

var oTable = this.byId(oTableId);
var oTemplate = oTable.removeItem(0);
oTable.bindItems({
  path: oPath,
  parameters: {
    $expand: oCustomExpand ? oCustomExpand : 'Gesellschaft($expand=Company($select=ID,Description))'
  },
  sorter: oSorter,
  key: 'ID',
  template: oTemplate,
  templateShareable: true
});

我收到以下错误:

未捕获错误:在读取属性之前不得更改属性
预计:

null

消息:差异被抑制,因为预期结果和实际结果具有等效的序列化

该错误仅发生在测试用例中。实际的 UI 工作正常。当我尝试在描述和有效性字段中添加数据时,会出现错误,因为两者都是必需的(有效性是一个组合框)。

有人可以提供解决方案吗?

unit-testing sapui5 qunit opa odata-v4
© www.soinside.com 2019 - 2024. All rights reserved.