Update failing frontend tests

This commit is contained in:
Ramon Wenger 2021-10-07 17:09:24 +02:00
parent 4f9d3bc33d
commit 42201c1b77
6 changed files with 29 additions and 32 deletions

View File

@ -25,24 +25,29 @@ describe('Read Only Portfolio', () => {
cy.mockGraphqlOps({operations: getOperations({readOnly: false})}); cy.mockGraphqlOps({operations: getOperations({readOnly: false})});
cy.visit('/portfolio'); cy.visit('/portfolio');
cy.getByDataCy('project-list').should('exist');
cy.getByDataCy('add-project-button').should('exist'); cy.getByDataCy('add-project-button').should('exist');
cy.getByDataCy('project-widget').should('have.length', 1); cy.getByDataCy('project').should('have.length', 1);
cy.getByDataCy('project-widget-actions').should('exist'); cy.getByDataCy('project-actions').should('exist');
}); });
it('Can not create and edit project when license invalid', () => { it('Can not create and edit project when license invalid', () => {
cy.mockGraphqlOps({operations: getOperations({readOnly: true})}); cy.mockGraphqlOps({operations: getOperations({readOnly: true})});
cy.visit('/portfolio'); cy.visit('/portfolio');
cy.getByDataCy('project-list').should('exist');
cy.getByDataCy('add-project-button').should('not.exist'); cy.getByDataCy('add-project-button').should('not.exist');
cy.getByDataCy('project-widget').should('have.length', 1); cy.getByDataCy('project').should('have.length', 1);
cy.getByDataCy('project-widget-actions').should('not.exist'); cy.getByDataCy('project-actions').should('not.exist');
}); });
it('Can not create and edit project when class inactive', () => { it('Can not create and edit project when class inactive', () => {
cy.mockGraphqlOps({operations: getOperations({readOnly: false, classReadOnly: true})}); cy.mockGraphqlOps({operations: getOperations({readOnly: false, classReadOnly: true})});
cy.visit('/portfolio'); cy.visit('/portfolio');
cy.getByDataCy('project-list').should('exist');
cy.getByDataCy('add-project-button').should('not.exist'); cy.getByDataCy('add-project-button').should('not.exist');
cy.getByDataCy('project-widget').should('have.length', 1); cy.getByDataCy('project').should('have.length', 1);
cy.getByDataCy('project-widget-actions').should('not.exist'); cy.getByDataCy('project-actions').should('not.exist');
}); });
}); });

View File

@ -9,14 +9,10 @@ const getOperations = ({readOnly = false, classReadOnly = false}) => ({
student: { student: {
id: btoa('PrivateUserNode:1'), id: btoa('PrivateUserNode:1'),
}, },
entriesCount: 3, entriesCount: 1,
entries: { entries: [
edges: [ {}
{ ]
node: {},
},
],
},
}, },
}, },
}); });

View File

@ -1,6 +1,5 @@
<template> <template>
<li <li
data-cy="project-list-item"
class="project"> class="project">
<router-link <router-link
:to="{name: 'project', params: {slug: project.slug}}" :to="{name: 'project', params: {slug: project.slug}}"

View File

@ -4,7 +4,9 @@
<div class="portfolio"> <div class="portfolio">
<h1 data-cy="page-title">Portfolio</h1> <h1 data-cy="page-title">Portfolio</h1>
<create-project-button class="portfolio__create-button" /> <create-project-button
class="portfolio__create-button"
v-if="!isReadOnly" />
<project-list <project-list
:projects="projects" /> :projects="projects" />
@ -18,13 +20,16 @@
<script> <script>
import ProjectWidget from '@/components/portfolio/ProjectWidget'; import ProjectWidget from '@/components/portfolio/ProjectWidget';
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
import PROJECTS_QUERY from '@/graphql/gql/queries/allProjects.gql'; import PROJECTS_QUERY from '@/graphql/gql/queries/allProjects.gql';
import PortfolioOnboarding from '@/components/portfolio/PortfolioOnboarding'; import PortfolioOnboarding from '@/components/portfolio/PortfolioOnboarding';
import CreateProjectButton from '@/components/portfolio/CreateProjectButton'; import CreateProjectButton from '@/components/portfolio/CreateProjectButton';
import ProjectList from '@/components/portfolio/ProjectList'; import ProjectList from '@/components/portfolio/ProjectList';
import me from '@/mixins/me';
export default { export default {
mixins: [me],
components: { components: {
ProjectList, ProjectList,
CreateProjectButton, CreateProjectButton,
@ -36,16 +41,12 @@
projects: { projects: {
query: PROJECTS_QUERY, query: PROJECTS_QUERY,
pollInterval: 5000, pollInterval: 5000,
},
me: {
query: ME_QUERY
} }
}, },
data() { data() {
return { return {
projects: [], projects: [],
me: {}
}; };
}, },

View File

@ -103,11 +103,6 @@
slug: this.slug slug: this.slug
}; };
}, },
update(data) {
const project = this.$getRidOfEdges(data).project || {};
this.$store.dispatch('setSpecialContainerClass', project.appearance);
return project;
},
pollInterval: 5000, pollInterval: 5000,
}, },
me: { me: {
@ -115,12 +110,6 @@
} }
}, },
created() {
},
beforeDestroy() {
this.$store.dispatch('setSpecialContainerClass', '');
},
}; };
</script> </script>

View File

@ -5,6 +5,13 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"lib": ["es2017", "dom"], "lib": ["es2017", "dom"],
"target": "ES5", "target": "ES5",
"module": "es2015",
"strict": true,
"moduleResolution": "node",
"baseUrl": "src",
"paths": {
"@/*": ["./*"]
},
"types": [ "types": [
"cypress" "cypress"
] ]