Skip to content

Commit

Permalink
Merge pull request #2122 from sanger/develop
Browse files Browse the repository at this point in the history
[release] Merge Develop into Master for 3.66.1
  • Loading branch information
seenanair authored Jan 6, 2025
2 parents 23a1b9e + 1743a95 commit d48a633
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .release-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.66.0
3.66.1
59 changes: 59 additions & 0 deletions app/frontend/javascript/file-list/components/FileList.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { mount } from '@vue/test-utils'
import FileList from './FileList.vue'

describe('FileList.vue', () => {
let wrapper

beforeEach(() => {
wrapper = mount(FileList, {
data() {
return {
qc_files: [],
loading: true,
}
},
})
})

it('renders loading spinner when loading is true', () => {
expect(wrapper.find('.spinner-dark').exists()).toBe(true)
})

it('does not render loading spinner when loading is false', async () => {
await wrapper.setData({ loading: false })
expect(wrapper.find('.spinner-dark').exists()).toBe(false)
})

it('renders "No files attached" when noFiles is true', async () => {
await wrapper.setData({ loading: false, qc_files: [] })
expect(wrapper.find('.list-group-item').text()).toBe('No files attached')
})

it('renders qc_files when they are present', async () => {
const mockFiles = [
{ uuid: '1', filename: 'file1.txt', created: '2023-01-01' },
{ uuid: '2', filename: 'file2.txt', created: '2023-01-02' },
]
await wrapper.setData({ loading: false, qc_files: mockFiles })
const fileLinks = wrapper.findAll('.list-group-item')
expect(fileLinks.length).toBe(2)
expect(fileLinks.at(0).text()).toBe('file1.txt - 2023-01-01')
expect(fileLinks.at(1).text()).toBe('file2.txt - 2023-01-02')
})

it('computed noFiles returns true when qc_files is empty and loading is false', async () => {
await wrapper.setData({ loading: false, qc_files: [] })
expect(wrapper.vm.noFiles).toBe(true)
})

it('computed noFiles returns false when qc_files is not empty', async () => {
await wrapper.setData({ loading: false, qc_files: [{ uuid: '1', filename: 'file1.txt', created: '2023-01-01' }] })
expect(wrapper.vm.noFiles).toBe(false)
})

it('calls fetchData on mount', () => {
const fetchDataSpy = vi.spyOn(FileList.methods, 'fetchData')
mount(FileList)
expect(fetchDataSpy).toHaveBeenCalled()
})
})
8 changes: 4 additions & 4 deletions app/frontend/javascript/file-list/components/FileList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="list-group list-group-flush" @click="handleClick">
<div class="list-group list-group-flush">
<div v-if="loading" class="spinner-dark">Updating...</div>
<a v-for="qc_file in qc_files" :key="qc_file.uuid" class="list-group-item" :href="'/qc_files/' + qc_file.uuid">
{{ qc_file.filename }} - {{ qc_file.created }}
Expand All @@ -23,6 +23,9 @@ export default {
return this.qc_files && this.qc_files.length === 0 && !this.loading
},
},
mounted() {
this.fetchData()
},
methods: {
fetchData: function () {
let self = this
Expand All @@ -35,9 +38,6 @@ export default {
}
xhr.send()
},
handleClick() {
this.fetchData()
},
},
}
</script>
2 changes: 1 addition & 1 deletion app/frontend/javascript/vue_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const elements = [
component: CustomTaggedPlate,
},
{
id: 'file-list',
id: 'files-list',
component: FileList,
},
{
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/stylesheets/limber/screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,12 @@ form + .btn-block {
}
}

.pool-tab-description {
@extend .list-group-item;
@extend .list-group-item-light;
@extend .small;
}

#ongoing_plate_purposes,
#ongoing_tube_purposes {
height: 33vh;
Expand Down
20 changes: 19 additions & 1 deletion app/models/robots/robot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ class Robot
include Form

