2
* Copyright 2021 The Backstage Authors
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
import { Entity } from '@backstage/catalog-model';
18
import { createDevApp, EntityGridItem } from '@backstage/dev-utils';
19
import React from 'react';
20
import { EntityBitriseContent } from '../src';
21
import { BitriseApi } from '../src/api/bitriseApi';
24
BitriseBuildArtifactDetails,
26
BitrisePagingResponse,
27
} from '../src/api/bitriseApi.model';
28
import { BITRISE_APP_ANNOTATION } from '../src/components/BitriseBuildsComponent';
29
import { bitriseApiRef } from '../src/plugin';
30
import { Content, Header, Page } from '@backstage/core-components';
32
const mockedPagingResponse: BitrisePagingResponse = {
35
total_item_count: 400,
38
const entities: (string | undefined)[] = [
48
const mockedBuildResults: BitriseBuildResult[] = [
51
buildSlug: '3291j9390d39239d3',
52
commitHash: '27c988e4f13e26bc2d1b0af292026a3079aqsxe1',
56
'https://github.com/ORG/APPNAME/commit/27c988e4f13e26bc2d1b0af292026a3079aqsxe1',
57
statusText: 'success',
59
workflow: 'app-ios-test',
60
triggerTime: '2019-01-27T17:55:17Z',
61
duration: '12 minutes',
65
buildSlug: '38i23sk2923js9231s1',
66
commitHash: '13c988d4f13e06bcdd1b0af292086a3079cdaxb0',
70
'https://github.com/ORG/APPNAME/commit/13c988d4f13e06bcdd1b0af292086a3079cdaxb0',
71
statusText: 'in-progress',
73
workflow: 'app-ios-release',
74
triggerTime: '2020-01-28T17:55:17Z',
75
duration: '19 minutes',
78
const entity = (name?: string) =>
80
apiVersion: 'backstage.io/v1alpha1',
84
[BITRISE_APP_ANNOTATION]: name,
96
getBuilds: async (appName: string) => {
99
throw new Error('Error!');
102
return new Promise(() => {});
105
return { data: mockedBuildResults, paging: mockedPagingResponse };
109
data: [mockedBuildResults.find(b => b.message === 'develop')],
110
paging: mockedPagingResponse,
113
case 'searchNotFound':
120
getBuildWorkflows: async (_buildSlug: string) => {
121
return ['app-ios-release', 'app-ios-test'];
123
getApp: async (_appName: string) => {
128
getBuildArtifacts: async (_appName: string, _buildSlug: string) => {
131
title: 'App artifact',
132
slug: 'some-artifact-slug',
135
title: 'App artifact 2',
136
slug: 'some-artifact-slug-2',
139
title: 'App artifact 3',
140
slug: 'some-artifact-slug-3',
142
] as BitriseBuildArtifact[];
144
getArtifactDetails: async (
147
_artifactSlug: string,
150
title: 'App artifact',
151
slug: 'some-artifact-slug',
152
public_install_page_url: 'some-url',
153
expiring_download_url: 'some-url',
154
} as BitriseBuildArtifactDetails;
161
<Page themeId="home">
162
<Header title="Bitrise CI" />
164
{entities.map(entityItem => (
165
<EntityGridItem entity={entity(entityItem)} key={entityItem}>
166
<EntityBitriseContent />