diff --git a/cypress/component/viewMessageChip.cy.js b/cypress/component/viewMessageChip.cy.js new file mode 100644 index 000000000..7910f598f --- /dev/null +++ b/cypress/component/viewMessageChip.cy.js @@ -0,0 +1,48 @@ +/** + * Copyright (C) NIWA & British Crown (Met Office) & Contributors. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import MessageChip from '@/components/cylc/MessageChip.vue' + +describe('View MessageChip Component', () => { + const mountMessageChip = (props) => { + cy.vmount( + MessageChip, + { + props + } + ).as('wrapper') + // add the classes Vuetify requires + cy.addVuetifyStyles(cy) + } + + it('checks messageChip colors', () => { + // mount the toolbar with a couple of controls + mountMessageChip( + { + level: 'this is a debug message', + message: 'Task Message :this is a debug message', + isMessage: true + } + ) + + // are the messages the correct colours? + cy + .get('.v-chip') + .should('have.class', 'bg-blue') + .contains('this is a debug message') + }) +}) diff --git a/src/components/cylc/MessageChip.vue b/src/components/cylc/MessageChip.vue new file mode 100644 index 000000000..48f22c711 --- /dev/null +++ b/src/components/cylc/MessageChip.vue @@ -0,0 +1,56 @@ + + + + diff --git a/src/components/cylc/tree/TreeItem.vue b/src/components/cylc/tree/TreeItem.vue index a4d2afb0d..5ed86bb51 100644 --- a/src/components/cylc/tree/TreeItem.vue +++ b/src/components/cylc/tree/TreeItem.vue @@ -115,29 +115,21 @@ along with this program. If not, see . prefix). @see https://github.com/cylc/cylc-ui/pull/530#issuecomment-781076619 --> - - - {{ customOutput.message }} - + :level="customOutput.level" + :message="customOutput.message" + :isMessage="customOutput.isMessage" + location="bottom"> + +{{ jobMessageOutputs.length - 5 }} @@ -229,6 +221,7 @@ along with this program. If not, see . import { mdiChevronRight } from '@mdi/js' import Task from '@/components/cylc/Task.vue' import Job from '@/components/cylc/Job.vue' +import MessageChip from '@/components/cylc/MessageChip.vue' import { WorkflowState } from '@/model/WorkflowState.model' import { formatDuration, @@ -261,7 +254,8 @@ export default { components: { Task, - Job + Job, + MessageChip }, props: { diff --git a/src/utils/tasks.js b/src/utils/tasks.js index 6e4485919..94e91f7dd 100644 --- a/src/utils/tasks.js +++ b/src/utils/tasks.js @@ -71,7 +71,8 @@ function jobMessageOutputs (jobNode) { const ret = [] let messageOutput - for (const message of jobNode.node.messages || []) { + for (const messageString of jobNode.node.messages || []) { + const [level, message] = messageString.split(':') if (TASK_OUTPUT_NAMES.includes(message)) { continue } @@ -88,6 +89,7 @@ function jobMessageOutputs (jobNode) { } else { // add a message to the list and make it look like an output ret.push({ + level, label: message, message: `Task Message: ${message}`, isMessage: true diff --git a/tests/e2e/specs/tree.cy.js b/tests/e2e/specs/tree.cy.js index 9a26b058a..8ad43aef1 100644 --- a/tests/e2e/specs/tree.cy.js +++ b/tests/e2e/specs/tree.cy.js @@ -163,17 +163,16 @@ describe('Tree view', () => { .should('be.visible') // the first job should have 5 outputs (the maximum number we display) - .first() + .first().as('firstJobNode') .find('.message-output') .should('have.length', 5) // the remainder should be referenced in an overflow counter +2 - .parent() + .get('@firstJobNode') + .find('[data-cy=chip-overflow]') .contains('+2') - .parent() - .parent() - .parent() - .parent() + .parents('.treeitem') + .first() // expand the job details node .find('.node-expand-collapse-button')