@@ -2,38 +2,14 @@ import { getLocalVue } from "@tests/jest/helpers";
22import { shallowMount } from "@vue/test-utils" ;
33import { createPinia } from "pinia" ;
44
5+ import type { RegisteredUser } from "@/api" ;
56import { useUserStore } from "@/stores/userStore" ;
67
78import HistoryNavigation from "./HistoryNavigation.vue" ;
89
910const localVue = getLocalVue ( ) ;
1011
11- // all options
12- const expectedOptions = [
13- "Show Histories Side-by-Side" ,
14- "Resume Paused Jobs" ,
15- "Copy this History" ,
16- "Delete this History" ,
17- "Export Tool References" ,
18- "Export History to File" ,
19- "Archive History" ,
20- "Extract Workflow" ,
21- "Show Invocations" ,
22- "Share & Manage Access" ,
23- ] ;
24-
25- // options enabled for logged-out users
26- const anonymousOptions = [
27- "Resume Paused Jobs" ,
28- "Delete this History" ,
29- "Export Tool References" ,
30- "Export History to File" ,
31- ] ;
32-
33- // options disabled for logged-out users
34- const anonymousDisabledOptions = expectedOptions . filter ( ( option ) => ! anonymousOptions . includes ( option ) ) ;
35-
36- async function createWrapper ( propsData : object , userData ?: any ) {
12+ async function createWrapper ( propsData : object , userData ?: Partial < RegisteredUser > ) {
3713 const pinia = createPinia ( ) ;
3814
3915 const wrapper = shallowMount ( HistoryNavigation as object , {
@@ -43,7 +19,7 @@ async function createWrapper(propsData: object, userData?: any) {
4319 } ) ;
4420
4521 const userStore = useUserStore ( ) ;
46- userStore . currentUser = { ...userStore . currentUser , ...userData } ;
22+ userStore . currentUser = { ...( userStore . currentUser as RegisteredUser ) , ...userData } ;
4723
4824 return wrapper ;
4925}
@@ -65,12 +41,6 @@ describe("History Navigation", () => {
6541 expect ( createButton . attributes ( ) . disabled ) . toBeFalsy ( ) ;
6642 const switchButton = wrapper . find ( "*[data-description='switch to another history']" ) ;
6743 expect ( switchButton . attributes ( ) . disabled ) . toBeFalsy ( ) ;
68-
69- const dropDown = wrapper . find ( "*[data-description='history options']" ) ;
70- const optionElements = dropDown . findAll ( "bdropdownitem-stub" ) ;
71- const optionTexts = optionElements . wrappers . map ( ( el ) => el . text ( ) ) ;
72-
73- expect ( optionTexts ) . toStrictEqual ( expectedOptions ) ;
7444 } ) ;
7545
7646 it ( "disables options for anonymous users" , async ( ) => {
@@ -83,28 +53,5 @@ describe("History Navigation", () => {
8353 expect ( createButton . attributes ( ) . disabled ) . toBeTruthy ( ) ;
8454 const switchButton = wrapper . find ( "*[data-description='switch to another history']" ) ;
8555 expect ( switchButton . attributes ( ) . disabled ) . toBeTruthy ( ) ;
86-
87- const dropDown = wrapper . find ( "*[data-description='history options']" ) ;
88- const enabledOptionElements = dropDown . findAll ( "bdropdownitem-stub:not([disabled])" ) ;
89- const enabledOptionTexts = enabledOptionElements . wrappers . map ( ( el ) => el . text ( ) ) ;
90- expect ( enabledOptionTexts ) . toStrictEqual ( anonymousOptions ) ;
91-
92- const disabledOptionElements = dropDown . findAll ( "bdropdownitem-stub[disabled]" ) ;
93- const disabledOptionTexts = disabledOptionElements . wrappers . map ( ( el ) => el . text ( ) ) ;
94- expect ( disabledOptionTexts ) . toStrictEqual ( anonymousDisabledOptions ) ;
95- } ) ;
96-
97- it ( "prompts anonymous users to log in" , async ( ) => {
98- const wrapper = await createWrapper ( {
99- history : { id : "current_history_id" } ,
100- histories : [ ] ,
101- } ) ;
102-
103- const dropDown = wrapper . find ( "*[data-description='history options']" ) ;
104- const disabledOptionElements = dropDown . findAll ( "bdropdownitem-stub[disabled]" ) ;
105-
106- disabledOptionElements . wrappers . forEach ( ( option ) => {
107- expect ( ( option . attributes ( "title" ) as string ) . toLowerCase ( ) ) . toContain ( "log in" ) ;
108- } ) ;
10956 } ) ;
11057} ) ;
0 commit comments