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

[Beta] Applied Accessibility - Tests fails to check for the closing </time> tag #16423

Closed
Asjas opened this issue Jan 6, 2018 · 7 comments
Closed
Labels
help wanted Open for all. You do not need permission to work on these.

Comments

@Asjas
Copy link
Contributor

Asjas commented Jan 6, 2018

Challenge Name

https://beta.freecodecamp.org/en/challenges/applied-accessibility/standardize-times-with-the-html5-datetime-attribute

Issue Description

The test is failing to check for the closing </time> tag. You can reproduce this issue by using the opening <time> tag and leaving out the closing tag.

Browser Information

  • Browser Name, Version: Chrome, Version 63.0.3239.108 (Official Build) (64-bit)
  • Operating System: Windows 10 Pro
  • Mobile, Desktop, or Tablet: Desktop

Your Code

<body>
  <header>
    <h1>Tournaments</h1>
  </header>
  <article>
    <h2>Mortal Combat Tournament Survey Results</h2>
    
    <!-- Add your code below this line -->
    
    <p>Thank you to everyone for responding to Master Camper Cat's survey. The best day to host the 
vaunted Mortal Combat tournament is <time datetime="2016-09-15">Thursday, September
 15<sup>th</sup>. May the best ninja win!</p>
    
    <!-- Add your code above this line -->
    
    <section>
      <h3>Comments:</h3>
      <article>
        <p>Posted by: Sub-Zero on <time datetime="2016-08-13T20:01Z">August 13<sup>th</sup></time></p>
        <p>Johnny Cage better be there, I'll finish him!</p>
      </article>
      <article>
        <p>Posted by: Doge on <time datetime="2016-08-15T08:12Z">August 15<sup>th</sup></time></p>
        <p>Wow, much combat, so mortal.</p>
      </article>
      <article>
        <p>Posted by: The Grim Reaper on <time datetime="2016-08-16T00:00Z">August 16<sup>th</sup></time></p>
        <p>Looks like I'll be busy that day.</p>
      </article>
    </section>
  </article>
  <footer>&copy; 2016 Camper Cat</footer>
</body>

Screenshot

time

@ooade
Copy link

ooade commented Jan 8, 2018

Possible fix for this too on this line

$('time').first().text() == "Thursday, September 15th"

@raisedadead raisedadead added help wanted Open for all. You do not need permission to work on these. type: tests labels Jan 11, 2018
@PolarisTLX
Copy link
Contributor

Hi there, this seems simple enough for me to fix.

I presume we simply need to modify the first test condition.
The description of the first condition should change from:
"Your time tags should wrap around the text "Thursday, September 15th"."
to:
"Your time tags should wrap around the text "Thursday, September 15th", with an opening AND closing tag."

And the code in the background should verify for both the opening and closing before it changes the icon next to the test condition from the "refresh-icon::before" to the "success-icon::before".

I've tried downloading the website to look into the JavaScript files, naturally there is quite a bit of code in there. Am I on the right path to finding that particular line of code to adjust?

@Asjas
Copy link
Contributor Author

Asjas commented Jan 19, 2018

Hi @PolarisTLX

Yes you are on the correct path. Basically you need to setup a local dev environment using the Contributing Guide as a reference. Once you have a local dev environment you can then start changing code and testing if it works locally.

The code you will probably look for is in the challenge seed directory. Each individual section in the map is split into folders. You will be looking for the Applied Accessibility json file. Once you have made changes to the file and saved it you will need to run node seed to update mongod. AFAIK you will also need to restart nodemon by typing rs to restart it before you run your test.

Coming to the testing of both opening and closing brackets. I myself have been trying to test for both opening and closing footer elements on issue #16416 and I haven't found a way. I've tried Regex but I'm not really the best at it. I've also tried playing with how Chai counts or selects elements but that hasn't worked for testing the closing element. I would love to see your solution and to test it on my issue to see if it also fixes it.

@Asjas
Copy link
Contributor Author

Asjas commented Jan 19, 2018

The only solution I've found was to write a really really long Regexp. But I'm not sure if it's really a good enough solution to PR.

@PolarisTLX
Copy link
Contributor

PolarisTLX commented Jan 19, 2018

Alright I have the local dev environment up and running, and I have found the test in question in the applied-accessibility.json file. And I think I have code required, however, I am not sure where to place this code.

I also think a RegExp is the quickest solution, and here is mine:

/(\<time).*\>Thursday, September 15\<sup\>th\<\/sup\>\<\/time\>\./;

When testing it in a console, I verified it worked on what the users solution should look like:
The test in the console:

var string = '<time datetime="2016-09-15">Thursday, September 15<sup>th</sup></time>.' 
var time = /(\<time).*\>Thursday, September 15\<sup\>th\<\/sup\>\<\/time\>\./;

console.log(time.test(string));
// true   (thus it should work)

It appears that it would also work if it was shortened to just:

/(\<time).*\>.*\<\/time\>/;

But that might be less accurate.

@Asjas
Copy link
Contributor Author

Asjas commented Jan 20, 2018

Okay so looking at the test for the time challenge you'll have to replace the current assert($('time').text().match(/Thursday, September 15th/g) with assert(code.match(regexp)). Then replace the word regexp with your RegExp. That should then work.

For reference on how the test should look you can also look at the Jump Straight to the Content Using the main Element challenge in the applied-accessibility.json file. The second test for it has a RegExp you can reference.

@PolarisTLX
Copy link
Contributor

Alright I've successfully been running and modifying the local dev environment.

Then I modified the code on line 706 of file "applied-accessibility.json"
From:
"assert($('time').text().match(/Thursday, September 15th/g), 'message: Yo..."
To:
"assert(code.match(/<time.*>Thursday, September 15th</sup></time>/g), 'message: Yo..."

I can tell that it is being tested as I can modify the "message" part. But the test is not working.
I suspect there is something with "assert(code.match(..." that isn't right. What is the variable "code" here?

anhtran1906 added a commit to fccSeniorSeminar/freeCodeCamp that referenced this issue Jan 26, 2018
Added test cases with assert statements

BREAKING CHANGE: no

Closes freeCodeCamp#16415
Closes freeCodeCamp#16424
Closes freeCodeCamp#16423
Closes freeCodeCamp#16422
Closes freeCodeCamp#16420
Closes freeCodeCamp#16419
Closes freeCodeCamp#16417
Closes freeCodeCamp#16414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Open for all. You do not need permission to work on these.
Projects
None yet
Development

No branches or pull requests

4 participants