Skip to content

Commit 301cfc2

Browse files
authored
NXT-4160: fix inconsistent error toast message (#68)
NXT-4160 (Fix inconsistent message to copy stacktrace)
1 parent 18bb7f5 commit 301cfc2

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.changeset/breezy-doors-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@knime/hub-features": patch
3+
---
4+
5+
Fix inconsistent error toast text when stack trace is provided but copying to clipboard is not allowed

packages/hub-features/src/rfcErrors/RFCErrorToastTemplate.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ const onShowDetailsClicked = () => {
102102
<div class="title">
103103
{{ props.title }}
104104
</div>
105-
<button v-if="!showDetails" class="show-more" @click="onShowDetailsClicked">
105+
<button
106+
v-if="!showDetails"
107+
data-test-id="show-details"
108+
class="show-more"
109+
@click="onShowDetailsClicked"
110+
>
106111
Show details
107112
</button>
108113
<div v-if="showDetails" class="additional-info">
@@ -124,11 +129,11 @@ const onShowDetailsClicked = () => {
124129
<div v-if="date"><strong>Date: </strong>{{ formattedDate }}</div>
125130
<div v-if="requestId"><strong>Request id: </strong>{{ requestId }}</div>
126131
<div v-if="errorId"><strong>Error id: </strong>{{ errorId }}</div>
127-
<div v-if="stacktrace">
132+
<div v-if="stacktrace && canCopyToClipboard">
128133
<strong>Stacktrace: </strong>Part of clipboard text
129134
</div>
130135
<div v-if="canCopyToClipboard" class="copy-button-wrapper">
131-
<Button @click="copyToClipboard">
136+
<Button data-test-id="copy-to-clipboard" @click="copyToClipboard">
132137
<template v-if="copied">
133138
<CheckIcon class="copy-icon" />Error was copied
134139
</template>

packages/hub-features/src/rfcErrors/__tests__/RFCErrorToastTemplate.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ describe("RFCErrorToastTemplate", () => {
7777
const { wrapper, copyMock } = doMount({
7878
...defaultProps,
7979
stacktrace: "cannot read property explosion of undefined at foo.bar.baz",
80+
canCopyToClipboard: false,
8081
} as any);
81-
await wrapper.find("button").trigger("click");
82+
83+
await wrapper.find("[data-test-id='show-details']").trigger("click");
84+
85+
expect(wrapper.text()).not.toContain("Stacktrace: Part of clipboard text");
86+
await wrapper.setProps({ canCopyToClipboard: true });
8287
expect(wrapper.text()).toContain("Stacktrace: Part of clipboard text");
8388

84-
await wrapper.find("button").trigger("click"); // first show details
85-
await wrapper.find("button").trigger("click"); // then the clipboard button
89+
await wrapper.find("[data-test-id='copy-to-clipboard']").trigger("click");
8690

8791
// @ts-expect-error
8892
const copiedText = copyMock.mock.calls[0][0];

0 commit comments

Comments
 (0)