-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor): Show v1 banner dismiss button if owner (#7722)
Github issue / Community forum post (link here to close automatically): https://community.n8n.io/t/v1-upgrade-banner-shall-be-dismissed-permanently/32775
- Loading branch information
Showing
3 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/editor-ui/src/components/banners/__tests__/V1Banner.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { render } from '@testing-library/vue'; | ||
import V1Banner from '../V1Banner.vue'; | ||
import { createPinia, setActivePinia } from 'pinia'; | ||
import { useUsersStore } from '@/stores/users.store'; | ||
|
||
describe('V1 Banner', () => { | ||
let pinia: ReturnType<typeof createPinia>; | ||
let usersStore: ReturnType<typeof useUsersStore>; | ||
|
||
beforeEach(async () => { | ||
pinia = createPinia(); | ||
setActivePinia(pinia); | ||
|
||
usersStore = useUsersStore(); | ||
}); | ||
|
||
it('should render banner', () => { | ||
const { container } = render(V1Banner); | ||
expect(container).toMatchSnapshot(); | ||
expect(container.querySelectorAll('a')).toHaveLength(1); | ||
}); | ||
|
||
it('should render banner with dismiss call if user is owner', () => { | ||
vi.spyOn(usersStore, 'currentUser', 'get').mockReturnValue({ | ||
globalRole: { | ||
id: 0, | ||
name: 'owner', | ||
createdAt: '2021-08-09T14:00:00.000Z', | ||
}, | ||
}); | ||
|
||
const { container } = render(V1Banner); | ||
expect(container).toMatchSnapshot(); | ||
expect(container.querySelectorAll('a')).toHaveLength(2); | ||
}); | ||
}); |
101 changes: 101 additions & 0 deletions
101
packages/editor-ui/src/components/banners/__tests__/__snapshots__/V1Banner.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`V1 Banner > should render banner 1`] = ` | ||
<div> | ||
<n8n-callout | ||
class="v1container" | ||
data-test-id="banners-V1" | ||
icon="info-circle" | ||
iconsize="medium" | ||
roundcorners="false" | ||
theme="warning" | ||
> | ||
<div | ||
class="mainContent keepSpace" | ||
> | ||
<span> | ||
n8n has been updated to version 1, introducing some breaking changes. Please consult the | ||
<a | ||
href="https://docs.n8n.io/1-0-migration-checklist" | ||
target="_blank" | ||
> | ||
migration guide | ||
</a> | ||
for more information. | ||
</span> | ||
<!--v-if--> | ||
</div> | ||
</n8n-callout> | ||
</div> | ||
`; | ||
|
||
exports[`V1 Banner > should render banner if user is not woner 1`] = ` | ||
<div> | ||
<n8n-callout | ||
class="v1container" | ||
data-test-id="banners-V1" | ||
icon="info-circle" | ||
iconsize="medium" | ||
roundcorners="false" | ||
theme="warning" | ||
> | ||
<div | ||
class="mainContent keepSpace" | ||
> | ||
<span> | ||
n8n has been updated to version 1, introducing some breaking changes. Please consult the | ||
<a | ||
href="https://docs.n8n.io/1-0-migration-checklist" | ||
target="_blank" | ||
> | ||
migration guide | ||
</a> | ||
for more information. | ||
</span> | ||
<!--v-if--> | ||
</div> | ||
</n8n-callout> | ||
</div> | ||
`; | ||
|
||
exports[`V1 Banner > should render banner with dismiss call if user is owner 1`] = ` | ||
<div> | ||
<n8n-callout | ||
class="v1container" | ||
data-test-id="banners-V1" | ||
icon="info-circle" | ||
iconsize="medium" | ||
roundcorners="false" | ||
theme="warning" | ||
> | ||
<div | ||
class="mainContent keepSpace" | ||
> | ||
<span> | ||
n8n has been updated to version 1, introducing some breaking changes. Please consult the | ||
<a | ||
href="https://docs.n8n.io/1-0-migration-checklist" | ||
target="_blank" | ||
> | ||
migration guide | ||
</a> | ||
for more information. | ||
</span> | ||
<a | ||
class="link" | ||
data-test-id="banner-confirm-v1" | ||
> | ||
<span> | ||
Don't show again | ||
</span> | ||
</a> | ||
</div> | ||
</n8n-callout> | ||
</div> | ||
`; |