tests: add all timing edge cases #158

Merged
cirex-web merged 7 commits from tests/all-timing-edge-cases into main 2024-09-22 23:26:34 +00:00
cirex-web commented 2024-09-09 22:26:23 +00:00 (Migrated from github.com)

Description

Adds everything mentioned in https://github.com/ScottyLabs/dining-api/wiki/Timing-Cases.
This does not pass with the code as-is, but should probably be merged before the refactor PR
image

I mocked out the Axios GET endpoint and replaced it with partly dynamically generated HTML files meant to simulate the real dining pages. A lot of this has been abstracted away (see mockAxios.ts and mockTimings.ts) with the goal of cleaner tests like the following:

  test("overlapping/self-containing times", async () => {
    setUpTimingTest({
      [Mon]: "8:00 AM - 4:00 PM, 2:00 PM - 9:00 PM",
      [Tue]: "2:00 PM - 9:00 PM, 8:00 AM - 4:00 PM",
      [Wed]: "8:00 AM - 9:00 PM, 2:00 PM - 4:00 PM",
      [Thur]: "2:00 PM - 4:00 PM, 8:00 AM - 9:00 PM",
      [Fri]: "7:00 AM - 4:00 PM, 6:00 AM - 2:00 PM, 7:00 PM - 12:00 AM",
    });
    await queryParserAndAssertTimingsCorrect([
      [Mon, 8, 0, Mon, 21, 0],
      [Tue, 8, 0, Tue, 21, 0],
      [Wed, 8, 0, Wed, 21, 0],
      [Thur, 8, 0, Thur, 21, 0],
      [Fri, 6, 0, Fri, 16, 0],
      [Fri, 19, 0, Fri, 23, 59],
    ]);
  });

With these added tests, we can be more confident that future code changes won't break existing parsing functionality.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Test A
  • Test B

Test Configuration:

  • Node.js version:
  • Python version:
  • Desktop/Mobile:
  • OS:
  • Browser:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
# Description Adds everything mentioned in https://github.com/ScottyLabs/dining-api/wiki/Timing-Cases. This does not pass with the code as-is, but should probably be merged before the refactor PR <img width="468" alt="image" src="https://github.com/user-attachments/assets/77e80f21-7d5a-48f0-ac80-8ca00709646f"> I mocked out the Axios GET endpoint and replaced it with partly dynamically generated HTML files meant to simulate the real dining pages. A lot of this has been abstracted away (see `mockAxios.ts` and `mockTimings.ts`) with the goal of cleaner tests like the following: ```ts test("overlapping/self-containing times", async () => { setUpTimingTest({ [Mon]: "8:00 AM - 4:00 PM, 2:00 PM - 9:00 PM", [Tue]: "2:00 PM - 9:00 PM, 8:00 AM - 4:00 PM", [Wed]: "8:00 AM - 9:00 PM, 2:00 PM - 4:00 PM", [Thur]: "2:00 PM - 4:00 PM, 8:00 AM - 9:00 PM", [Fri]: "7:00 AM - 4:00 PM, 6:00 AM - 2:00 PM, 7:00 PM - 12:00 AM", }); await queryParserAndAssertTimingsCorrect([ [Mon, 8, 0, Mon, 21, 0], [Tue, 8, 0, Tue, 21, 0], [Wed, 8, 0, Wed, 21, 0], [Thur, 8, 0, Thur, 21, 0], [Fri, 6, 0, Fri, 16, 0], [Fri, 19, 0, Fri, 23, 59], ]); }); ``` With these added tests, we can be more confident that future code changes won't break existing parsing functionality. <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ## Type of change <!-- Please delete options that are not relevant. --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update # How Has This Been Tested? <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> - [ ] Test A - [ ] Test B **Test Configuration**: <!-- Please remove sections that are not relevant. --> - Node.js version: - Python version: - Desktop/Mobile: - OS: - Browser: # Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes
vercel[bot] commented 2024-09-09 22:26:27 +00:00 (Migrated from github.com)

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dining-api Ready (Inspect) Visit Preview 💬 Add feedback Sep 22, 2024 11:26pm
[vc]: #QAl9QAgaDZah2Yfv2LijuzM0rV65g6K8WUU+iQs8l5w=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJkaW5pbmctYXBpIiwicm9vdERpcmVjdG9yeSI6bnVsbCwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL3Njb3R0eWxhYnMvZGluaW5nLWFwaS83aXVmTkxyQzVBbmVmWkZ3SERtSGNKOEtFR1llIiwicHJldmlld1VybCI6ImRpbmluZy1hcGktZ2l0LWZvcmstY2lyZXgtd2ViLXRlc3RzLWFsbC10aW1pbi03YTIyYzUtc2NvdHR5bGFicy52ZXJjZWwuYXBwIiwibmV4dENvbW1pdFN0YXR1cyI6IkRFUExPWUVEIiwibGl2ZUZlZWRiYWNrIjp7InJlc29sdmVkIjowLCJ1bnJlc29sdmVkIjowLCJ0b3RhbCI6MCwibGluayI6ImRpbmluZy1hcGktZ2l0LWZvcmstY2lyZXgtd2ViLXRlc3RzLWFsbC10aW1pbi03YTIyYzUtc2NvdHR5bGFicy52ZXJjZWwuYXBwIn19XX0= **The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more) | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **dining-api** | ✅ Ready ([Inspect](https://vercel.com/scottylabs/dining-api/7iufNLrC5AnefZFwHDmHcJ8KEGYe)) | [Visit Preview](https://vercel.live/open-feedback/dining-api-git-fork-cirex-web-tests-all-timin-7a22c5-scottylabs.vercel.app?via=pr-comment-visit-preview-link&passThrough=1) | 💬 [**Add feedback**](https://vercel.live/open-feedback/dining-api-git-fork-cirex-web-tests-all-timin-7a22c5-scottylabs.vercel.app?via=pr-comment-feedback-link) | Sep 22, 2024 11:26pm |
cirex-web commented 2024-09-10 02:46:59 +00:00 (Migrated from github.com)

the test code is a bit unreadable at the moment... I'll fix it soon
Fixed

~the test code is a bit unreadable at the moment... I'll fix it soon~ Fixed
GhostOf0days (Migrated from github.com) approved these changes 2024-09-22 23:21:15 +00:00
GhostOf0days (Migrated from github.com) left a comment

I see no issues. Thanks for your PR.

I see no issues. Thanks for your PR.
Sign in to join this conversation.
No description provided.