Skip to content

Commit

Permalink
fix: Fix job name search (#1282)
Browse files Browse the repository at this point in the history
Co-authored-by: Tiffany K <[email protected]>
  • Loading branch information
minghay and tkyi authored Dec 5, 2024
1 parent 9b92624 commit 1a114de
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 39 deletions.
5 changes: 0 additions & 5 deletions app/components/pipeline/jobs/table/cell/job/component.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { statusIcon } from 'screwdriver-ui/utils/build';
import getDisplayName from './util';

export default class PipelineJobsTableCellJobComponent extends Component {
@tracked latestBuild;
Expand All @@ -26,8 +25,4 @@ export default class PipelineJobsTableCellJobComponent extends Component {

this.args.record.onDestroy(this.args.record.job);
}

get jobName() {
return getDisplayName(this.args.record.job);
}
}
2 changes: 1 addition & 1 deletion app/components/pipeline/jobs/table/cell/job/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<BsTooltip @placement="bottom">
{{@record.job.name}}
</BsTooltip>
{{this.jobName}}
{{@record.jobName}}
</div>
</div>
3 changes: 2 additions & 1 deletion app/components/pipeline/jobs/table/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Component from '@glimmer/component';
import { service } from '@ember/service';
import { action } from '@ember/object';
import DataReloader from './dataReloader';
import getDisplayName from './util';

const INITIAL_PAGE_SIZE = 10;

Expand Down Expand Up @@ -75,7 +76,7 @@ export default class PipelineJobsTableComponent extends Component {
this.args.jobs.forEach(job => {
this.data.push({
job,
jobName: job.name,
jobName: getDisplayName(job),
stageName: job?.permutations?.[0]?.stage?.name || 'N/A',
pipeline: this.args.pipeline,
jobs: this.args.jobs,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ module(
setupRenderingTest(hooks);

test('it renders', async function (assert) {
const job = { id: 123, name: 'main' };
const jobName = 'main';

this.setProperties({
record: {
job,
job: { id: 123, name: 'main' },
jobName,
onCreate: () => {},
onDestroy: () => {}
}
Expand All @@ -26,7 +27,7 @@ module(
/>`
);

assert.dom('.job-name').hasText(job.name);
assert.dom('.job-name').hasText(jobName);
});

test('it calls onCreate', async function (assert) {
Expand All @@ -36,6 +37,7 @@ module(
this.setProperties({
record: {
job,
jobName: 'main',
onCreate,
onDestroy: () => {}
}
Expand All @@ -58,6 +60,7 @@ module(
this.setProperties({
record: {
job,
jobName: 'main',
onCreate: () => {},
onDestroy
}
Expand All @@ -73,32 +76,5 @@ module(
assert.equal(onDestroy.calledOnce, true);
assert.equal(onDestroy.calledWith(job), true);
});

test('it uses display name if annotation is set', async function (assert) {
const displayName = 'Display me';
const job = {
id: 123,
name: 'main',
permutations: [
{ annotations: { 'screwdriver.cd/displayName': displayName } }
]
};

this.setProperties({
record: {
job,
onCreate: () => {},
onDestroy: () => {}
}
});

await render(
hbs`<Pipeline::Jobs::Table::Cell::Job
@record={{this.record}}
/>`
);

assert.dom('.job-name').hasText(displayName);
});
}
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from 'qunit';
import getDisplayName from 'screwdriver-ui/components/pipeline/jobs/table/cell/job/util';
import getDisplayName from 'screwdriver-ui/components/pipeline/jobs/table/util';

module('Unit | Component | pipeline/jobs/table/cell/job/util', function () {
module('Unit | Component | pipeline/jobs/table/util', function () {
test('getDisplayName uses job name', function (assert) {
const job = { name: 'abc123' };

Expand Down

0 comments on commit 1a114de

Please sign in to comment.