attr_reader :beds
attr_accessor :api, :user_uuid, :layout, :name, :id, :verify_robot, :class, :robot_barcode, :require_robot
attr_accessor :api,
:user_uuid,
:layout,
:name,
:id,
:verify_robot,
:class,
:robot_barcode,
:require_robot,
:start_button_text

alias verify_robot? verify_robot
alias require_robot? require_robot
Expand Down Expand Up @@ -51,6 +60,15 @@ def bed_labwares=(bed_labwares)
bed_labwares.each { |bed_barcode, labware_barcodes| beds[bed_barcode.strip].load(labware_barcodes) }
end

# Returns the message to be displayed on the start button.
# If `start_button_text` is present, it returns that text.
# Otherwise, it returns a default message "Start the #{name}".
#
# @return [String] the message to be displayed on the start button
def start_button_message
start_button_text || "Start the #{name}"
end

private

def error(bed, message)
Expand Down
1 change: 1 addition & 0 deletions app/views/plates/_pooling_tab.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<ul id="pools-information" class="list-group list-group-flush">
<li class="pool-tab-description">Future pools, as specified in submission</li>
<% plate_presenter.pools.each do |pool| -%>
<li data-pool="<%= pool.id %>" class='list-group-item pool-colours'>
<div class="pool-data">
Expand Down
2 changes: 1 addition & 1 deletion app/views/robots/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<%= sidebar do %>
<%= form_for :robot, url: start_robot_path(robot.id) do |form| %>
<%= render partial: 'bed', locals: {robot: robot, form: form } %>
<%= submit_tag "Start the #{robot.name}",
<%= submit_tag robot.start_button_message,
name: nil,
class: "submit btn btn-lg btn-success btn-block",
id: 'start-robot',
Expand Down
4 changes: 4 additions & 0 deletions config/robots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3810,6 +3810,7 @@
name: 'Bravo LCMT DNA Frag Verification',
require_robot: true,
verify_robot: true,
start_button_text: 'Finish Bravo LCMT DNA Frag Verification',
beds: {
bed(5).barcode => {
purpose: 'LCMT DNA Frag',
Expand All @@ -3827,6 +3828,7 @@
name: 'Bravo LCMT DNA End Prep Verification',
require_robot: true,
verify_robot: true,
start_button_text: 'Finish Bravo LCMT DNA End Prep Verification',
beds: {
bed(5).barcode => {
purpose: 'LCMT DNA End Prep',
Expand Down Expand Up @@ -3867,6 +3869,7 @@
name: 'Bravo LCMT EM TET2 Ox Verification',
require_robot: true,
verify_robot: true,
start_button_text: 'Finish Bravo LCMT EM TET2 Ox Verification',
beds: {
bed(5).barcode => {
purpose: 'LCMT EM TET2 Ox',
Expand Down Expand Up @@ -3914,6 +3917,7 @@
name: 'Bravo LCMT EM NaOH Denat Verification',
require_robot: true,
verify_robot: true,
start_button_text: 'Finish Bravo LCMT EM NaOH Denat Verification',
beds: {
bed(5).barcode => {
purpose: 'LCMT EM NaOH Denat',
Expand Down
25 changes: 25 additions & 0 deletions spec/models/robots/robot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -754,4 +754,29 @@
end
end
end

describe '#start_button_message' do
let(:robot_spec) do
{
'name' => 'robot_name',
'beds' => {
'bed1_barcode' => {
'purpose' => 'Limber Cherrypicked',
'states' => ['passed'],
'label' => 'Bed 1'
}
}
}
end

it 'returns the correct message when the robot does not have a start_button_text' do
robot = Robots::Robot.new(robot_spec)
expect(robot.start_button_message).to eq("Start the #{robot.name}")
end

it 'returns the robots start_button_text when present' do
robot = Robots::Robot.new(robot_spec.merge(start_button_text: 'Be different'))
expect(robot.start_button_message).to eq('Be different')
end
end
end

0 comments on commit d48a633

Please sign in to comment.