-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FSADT1-1429): Unregistered business client type is only viewed b… (
- Loading branch information
1 parent
bd34c52
commit 14c5949
Showing
5 changed files
with
88 additions
and
29 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
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 |
---|---|---|
|
@@ -636,7 +636,7 @@ public class TestConstants { | |
"", | ||
"forest1", | ||
"U", | ||
"I", | ||
"USP", | ||
"", | ||
"SP", | ||
LocalDate.of(1975, 1, 31), | ||
|
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
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
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 |
---|---|---|
@@ -1,34 +1,84 @@ | ||
import { createRouter, createMemoryHistory } from 'vue-router'; | ||
import { describe, it, expect } from "vitest"; | ||
import { describe, it, expect, vi } from "vitest"; | ||
import { mount } from '@vue/test-utils'; | ||
import FormStaffPage from '@/pages/FormStaffPage.vue'; | ||
import ForestClientUserSession from '@/helpers/ForestClientUserSession'; | ||
|
||
describe('FormStaffPage', () => { | ||
// Mocking the ForestClientUserSession | ||
vi.mock('@/helpers/ForestClientUserSession', () => ({ | ||
default: { | ||
authorities: [] | ||
} | ||
})); | ||
|
||
it('renders the clientType dropdown with the expected order of elements', async () => { | ||
const router = createRouter({ | ||
history: createMemoryHistory(), | ||
routes: [{ path: '/', component: FormStaffPage },], | ||
}); | ||
describe('FormStaffPage', () => { | ||
const router = createRouter({ | ||
history: createMemoryHistory(), | ||
routes: [{ path: '/', component: FormStaffPage }], | ||
}); | ||
|
||
const wrapper = mount(FormStaffPage, { | ||
const mountComponent = () => { | ||
return mount(FormStaffPage, { | ||
global: { | ||
plugins: [router], | ||
}, | ||
}); | ||
}; | ||
|
||
it('renders the clientType dropdown with the expected order of elements for a non-admin user', async () => { | ||
// Mock as non-admin user | ||
ForestClientUserSession.authorities = []; | ||
|
||
const wrapper = mountComponent(); | ||
const clientTypeDropdown = wrapper.find('#clientType'); | ||
|
||
// Extract the innerHTML of the dropdown | ||
const dropdownHTML = clientTypeDropdown.element.innerHTML; | ||
|
||
// Parse the innerHTML to extract the text content of each dropdown item | ||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(`<cds-combo-box>${dropdownHTML}</cds-combo-box>`, 'text/html'); | ||
const dropdownItems = doc.querySelectorAll('cds-combo-box-item'); | ||
|
||
const dropdownValues = Array.from(dropdownItems).map(item => item.textContent.trim()); | ||
|
||
const expectedDropdownValues = [ | ||
'Individual', | ||
'BC registered business', | ||
'First Nation', | ||
'Government', | ||
'Ministry of Forests', | ||
]; | ||
|
||
expect(dropdownValues).toEqual(expectedDropdownValues); | ||
}); | ||
|
||
it('renders the clientType dropdown with the expected order of elements for an admin user', async () => { | ||
// Mock as admin user | ||
ForestClientUserSession.authorities = ['CLIENT_ADMIN']; | ||
|
||
const wrapper = mountComponent(); | ||
const clientTypeDropdown = wrapper.find('#clientType'); | ||
|
||
// Extract the innerHTML of the dropdown | ||
const dropdownHTML = clientTypeDropdown.element.innerHTML; | ||
|
||
// Parse the innerHTML to extract the text content of each dropdown item | ||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(`<cds-combo-box>${dropdownHTML}</cds-combo-box>`, 'text/html'); | ||
const dropdownItems = doc.querySelectorAll('cds-combo-box-item'); | ||
|
||
// Extract the text content from each dropdown item | ||
const dropdownValues = Array.from(dropdownItems).map(item => item.textContent.trim()); | ||
|
||
expect(dropdownValues).toEqual(['Individual','BC registered business','First Nation','Government','Ministry of Forests','Unregistered company']); | ||
|
||
const expectedDropdownValues = [ | ||
'Individual', | ||
'BC registered business', | ||
'First Nation', | ||
'Government', | ||
'Ministry of Forests', | ||
'Unregistered company', | ||
]; | ||
|
||
expect(dropdownValues).toEqual(expectedDropdownValues); | ||
}); | ||
}); | ||
}); |