Commit 3b3340fc authored by Martin Wortschack's avatar Martin Wortschack Committed by Fatih Acet

Calculate percentageCompleted value

- Remove hard coded value from tour parts
- Update specs
- Update mock data
parent 23fb1a19
......@@ -48,9 +48,7 @@ export const percentageCompleted = state => {
return 0;
}
return tourData[tourKey][lastStepIndex]
? tourData[tourKey][lastStepIndex].percentageCompleted
: 0;
return Math.floor((100 * lastStepIndex) / tourData[tourKey].length);
};
export const actionPopover = (state, getters) =>
......
......@@ -34,7 +34,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 0,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/tree/master$`, ''),
......@@ -68,7 +67,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 8,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commits/master$`, ''),
......@@ -84,7 +82,6 @@ const GUIDED_GITLAB_TOUR = [
selector: '.js-onboarding-commit-item',
text: s__('UserOnboardingTour|Click to open the latest commit to see its details.'),
},
percentageCompleted: 16,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commit/[a-z0-9]+$`, ''),
......@@ -115,7 +112,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 24,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/-/branches$`, ''),
......@@ -149,7 +145,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 32,
},
{
forUrl: ({ projectFullPath }) =>
......@@ -175,7 +170,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 40,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/issues$`, ''),
......@@ -204,7 +198,6 @@ const GUIDED_GITLAB_TOUR = [
},
],
actionPopover: null,
percentageCompleted: 48,
},
{
forUrl: ({ projectFullPath }) =>
......@@ -226,7 +219,6 @@ const GUIDED_GITLAB_TOUR = [
selector: '.js-onboarding-issue-item',
text: s__('UserOnboardingTour|Open one of the issues by clicking on its title.'),
},
percentageCompleted: 56,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/issues/[0-9]+$`, ''),
......@@ -259,7 +251,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 64,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/merge_requests$`, ''),
......@@ -277,7 +268,6 @@ const GUIDED_GITLAB_TOUR = [
"UserOnboardingTour|Let's take a closer look at a merge request. Click on the title of one.",
),
},
percentageCompleted: 72,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/merge_requests/[0-9]+$`, ''),
......@@ -308,7 +298,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 80,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/pipelines$`, ''),
......@@ -342,7 +331,6 @@ const GUIDED_GITLAB_TOUR = [
false,
),
},
percentageCompleted: 88,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/pipelines/[0-9]+$`, ''),
......@@ -392,7 +380,6 @@ const GUIDED_GITLAB_TOUR = [
},
],
actionPopover: null,
percentageCompleted: 96,
},
];
......@@ -407,7 +394,6 @@ const CREATE_PROJECT_TOUR = [
),
placement: 'bottom',
},
percentageCompleted: 0,
},
{
forUrl: () => new RegExp(`/projects/new\\?*.*$`, ''),
......@@ -428,7 +414,6 @@ const CREATE_PROJECT_TOUR = [
},
],
actionPopover: null,
percentageCompleted: 33,
},
{
forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}$`, ''),
......@@ -458,7 +443,6 @@ const CREATE_PROJECT_TOUR = [
},
],
actionPopover: null,
percentageCompleted: 66,
},
];
......@@ -479,7 +463,6 @@ const INVITE_COLLEAGUES_TOUR = [
false,
),
},
percentageCompleted: 0,
},
{
forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}/edit$`, ''),
......@@ -495,7 +478,6 @@ const INVITE_COLLEAGUES_TOUR = [
false,
),
},
percentageCompleted: 33,
},
{
forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}/-/project_members$`, ''),
......@@ -522,7 +504,6 @@ const INVITE_COLLEAGUES_TOUR = [
},
],
actionPopover: null,
percentageCompleted: 66,
},
];
......
......@@ -17,7 +17,6 @@ export const mockTourData = {
text: 'foo',
placement: 'top',
},
percentageCompleted: 10,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/foo/bar$`, ''),
......@@ -31,7 +30,6 @@ export const mockTourData = {
selector: '',
text: 'bar',
},
percentageCompleted: 20,
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/xyz`, ''),
......@@ -41,7 +39,6 @@ export const mockTourData = {
text: 'foo',
placement: 'top',
},
percentageCompleted: 30,
},
],
};
......
......@@ -163,7 +163,7 @@ describe('User onboarding store getters', () => {
it('returns the percentage completed for the current step', () => {
localState.lastStepIndex = 1;
expect(getters.percentageCompleted(localState)).toBe(20);
expect(getters.percentageCompleted(localState)).toBe(33);
});
it('returns the 0 if there is no step index', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment