Giter VIP home page Giter VIP logo

Comments (7)

sidkshatriya avatar sidkshatriya commented on August 23, 2024

I agree. We should definitely have tests. Thanks for creating the ticket I was planning to create :-)

cc: @sirkitree

from amp-library.

sidkshatriya avatar sidkshatriya commented on August 23, 2024

(BTW we probably won't have CI for now though)

from amp-library.

sidkshatriya avatar sidkshatriya commented on August 23, 2024

Need to have a discussion with @sirkitree if we need to do this in Phase 1 or we can park this for a Phase 2.

from amp-library.

sirkitree avatar sirkitree commented on August 23, 2024

This does not need to be done for phase 1, but would be a good candidate for phase 2 of the project.

from amp-library.

sidkshatriya avatar sidkshatriya commented on August 23, 2024

Parking this ticket for now. No work will be done on this for Phase 1.

from amp-library.

sidkshatriya avatar sidkshatriya commented on August 23, 2024

General Plan

The scope of this ticket would be to setup a few basic tests and generally get this working. We'll need to keep adding tests as we go along.

from amp-library.

sidkshatriya avatar sidkshatriya commented on August 23, 2024

Basic testing structure is in place with 2 tests. This was probably the most important part. Now all we need to do is keep adding more tests along with expected output.

  • The testing code automatically picks up html fragments and whole documents for testing placed in tests/test-data/full-htmland tests/test-data/fragment-html folders
  • Currently there is one full html document test and one fragment test. The expected output is stored with a suffix of .out e.g. several_errors.html.out

Here is an example of what happens when a test fails
(Note: None are failing currently. This is an artificial example -- a test has been made to fail by changing the input html slightly)

$ vendor/bin/phpunit tests
PHPUnit 5.3.2 by Sebastian Bergmann and contributors.

F.                                                                  2 / 2 (100%)

Time: 1.16 seconds, Memory: 14.00Mb

There was 1 failure:

1) AmpTest::testFiles with data set "tests/test-data/fragment-html/sample-html-fragment.html" ('tests/test-data/fragment-html...t.html', false)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 ---------------
-Line  1: <p><a style="color: red;" href="javascript:run();">Run</a></p>
+Line  1: <p><a great-style="color: red;" href="javascript:run();">Run</a></p>

@@ @@

-<a style="color: red;" href="javascript:run();"> on line 1
-- The attribute 'style' may not appear in tag 'a'.
+<a great-style="color: red;" href="javascript:run();"> on line 1
+- The attribute 'great-style' may not appear in tag 'a'.
    [code: DISALLOWED_ATTR  category: DISALLOWED_HTML]
-   ACTION TAKEN: a.style attribute was removed due to validation issues.
+   ACTION TAKEN: a.great-style attribute was removed due to validation issues.
 - Invalid URL protocol 'javascript:' for attribute 'href' in tag 'a'.
    [code: INVALID_URL_PROTOCOL  category: DISALLOWED_HTML]
    ACTION TAKEN: a.href attribute was removed due to validation issues.

 <a style="margin: 2px;" href="http://www.cnn.com" target="_parent"> on line 2
 - The attribute 'style' may not appear in tag 'a'.
    [code: DISALLOWED_ATTR  category: DISALLOWED_HTML]
    ACTION TAKEN: a.style attribute was removed due to validation issues.
 - The attribute 'target' in tag 'a' is set to the invalid value '_parent'.
    [code: INVALID_ATTR_VALUE  category: DISALLOWED_HTML]
    ACTION TAKEN: a.target attribute was removed due to validation issues.

 <input type="submit" value="submit"> on line 5
 - The tag 'input' is disallowed.
    [code: DISALLOWED_TAG  category: DISALLOWED_HTML]
    ACTION TAKEN: input tag was removed due to validation issues.

 <div onmouseover="hello();"> on line 6
 - The attribute 'onmouseover' may not appear in tag 'div'.
    [code: DISALLOWED_ATTR  category: DISALLOWED_HTML]
    ACTION TAKEN: div.onmouseover attribute was removed due to validation issues.

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"> on line 8
 - The tag 'script' is disallowed except in specific forms.
    [code: GENERAL_DISALLOWED_TAG  category: GENERIC]
    ACTION TAKEN: script tag was removed due to validation issues.

 <style> on line 9
 - The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'.
    [code: MANDATORY_ATTR_MISSING  category: DISALLOWED_HTML see: https://www.ampproject.org/docs/reference/spec.html#stylesheets]
 - The parent tag of tag 'style' is 'body', but it can only be 'head'.
    [code: WRONG_PARENT_TAG  category: DISALLOWED_HTML see: https://www.ampproject.org/docs/reference/spec.html#stylesheets]
    ACTION TAKEN: style tag was removed due to validation issues.


 COMPONENT NAMES WITH JS PATH
 ------------------------------
 'amp-iframe', include path 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js'

 '

tests/AmpTest.php:45

FAILURES!
Tests: 2, Assertions: 2, Failures: 1.

from amp-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.