Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write e2e tests for onboarding - Closes #589 #629

Merged
merged 1 commit into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/onboarding/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class Onboarding extends React.Component {
reset() {
this.isAlreadyOnboarded = true;
this.onboardingStarted = false;
this.onboardingFinished = false;
this.joyride.reset(true);
this.setState({ start: false, intro: true, skip: false });
}

Expand All @@ -68,6 +70,7 @@ class Onboarding extends React.Component {
const onboardingStarted = data.index === 1;
const onboardingStep = data.index > 1;
const skipOnboarding = data.action === 'skip';
const lastStepReached = data.index === this.state.steps.length - 1;
const onboardingFinished = data.type === 'finished';

if (onboardingNotStarted) {
Expand All @@ -84,6 +87,9 @@ class Onboarding extends React.Component {
this.setState({ skip: true });
this.joyride.reset(true); // go to step 0 to show the skip step
}
if (lastStepReached) {
this.onboardingFinished = true;
}
if (onboardingFinished) {
if (this.onboardingFinished) this.reset();
this.onboardingFinished = true;
Expand Down
2 changes: 1 addition & 1 deletion src/components/setting/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Setting extends React.Component {
</div>
{this.showOnboardingSetting()
? <div>
<button className={styles.settingsButton} onClick={() => {
<button className={`${styles.settingsButton} onboarding-setting`} onClick={() => {
toggleMenu();
startOnboarding();
}
Expand Down
111 changes: 111 additions & 0 deletions test/e2e/onboarding.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Feature: Onboarding
Scenario: should not start onboarding when not logged in
Given I go to "/"
And I wait 1 seconds
Then I should see no "joyride-tooltip__header"

Scenario: should start onboarding automatically
Given I'm logged in as "genesis"
And I wait 0.4 seconds
Then I should see text "Welcome to Lisk Hub" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Lisk ID" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Keep the overview" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Send LSK" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Explore the network" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Manage your application" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Access extra features" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "You’ve completed the tour!" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
Then I should see no "joyride-tooltip__header"

When I click "more menu"
And I click 1 item in setting carousel
And I wait 0.4 seconds
And I click "advancedMode"
And I click 3 item in setting carousel
And I wait 0.4 seconds
And I click "onboarding-setting"
Then I should see text "Welcome to Lisk Hub" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Lisk ID" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Keep the overview" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Send LSK" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Explore the network" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Delegate voting" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Manage your application" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Access extra features" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "You’ve completed the tour!" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
Then I should see no "joyride-tooltip__header"

When I refresh the page
And I wait 1 seconds
Then I should see no "joyride-tooltip__header"

When I click "more menu"
And I click 3 item in setting carousel
And I wait 0.4 seconds
And I click "onboarding-setting"
And I wait 0.4 seconds
Then I should see text "Welcome to Lisk Hub" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--primary"
And I wait 0.4 seconds
Then I should see text "Lisk ID" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--skip"
And I wait 0.4 seconds
Then I should see text "Onboarding whenever you need" in "joyride-tooltip__header" element

And I click "joyride-tooltip__button--skip"
Then I should see no "joyride-tooltip__header"




4 changes: 3 additions & 1 deletion test/e2e/step_definitions/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ defineSupportCode(({ Before, After, registerListener }) => {
browser.get(browser.params.baseURL);
localStorage.clear();
localStorage.setItem('showNetwork', 'true');
localStorage.setItem('onboarding', 'false');
if (scenario.scenario.feature.name !== 'Onboarding') {
localStorage.setItem('onboarding', 'false');
}
browser.get(browser.params.baseURL).then(callback);
});

Expand Down