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

Web Lab: Correct share links in different environments #19625

Merged

Conversation

islemaster
Copy link
Contributor

@islemaster islemaster commented Dec 13, 2017

Reverts #19623, restoring #19535 with fixes for sharing from CSD/CSP script project levels.

I added tests that catch the bad case, fixed the bad case, then totally reorganized the tests to reduce duplication, make the test names useful for spot-checking behavior, and easier to extend in the future. I've also added a UI test covering the regression, since in general unit test coverage over project stuff is not great and I still might have missed something.

Here's the new set of tests for getShareUrl():

    project.js
      project.getShareUrl
        on https://studio.code.org
          artist projects share to https://studio.code.org/projects/artist/<project-id>
            ✔ from project edit page
            ✔ from a script level
          playlab projects share to https://studio.code.org/projects/playlab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          applab projects share to https://studio.code.org/projects/applab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          gamelab projects share to https://studio.code.org/projects/gamelab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          weblab projects share to https://codeprojects.org/<project-id>
            ✔ from project edit page
            ✔ from project view page
            ✔ from a script level
        on https://test-studio.code.org
          artist projects share to https://test-studio.code.org/projects/artist/<project-id>
            ✔ from project edit page
            ✔ from a script level
          playlab projects share to https://test-studio.code.org/projects/playlab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          applab projects share to https://test-studio.code.org/projects/applab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          gamelab projects share to https://test-studio.code.org/projects/gamelab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          weblab projects share to https://test.codeprojects.org/<project-id>
            ✔ from project edit page
            ✔ from project view page
            ✔ from a script level
        on https://staging-studio.code.org
          artist projects share to https://staging-studio.code.org/projects/artist/<project-id>
            ✔ from project edit page
            ✔ from a script level
          playlab projects share to https://staging-studio.code.org/projects/playlab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          applab projects share to https://staging-studio.code.org/projects/applab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          gamelab projects share to https://staging-studio.code.org/projects/gamelab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          weblab projects share to https://staging.codeprojects.org/<project-id>
            ✔ from project edit page
            ✔ from project view page
            ✔ from a script level
        on http://localhost-studio.code.org:3000
          artist projects share to http://localhost-studio.code.org:3000/projects/artist/<project-id>
            ✔ from project edit page
            ✔ from a script level
          playlab projects share to http://localhost-studio.code.org:3000/projects/playlab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          applab projects share to http://localhost-studio.code.org:3000/projects/applab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          gamelab projects share to http://localhost-studio.code.org:3000/projects/gamelab/<project-id>
            ✔ from project edit page
            ✔ from a script level
          weblab projects share to http://localhost.codeprojects.org:3000/<project-id>
            ✔ from project edit page
            ✔ from project view page
            ✔ from a script level

wait_short_until do
share_link_input = @browser.find_element(:css, '#sharing-input')
end
expect(share_link_input.attribute('value')).to include(expected_text)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested that this step fails as expected when the given text is not found:

image

},

/**
* This method exists to be mocked for unit tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This made me sad :)

@islemaster islemaster force-pushed the revert-19623-revert-19535-weblab-correct-share-links branch from db585f0 to 93e4775 Compare December 14, 2017 17:10
@islemaster
Copy link
Contributor Author

This is passing tests now that the Chrome 63 failures are worked out. Can I get a review?

const re = /([-.]?studio)?\.?code.org/i;
const environmentKey = location.hostname.replace(re, '');
const subdomain = environmentKey.length > 0 ? `${environmentKey}.` : '';
const port = 'localhost' === environmentKey ? `:${location.port}` : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gut says this kind of parsing could be more generically useful across our code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should be extracted or reused somewhere right away?

Copy link
Member

@breville breville Dec 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think okay for now; but it would be good to keep an eye out for chances to use shared code going forward. The Ruby side of the system has been somewhat good at using common code to deal with our various environments.

codeProjects: 'https://test.codeprojects.org',
},
{
studio:'https://test.studio.code.org',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a domain we offer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh - I know there was a time in the past where we didn't care whether you wrote test-studio or test.studio, but maybe that's not true anymore? This is easy enough to tear out, I just wanted to make sure this utility handled that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem to work for me, and I have a feeling some of our infrastructure changes stopped them from working a while ago. Same comment for the staging link in this file too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't get confirmation yet, agreed, it looks like we don't support these anymore. I've removed the tests.

@@ -1,3 +1,7 @@
# Which stage of allthethings.script contains the App Lab levels; this way we
# only have to update in one place if this changes.
APPLAB_ALLTHETHINGS_STAGE = 18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Can imagine a lot of UI tests benefitting from something like this.

@@ -36,6 +40,14 @@ def add_code_to_editor(code)
STEPS
end

Given /^I am on the (\d+)(?:st|nd|rd|th)? App ?Lab test level$/ do |level_index|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I look forward to testing the 3th level :)

Copy link
Member

@breville breville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not particularly familiar part of the code base, but looks good to me!

@islemaster islemaster changed the title Unrevert Web Lab correct share links Web Lab: Correct share links in different environments Dec 14, 2017
@islemaster islemaster merged commit f84d7ee into staging Dec 14, 2017
@islemaster islemaster deleted the revert-19623-revert-19535-weblab-correct-share-links branch December 14, 2017 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants