Add new test for instruments page, start refactor and style changes

This commit is contained in:
Ramon Wenger 2021-10-20 13:57:32 +02:00
parent 3c03e3c741
commit 5fd5a5be4a
7 changed files with 96 additions and 46 deletions

View File

@ -2,7 +2,7 @@
const path = require('path'); const path = require('path');
const config = require('../config'); const config = require('../config');
const VueLoaderPlugin = require('vue-loader/lib/plugin'); const {VueLoaderPlugin} = require('vue-loader');
const {isDev, styleRule, assetsPath} = require('./utils'); const {isDev, styleRule, assetsPath} = require('./utils');
@ -42,7 +42,7 @@ module.exports = {
alias: { alias: {
'@': resolve('src'), '@': resolve('src'),
styles: resolve('src/styles'), styles: resolve('src/styles'),
gql: resolve('src/graphql/gql') gql: resolve('src/graphql/gql'),
}, },
}, },
module: { module: {
@ -64,9 +64,9 @@ module.exports = {
test: /\.tsx?$/, test: /\.tsx?$/,
loader: 'ts-loader', loader: 'ts-loader',
options: { options: {
appendTsSuffixTo: [/\.vue$/] appendTsSuffixTo: [/\.vue$/],
}, },
exclude: /node_modules/ exclude: /node_modules/,
}, },
{ {
test: /\.js$/, test: /\.js$/,
@ -79,7 +79,7 @@ module.exports = {
{ {
test: /\.(gql|graphql)$/, test: /\.(gql|graphql)$/,
loader: 'graphql-tag/loader', loader: 'graphql-tag/loader',
exclude: /node_modules/ exclude: /node_modules/,
}, },
{ {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

View File

@ -20,11 +20,13 @@ const classMemberIdIterator = idGenerator('ClassMemberNode');
const chapterIdIterator = idGenerator('ChapterNode'); const chapterIdIterator = idGenerator('ChapterNode');
const moduleIdIterator = idGenerator('ModuleNode'); const moduleIdIterator = idGenerator('ModuleNode');
const contentBlockIdIterator = idGenerator('ContentBlockNode'); const contentBlockIdIterator = idGenerator('ContentBlockNode');
const instrumentIdGenerator = idGenerator('InstrumentNode');
const getClassMemberId = () => classMemberIdIterator.next().value; const getClassMemberId = () => classMemberIdIterator.next().value;
const getChapterId = () => chapterIdIterator.next().value; const getChapterId = () => chapterIdIterator.next().value;
const getModuleId = () => moduleIdIterator.next().value; const getModuleId = () => moduleIdIterator.next().value;
const getContentBlockId = () => contentBlockIdIterator.next().value; const getContentBlockId = () => contentBlockIdIterator.next().value;
const getInstrumentId = () => instrumentIdGenerator.next().value;
export default { export default {
UUID: () => '123-456-789', UUID: () => '123-456-789',
@ -109,4 +111,10 @@ export default {
title: 'A Room Entry', title: 'A Room Entry',
contents: [], contents: [],
}), }),
InstrumentNode: () => ({
contents: [],
title: 'instrument-title',
slug: 'instrument-slug',
id: getInstrumentId(),
})
}; };

View File

@ -8,10 +8,20 @@ describe('Instruments Page', () => {
operations: { operations: {
MeQuery: {}, MeQuery: {},
InstrumentsQuery: { InstrumentsQuery: {
instruments: [] instruments: [
{},
{}
]
} }
} }
}); });
cy.visit('instruments/'); cy.visit('instruments/');
cy.getByDataCy('filter-all-instruments').should('exist');
cy.getByDataCy('filter-language-communication').should('exist');
cy.getByDataCy('filter-society').should('exist');
cy.getByDataCy('filter-interdisciplinary').should('exist');
cy.getByDataCy('filter-analysis').should('exist');
cy.getByDataCy('filter-ethics').should('exist');
}); });
}); });

View File

