Fix race condition
This commit is contained in:
parent
b43b70a40b
commit
8c70b051ff
|
|
@ -7,17 +7,25 @@ describe('Onboarding', () => {
|
||||||
cy.setup();
|
cy.setup();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows the onboarding steps and finishes them', () => {
|
it.only('shows the onboarding steps and finishes them', () => {
|
||||||
|
let onboardingVisited = false;
|
||||||
cy.mockGraphqlOps({
|
cy.mockGraphqlOps({
|
||||||
operations: {
|
operations: {
|
||||||
MeQuery: {
|
MeQuery: () => ({
|
||||||
me: {
|
me: {
|
||||||
...me.me,
|
onboardingVisited,
|
||||||
onboardingVisited: false
|
},
|
||||||
}
|
}),
|
||||||
|
UpdateOnboardingProgress: () => {
|
||||||
|
onboardingVisited = true;
|
||||||
|
return {
|
||||||
|
updateOnboardingProgress: {
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
...mockUpdateOnboardingProgress()
|
NewsTeasers: {}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
|
|
@ -30,18 +38,23 @@ describe('Onboarding', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows the onboarding steps and skips them', () => {
|
it('shows the onboarding steps and skips them', () => {
|
||||||
cy.fakeLogin('hansli', 'test');
|
let onboardingVisited = false;
|
||||||
|
|
||||||
cy.mockGraphqlOps({
|
cy.mockGraphqlOps({
|
||||||
operations: {
|
operations: {
|
||||||
MeQuery: {
|
MeQuery: {
|
||||||
me: {
|
me: {
|
||||||
...me.me,
|
onboardingVisited,
|
||||||
onboardingVisited: false
|
},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
...mockUpdateOnboardingProgress()
|
UpdateOnboardingProgress: () => {
|
||||||
}
|
onboardingVisited = true;
|
||||||
|
return {
|
||||||
|
updateOnboardingProgress: {
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
|
|
@ -51,13 +64,12 @@ describe('Onboarding', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not show the onboarding', () => {
|
it('does not show the onboarding', () => {
|
||||||
cy.fakeLogin('hansli', 'test');
|
|
||||||
|
|
||||||
cy.mockGraphqlOps({
|
cy.mockGraphqlOps({
|
||||||
operations: {
|
operations: {
|
||||||
MeQuery: me,
|
MeQuery: {
|
||||||
...mockUpdateOnboardingProgress()
|
me: {}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
},
|
},
|
||||||
illustration() {
|
illustration() {
|
||||||
return this.$route.meta.illustration;
|
return this.$route.meta.illustration;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -35,11 +35,11 @@
|
||||||
const next = this.$route.meta.next;
|
const next = this.$route.meta.next;
|
||||||
if (next === 'home') {
|
if (next === 'home') {
|
||||||
this.completeOnboarding();
|
this.completeOnboarding();
|
||||||
|
} else {
|
||||||
|
this.$router.push({name: next});
|
||||||
}
|
}
|
||||||
this.$router.push({name: next});
|
|
||||||
},
|
},
|
||||||
completeOnboarding() {
|
completeOnboarding() {
|
||||||
const router = this.$router;
|
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: UPDATE_ONBOARDING_PROGRESS,
|
mutation: UPDATE_ONBOARDING_PROGRESS,
|
||||||
update(store, {data: {updateOnboardingProgress: {success}}}) {
|
update(store, {data: {updateOnboardingProgress: {success}}}) {
|
||||||
|
|
@ -49,11 +49,12 @@
|
||||||
data.me.onboardingVisited = success;
|
data.me.onboardingVisited = success;
|
||||||
store.writeQuery({query, data});
|
store.writeQuery({query, data});
|
||||||
}
|
}
|
||||||
router.push({name: 'home'});
|
},
|
||||||
}
|
}).then(() => {
|
||||||
|
this.$router.push({name: 'home'});
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue