go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/build/legacy/build_page/steps_tab/step_entry.test.ts (about)

     1  // Copyright 2021 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  import { aTimeout, fixture, html } from '@open-wc/testing-helpers';
    16  import { css, LitElement } from 'lit';
    17  import { customElement } from 'lit/decorators.js';
    18  
    19  import './step_entry';
    20  import { BuildbucketStatus } from '@/common/services/buildbucket';
    21  import { Store } from '@/common/store';
    22  import { StepExt } from '@/common/store/build_state';
    23  import { provider } from '@/generic_libs/tools/lit_context';
    24  import {
    25    IntersectionNotifier,
    26    provideNotifier,
    27  } from '@/generic_libs/tools/observer_element';
    28  
    29  @customElement('milo-bp-step-entry-test-notifier-provider')
    30  @provider
    31  class NotifierProviderElement extends LitElement {
    32    @provideNotifier()
    33    notifier = new IntersectionNotifier({ root: this });
    34  
    35    protected render() {
    36      return html`<slot></slot>`;
    37    }
    38  
    39    static styles = css`
    40      :host {
    41        display: block;
    42        height: 100px;
    43        overflow-y: auto;
    44      }
    45    `;
    46  }
    47  
    48  describe('StepEntry', () => {
    49    test('can render a step without start time', async () => {
    50      const step = new StepExt({
    51        step: {
    52          name: 'stepname',
    53          status: BuildbucketStatus.Scheduled,
    54          startTime: undefined,
    55        },
    56        listNumber: '1.',
    57        selfName: 'stepname',
    58        depth: 0,
    59        index: 0,
    60      });
    61      await fixture<NotifierProviderElement>(html`
    62        <milo-bp-step-entry-test-notifier-provider>
    63          <milo-bp-step-entry
    64            .store=${Store.create()}
    65            .step=${step}
    66          ></milo-bp-step-entry>
    67        </milo-bp-step-entry-test-notifier-provider>
    68      `);
    69      await aTimeout(10);
    70    });
    71  });