@ -18294,6 +18294,13 @@
"integrity": "sha512-q8GgAIPU7xHCsUhB1PUgR//8GoI0bUdMRUKd69jw2UcKy7pGuu0NbJsOGqdSpdpvhO4LY/dgqohPEkE1TrBwKQ==", "integrity": "sha512-q8GgAIPU7xHCsUhB1PUgR//8GoI0bUdMRUKd69jw2UcKy7pGuu0NbJsOGqdSpdpvhO4LY/dgqohPEkE1TrBwKQ==",
"requires": { "requires": {
"vue": "^2.1.10" "vue": "^2.1.10"
},
"dependencies": {
"vue": {
"version": "2.6.14",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.14.tgz",
"integrity": "sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ=="
}
} }
}, },
"svgo": { "svgo": {
@ -19724,6 +19731,13 @@
"babel-preset-env": "^1.6.0", "babel-preset-env": "^1.6.0",
"rollup-plugin-babel": "^3.0.2", "rollup-plugin-babel": "^3.0.2",
"vue": "^2.4.4" "vue": "^2.4.4"
},
"dependencies": {
"vue": {
"version": "2.6.14",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.14.tgz",
"integrity": "sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ=="
}
} }
}, },
"vuejs-logger": { "vuejs-logger": {

View File

@ -0,0 +1,25 @@
<template>
<div class="filter-group">
<a v-bind="$attrs">{{ title }}</a>
</div>
</template>
<script>
export default {
props: {
title: {
type: String,
default: ''
}
},
inheritAttrs: false
};
</script>
<style scoped lang="scss">
@import '~styles/helpers';
.filter-group {
border-bottom: 1px solid black;
}
</style>

View File

@ -1,24 +1,33 @@
<template> <template>
<div class="instrument-filter"> <div class="instrument-filter">
<checkbox <filter-group
:checked="type.enabled" title="Alle Instrumente"
:class="`instrument-filter__checkbox--${type.cls}`" data-cy="filter-all-instruments"/>
:label="type.label"
:key="i" <filter-group
class="instrument-filter__checkbox" title="Sprache und Kommunikation"
v-for="(type, i) in types" data-cy="filter-language-communication"/>
@input="change($event, i)"
/> <filter-group
title="Gesellschaft"
data-cy="filter-society"/>
<filter-group
title="Überfachliche Instrumente"
data-cy="filter-society"/>
</div> </div>
</template> </template>
<script> <script>
import Checkbox from '@/components/ui/Checkbox'; import Checkbox from '@/components/ui/Checkbox';
import FilterGroup from '@/components/instruments/FilterGroup';
export default { export default {
components: { components: {
Checkbox FilterGroup,
Checkbox,
}, },
data() { data() {
return { return {
@ -28,21 +37,21 @@
label: 'Sprache und Kommunikation', label: 'Sprache und Kommunikation',
enabled: true, enabled: true,
prop: 'LANGUAGE_COMMUNICATION', prop: 'LANGUAGE_COMMUNICATION',
cls: 'language' cls: 'language',
}, },
{ {
label: 'Gesellschaft', label: 'Gesellschaft',
enabled: true, enabled: true,
prop: 'SOCIETY', prop: 'SOCIETY',
cls: 'society' cls: 'society',
}, },
{ {
label: 'Überfachliches Instrument', label: 'Überfachliches Instrument',
enabled: true, enabled: true,
prop: 'INTERDISCIPLINARY', prop: 'INTERDISCIPLINARY',
cls: 'interdisciplinary' cls: 'interdisciplinary',
}, },
] ],
}; };
}, },
@ -53,26 +62,27 @@
...this.types.slice(0, index), ...this.types.slice(0, index),
{ {
...type, ...type,
enabled enabled,
}, },
...this.types.slice(index + 1), ...this.types.slice(index + 1),
]; ];
this.$emit('filter', this.$emit('filter',
this.types this.types
.filter(t => t.enabled) .filter(t => t.enabled)
.map(t => t.prop) .map(t => t.prop),
); );
} },
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "@/styles/_variables.scss"; @import "~styles/helpers";
.instrument-filter { .instrument-filter {
display: flex; display: flex;
align-content: center; flex-direction: column;
//align-content: center;
&__checkbox { &__checkbox {
&--language { &--language {

View File

@ -1,10 +1,5 @@
<template> <template>
<div class="instrument-overview"> <div class="instrument-overview">
<div class="instrument-overview__heading">
<h1 class="instrument-overview__title">
Instrumente
</h1>
</div>
<instrument-filter <instrument-filter
class="instrument-overview__filter" class="instrument-overview__filter"
@filter="updateFilter"/> @filter="updateFilter"/>
@ -65,24 +60,12 @@
.instrument-overview { .instrument-overview {
display: grid; display: grid;
grid-template-rows: auto auto 1fr; //grid-template-rows: auto auto 1fr;
@include centered(800px); grid-template-columns: 300px auto;
//@include centered(800px);
&__heading {
padding: 2*$large-spacing 0;
width: 100%;
display: flex;
justify-content: flex-start;
}
&__title {
max-width: $screen-width;
line-height: 1.2;
margin-bottom: 0;
}
&__filter { &__filter {
justify-self: start;
} }
&__list { &__list {