mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Fix cypress tests/start refactor search story
- Cannot use data-test in cypress tests as we use production image and data-test are removed to minimize the image. Select based on styleguide input's class - Story is still not working because of filter dateTime and $i18n.locale(), we can fix this later. - Co-authored-by: Moriz Wahl <moriz.wahl@gmx.de>
This commit is contained in:
parent
e6f1672067
commit
84780013f4
@ -1,6 +1,6 @@
|
|||||||
import { When, Then } from "cypress-cucumber-preprocessor/steps";
|
import { When, Then } from "cypress-cucumber-preprocessor/steps";
|
||||||
When("I search for {string}", value => {
|
When("I search for {string}", value => {
|
||||||
cy.get("[data-test='search-field']")
|
cy.get(".searchable-input .ds-select-search")
|
||||||
.focus()
|
.focus()
|
||||||
.type(value);
|
.type(value);
|
||||||
});
|
});
|
||||||
@ -16,7 +16,7 @@ Then("the search has no results", () => {
|
|||||||
expect($li).to.have.length(1);
|
expect($li).to.have.length(1);
|
||||||
});
|
});
|
||||||
cy.get(".ds-select-dropdown").should("contain", 'Nothing found');
|
cy.get(".ds-select-dropdown").should("contain", 'Nothing found');
|
||||||
cy.get("[data-test='search-field']")
|
cy.get(".searchable-input .ds-select-search")
|
||||||
.focus()
|
.focus()
|
||||||
.type("{esc}");
|
.type("{esc}");
|
||||||
});
|
});
|
||||||
@ -35,21 +35,21 @@ Then("I should see the following users in the select dropdown:", table => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
When("I type {string} and press Enter", value => {
|
When("I type {string} and press Enter", value => {
|
||||||
cy.get("[data-test='search-field']")
|
cy.get(".searchable-input .ds-select-search")
|
||||||
.focus()
|
.focus()
|
||||||
.type(value)
|
.type(value)
|
||||||
.type("{enter}", { force: true });
|
.type("{enter}", { force: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
When("I type {string} and press escape", value => {
|
When("I type {string} and press escape", value => {
|
||||||
cy.get("[data-test='search-field']")
|
cy.get(".searchable-input .ds-select-search")
|
||||||
.focus()
|
.focus()
|
||||||
.type(value)
|
.type(value)
|
||||||
.type("{esc}");
|
.type("{esc}");
|
||||||
});
|
});
|
||||||
|
|
||||||
Then("the search field should clear", () => {
|
Then("the search field should clear", () => {
|
||||||
cy.get("[data-test='search-field']").should("have.text", "");
|
cy.get(".searchable-input .ds-select-search").should("have.text", "");
|
||||||
});
|
});
|
||||||
|
|
||||||
When("I select a post entry", () => {
|
When("I select a post entry", () => {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { config, mount } from '@vue/test-utils'
|
|||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import SearchField from './SearchField.vue'
|
import SearchField from './SearchField.vue'
|
||||||
import SearchableInput from '~/components/generic/SearchableInput/SearchableInput'
|
import SearchableInput from '~/components/generic/SearchableInput/SearchableInput'
|
||||||
import { results as searchResults } from './SearchField.story'
|
import { searchResults } from '~/components/generic/SearchableInput/SearchableInput.story'
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
localVue.filter('truncate', () => 'truncated string')
|
localVue.filter('truncate', () => 'truncated string')
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { config, mount } from '@vue/test-utils'
|
|||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import SearchableInput from './SearchableInput'
|
import SearchableInput from './SearchableInput'
|
||||||
import { results } from '~/components/features/SearchField/SearchField.story'
|
import { searchResults } from '~/components/generic/SearchableInput/SearchableInput.story'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ describe('SearchableInput.vue', () => {
|
|||||||
|
|
||||||
describe('navigating to resource', () => {
|
describe('navigating to resource', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
propsData = { options: results }
|
propsData = { options: searchResults }
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
select = wrapper.find('.ds-select')
|
select = wrapper.find('.ds-select')
|
||||||
select.trigger('focus')
|
select.trigger('focus')
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { storiesOf } from '@storybook/vue'
|
import { storiesOf } from '@storybook/vue'
|
||||||
import { withA11y } from '@storybook/addon-a11y'
|
import { withA11y } from '@storybook/addon-a11y'
|
||||||
import SearchField from './SearchField.vue'
|
import SearchableInput from './SearchableInput.vue'
|
||||||
import helpers from '~/storybook/helpers'
|
import helpers from '~/storybook/helpers'
|
||||||
|
|
||||||
helpers.init()
|
helpers.init()
|
||||||
|
|
||||||
export const results = [
|
export const searchResults = [
|
||||||
{
|
{
|
||||||
id: 'post-by-jenny',
|
id: 'post-by-jenny',
|
||||||
__typename: 'Post',
|
__typename: 'Post',
|
||||||
@ -104,14 +104,12 @@ storiesOf('Search Field', module)
|
|||||||
.addDecorator(withA11y)
|
.addDecorator(withA11y)
|
||||||
.addDecorator(helpers.layout)
|
.addDecorator(helpers.layout)
|
||||||
.add('test', () => ({
|
.add('test', () => ({
|
||||||
components: { SearchField },
|
components: { SearchableInput },
|
||||||
store: helpers.store,
|
store: helpers.store,
|
||||||
data: () => ({
|
data: () => ({
|
||||||
results: results,
|
searchResults,
|
||||||
}),
|
}),
|
||||||
template: `
|
template: `
|
||||||
<search-field
|
<searchable-input :options="searchResults" />
|
||||||
:searchResults="results"
|
|
||||||
/>
|
|
||||||
`,
|
`,
|
||||||
}))
|
}))
|
||||||
@ -185,7 +185,6 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
&,
|
|
||||||
.ds-select-dropdown {
|
.ds-select-dropdown {
|
||||||
transition: box-shadow 100ms;
|
transition: box-shadow 100ms;
|
||||||
max-height: 70vh;
|
max-height: 70vh;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user