-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Feature Request: No way to check AMP Validation State using Vanilla HTML+JS #9371
Comments
Why aren't you just using the validator? |
@jridgewell not possible from something like Ghost Inspector, or Ruby/Selinum based feature testing. I have an already-renderd AMP page that I've asserted has correct content and want to lastly check that it is amp-valid. We're not testing against pre-rendered fixtures, we're using this for production smoke testing real articles in using Selenium to keep tabs on our CI. Use case: Every hour Ghost Inspector hits production AMP article and appends |
Can you use Cloudflare's validation API? |
@jridgewell Yes, I could write a separate test suite that solely hits Cloudflare's validation API endpoint and then parses the JSON to check for validity (although not in Ghost Inspector, it'd have to be done using a different tool). This seems like a redundant/unnecessary step to me though, since I'm already running E2E feature tests against fully-rendered AMP pages in Selenium/Capybara (or alternatively Ghost Inspector). Wouldn't it be more efficient to take my same E2E tests with fully rendered AMP pages but run them against pages in That way I get clean E2E feature tests which test for correct content and amp-validity without having to do any asynchronous API calls to 3rd party services. Here's the Capybara method I'm hoping to leverage in this scenario and here's a similar Ghost Inspector feature that would also do the job. Definitely open to discussion though! Let me know of your concerns etc, I'm all ears. |
Another reason why using Cloudflare isn't a perfect solution: We host our CI/pre-prod builds on a private server requiring username+password credentials. We'd have to expose our credentials into the URL using |
/to @powdercloud. Ideally, the validator included with |
I looked into it for a bit. The status quo is that when #development=1 is appended, this code runs: If amp.validator.validateUrlAndLog were to also store a result object, would this be sufficient? The way to graft this together is for amp.validator.validateUrlAndLog to return this object, and for the runtime to store it in this variable. It's a slight bit hacky but makes it so we don't have to add this global variable to engine.js. Opinions on this most welcome. I'm not familiar with Ghost Inspector etc., so it's hard for me to say whether this is the simplest possible solution - but maybe better than annotating the DOM. Note that with the solution outlined here you'd still end up with an extra HTTP fetch per document you're checking - that's just how #development=1 works. |
@powdercloud I noticed the same method and found the same confusion, why is there no function to revalidate the current page and return the state synchronously?
Storing the return value in a global variable would be better than the current implementation because our front end tests can always sleep and then check that variable. I definitely like the simplicity of that idea, and it's just as easy as my original idea of What would be most ideal is |
This might be a way.
Also:
|
@powdercloud that works great with one minor addition.
You are right that it is inefficient but this gets the job done for now! Assuming the underlying implementation of the validator doesn't change suddenly we'll be a-ok. If it does, which it could since this is undocumented/unsupported functionality, my tests will start failing and I'll have to refactor or remove the step. It's unfortunate that I have to re-request the page I'm already on but at the same time, you are right this is indeed a testing environment where making one extra request isn't game-breaking. |
amp.validator.validateString(inputText) isn't going to change, and neither is the status field of the return value; if we make changes they'll be backwards compatible by necessity because the runtime, the npm library, the chrome extension, etc. depends on this. I also don't see why the behavior of loading this for #development=1 would change. |
As of October 13, 2018, AMP validation can be checked using - |
Not true, just checked a page with errors and |
I think you will get some solution to using this website AMP Validator. By using this website you can test multiple numbers of URLs in a short time. And this site is secure, accurate, fast and easy to use. The most interesting thing is you will get the proper beautified email report. |
What's the issue?
Feature request:
Gherkin:
As a developer writing end to end tests
When I go to an AMP page with
#development=1
appended to the URLI expect that I can check the validation state of the current page using a single line of synchronous JS in the console
More info
I think it makes the most sense for there to be a data attribute appended to the
<html amp>
element in this fashion<html amp amp-valid>
and for failure<html amp amp-invalid>
, but only when in development mode.That way the developer can reliably check that attribute in order to assert the validation state of the AMP page without any GET requests to third parties, XHR, or Node.
I envision using something like
return document.documentElement.hasAttribute('amp-valid')
in my Ghost Inspector tests or in my Selenium/Capybara feature tests. I'd just have to account for the 1-2 seconds it takes for the validator to run before asserting.How do we reproduce the issue?
N/A
What browsers are affected?
N/A
Which AMP version is affected?
Latest 1494446565961
The text was updated successfully, but these errors were encountered: