-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from OnroerendErfgoed/develop
Release 0.16.0
- Loading branch information
Showing
9 changed files
with
251 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,22 +79,19 @@ yarn storybook | |
yarn build:watch | ||
``` | ||
|
||
#### Symlink | ||
|
||
A symlink can be created between the library and implementing applications. | ||
#### Yalc - for sharing locally developed packages across your local environment. - https://github.com/wclr/yalc | ||
|
||
```sh | ||
yarn link | ||
Yalc publish | ||
``` | ||
|
||
Afterwards link the package in the desired implementing application. | ||
|
||
```sh | ||
yarn link "vue-components" | ||
yalc add @OnroerendErfgoed/[email protected] | ||
yalc update | ||
yarn | ||
``` | ||
|
||
Whilst running the `build:watch` command, changes in the library will automatically be reflected in linked applications. | ||
|
||
### Type-Check, Compile and Minify for Production | ||
|
||
```sh | ||
|
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 |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/* eslint-disable vue/one-component-per-file */ | ||
import { defineComponent, ref } from 'vue'; | ||
import OeSelect from '@components/dumb/OeSelect.vue'; | ||
import type { ISelectOption } from '@models/select'; | ||
|
||
describe('Select', () => { | ||
const select = () => cy.dataCy('oe-select'); | ||
const dropdown = () => cy.get('.vl-select__list.vl-select__list--dropdown'); | ||
const selectItemPlaceholder = () => cy.get('.vl-select__item.vl-select__item--choice.is-placeholder'); | ||
const selectedItem = () => cy.get('.vl-select__item.vl-select__item--selectable'); | ||
const selectableItems = () => cy.get('.vl-select__item.vl-select__item--choice.vl-select__item--selectable'); | ||
|
||
describe('default', () => { | ||
const TestComponent = defineComponent({ | ||
components: { OeSelect }, | ||
setup() { | ||
const modelValue = ref<ISelectOption>(); | ||
const options: ISelectOption[] = [ | ||
{ label: 'België', value: 'België' }, | ||
{ label: 'Frankrijk', value: 'Frankrijk' }, | ||
{ label: 'Duitsland - Land in Centraal-Europa.', value: 'Duitsland' }, | ||
]; | ||
const customLabel = (option: ISelectOption) => option?.label; | ||
|
||
return { options, customLabel, modelValue }; | ||
}, | ||
template: '<OeSelect v-model="modelValue" :custom-label="customLabel" :options="options"/>', | ||
}); | ||
|
||
it('renders a custom select with placeholder', () => { | ||
cy.mount(TestComponent); | ||
cy.get('.js-vl-select') | ||
.should('exist') | ||
.should('be.visible') | ||
.find('.vl-select__inner > .vl-input-field') | ||
.should('be.visible') | ||
.find('.vl-select__item.item--placeholder') | ||
.invoke('text') | ||
.should('equal', 'Selecteer een optie'); | ||
}); | ||
|
||
it('does not show the dropdown', () => { | ||
cy.mount(TestComponent); | ||
dropdown().should('not.exist'); | ||
}); | ||
|
||
it('shows the dropdown when clicking at the select element', () => { | ||
cy.mount(TestComponent); | ||
select().click(); | ||
dropdown().should('exist'); | ||
}); | ||
|
||
it('renders the placeholder as first element', () => { | ||
cy.mount(TestComponent); | ||
select().click(); | ||
selectItemPlaceholder().invoke('text').should('equal', 'Selecteer een optie'); | ||
}); | ||
|
||
it('renders all options with custom label', () => { | ||
cy.mount(TestComponent).then(({ component }) => { | ||
select().click(); | ||
selectableItems().each((option, i) => { | ||
expect(option.text()).to.equal(component.options[i].label); | ||
}); | ||
}); | ||
}); | ||
|
||
it('updates the model value and closes the dropdown when item is selected', () => { | ||
cy.mount(TestComponent).then(({ component }) => { | ||
select().click(); | ||
selectableItems() | ||
.first() | ||
.click() | ||
.then(() => { | ||
selectedItem().invoke('text').should('equal', component.options[0].label); | ||
expect(component.modelValue).to.deep.equal(component.options[0]); | ||
dropdown().should('not.exist'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('highlights the selected item', () => { | ||
cy.mount(TestComponent); | ||
select().click(); | ||
selectableItems() | ||
.first() | ||
.click() | ||
.then(() => { | ||
select().click(); | ||
selectableItems().first().should('have.class', 'is-highlighted'); | ||
selectableItems().last().should('not.have.class', 'is-highlighted'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('custom placeholder', () => { | ||
const TestComponent = defineComponent({ | ||
components: { OeSelect }, | ||
template: '<OeSelect placeholder="My custom placeholder"/>', | ||
}); | ||
|
||
it('renders a select with custom placeholder', () => { | ||
cy.mount(TestComponent); | ||
cy.get('.js-vl-select') | ||
.should('exist') | ||
.should('be.visible') | ||
.find('.vl-select__inner > .vl-input-field') | ||
.should('be.visible') | ||
.find('.vl-select__item.item--placeholder') | ||
.invoke('text') | ||
.should('equal', 'My custom placeholder'); | ||
}); | ||
|
||
it('renders the custom placeholder as first element', () => { | ||
cy.mount(TestComponent); | ||
select().click(); | ||
selectItemPlaceholder().invoke('text').should('equal', 'My custom placeholder'); | ||
}); | ||
}); | ||
|
||
describe('selected value', () => { | ||
const TestComponent = defineComponent({ | ||
components: { OeSelect }, | ||
setup() { | ||
const modelValue = ref<ISelectOption>({ label: 'België', value: 'België' }); | ||
const options: ISelectOption[] = [ | ||
{ label: 'België', value: 'België' }, | ||
{ label: 'Frankrijk', value: 'Frankrijk' }, | ||
{ label: 'Duitsland - Land in Centraal-Europa.', value: 'Duitsland' }, | ||
]; | ||
const customLabel = (option: ISelectOption) => option?.label; | ||
|
||
return { options, customLabel, modelValue }; | ||
}, | ||
template: '<OeSelect v-model="modelValue" :custom-label="customLabel" :options="options"/>', | ||
}); | ||
|
||
it('selects the initial boundend value', () => { | ||
cy.mount(TestComponent).then(({ component }) => { | ||
selectedItem().invoke('text').should('equal', component.modelValue.label); | ||
}); | ||
}); | ||
|
||
it('updates the value after modelValue changed', () => { | ||
cy.mount(TestComponent).then(({ component }) => { | ||
component.modelValue = component.options[1]; | ||
selectedItem().invoke('text').should('equal', component.options[1].label); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
export class User { | ||
public actor: IUserActor; | ||
public groups: string[]; | ||
public organisatie: IOrganisatie; | ||
public personid: string; | ||
public persoonsgegevens: IPersoonsgegevens; | ||
public ssoToken: string; | ||
public userid: string; | ||
|
||
constructor(user: IUser) { | ||
this.actor = user.actor; | ||
this.groups = user.groups; | ||
this.organisatie = user.organisatie; | ||
this.personid = user.personid; | ||
this.persoonsgegevens = user.persoonsgegevens; | ||
this.ssoToken = user.sso_token; | ||
this.userid = user.userid; | ||
} | ||
|
||
public hasRole(role: string): boolean { | ||
return !!this.groups?.find((group) => group === role); | ||
} | ||
} | ||
|
||
/* User object */ | ||
export interface IUser { | ||
actor: IUserActor; | ||
groups: string[]; | ||
organisatie: IOrganisatie; | ||
personid: string; | ||
persoonsgegevens: IPersoonsgegevens; | ||
sso_token: string; | ||
userid: string; | ||
} | ||
|
||
interface IUserActor { | ||
erkenningen: IErkenning[]; | ||
id: number; | ||
instantie_actor_omschrijving: string; | ||
instantie_actor_uri: string; | ||
omschrijving: string; | ||
uid: string; | ||
uri: string; | ||
} | ||
|
||
interface IErkenning { | ||
erkend_als: string; | ||
erkend_voor: string; | ||
erkenningsnummer: string; | ||
geldigheid: string; | ||
id: number; | ||
omschrijving: string; | ||
reden_erkenning: IRedenErkenning; | ||
type: string; | ||
type_erkenning_id: number; | ||
uri: string; | ||
} | ||
|
||
interface IRedenErkenning { | ||
id: number; | ||
reden_erkenning: string; | ||
} | ||
|
||
interface IOrganisatie { | ||
id: string; | ||
naam: string; | ||
type: string; | ||
} | ||
|
||
interface IPersoonsgegevens { | ||
email: string; | ||
naam: string; | ||
omschrijving: string; | ||
rijksregisternummer: string; | ||
voornaam: string; | ||
} |