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

Bug/issue 271 determinism #292

Merged
merged 12 commits into from
Mar 2, 2020
Merged

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Feb 25, 2020

Related Issue

resolves #271

Summary of Changes

  1. Pages are tracked as read from the filesystem, and inserted into pages Array to that index, instead of asynchronously being pushed . Was trying to do something fancy like this but couldn't get it to work.
  2. Documented graph return order
  3. Added unit testing for data/graph.js and updated test cases to expect a specific order each time

Notes

  1. had to extend Mocha glob configuration, which is making the test and test:tdd tasks a little cumbersome to maintain now. Will create a new issue for refactoring this configuration to use a mocharc.js file - see Technical/issue 293 mocha refactor #294
  2. Could probably use some additional unit testing around other data files. Should probably make a new issue for that. Could also some up with a better way to capture MOCK_GRAPH

@thescientist13 thescientist13 added bug Something isn't working P0 Critical issue that should get addressed ASAP Content as Data labels Feb 25, 2020
@thescientist13
Copy link
Member Author

thescientist13 commented Feb 25, 2020

Hmm.. test is failing on CI because second-post.md is still returned before first-post.md 😞 😠

       {
      -  "Page:6d2fe63686567be": {
      +  "Page:9a4ce9aeeb41a94": {
           "__typename": "Page"
           "fileName": "second-post"
           "filePath": "./blog/second-post.md"
      -    "id": "6d2fe63686567be"
      +    "id": "9a4ce9aeeb41a94"
           "link": "/blog/second-post"
           "template": "blog"
           "title": "Blog"
         }
      -  "Page:cc38e1248273d99": {
      +  "Page:f3f1bb94286324a": {
           "__typename": "Page"
           "fileName": "first-post"
           "filePath": "./blog/first-post.md"
      -    "id": "cc38e1248273d99"
      +    "id": "f3f1bb94286324a"
           "link": "/blog/first-post"
           "template": "blog"
           "title": "Blog"
         }

@thescientist13 thescientist13 self-assigned this Feb 25, 2020
Copy link
Member Author

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

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

So against my prior comment, the order is actually correct I think. Looking at the build The expected and actual both have second post after first post. ex.

AssertionError: expected '\n                window.__APOLLO_STATE__={"Page:cc38e1248273d99":{"id":"cc38e1248273d99","title":"Blog","link":"/blog/first-post","filePath":"./blog/first-post.md","fileName":"first-post","template":"blog","__typename":"Page"},"Page:6d2fe63686567be":{"id":"6d2fe63686567be","title":"Blog","link":"/blog/second-post","filePath":"./blog/second-post.md","fileName":"second-post","template":"blog","__typename":"Page"},"ROOT_QUERY":{"children({\\"parent\\":\\"blog\\"})":[{"type":"id","generated":false,"id":"Page:cc38e1248273d99","typename":"Page"},{"type":"id","generated":false,"id":"Page:6d2fe63686567be","typename":"Page"}],"navigation":[{"type":"id","generated":true,"id":"ROOT_QUERY.navigation.0","typename":"Navigation"}]},"ROOT_QUERY.navigation.0":{"label":"Blog","link":"/blog/","__typename":"Navigation"}};\n              ' to include 'window.__APOLLO_STATE__={"ROOT_QUERY.navigation.0":{"label":"Blog","link":"/blog/","__typename":"Navigation"},"ROOT_QUERY":{"navigation":[{"type":"id","generated":true,"id":"ROOT_QUERY.navigation.0","typename":"Navigation"}],"children({\\"parent\\":\\"blog\\"})":[{"type":"id","generated":false,"id":"Page:f3f1bb94286324a","typename":"Page"},{"type":"id","generated":false,"id":"Page:9a4ce9aeeb41a94","typename":"Page"}]},"Page:f3f1bb94286324a":{"id":"f3f1bb94286324a","title":"Blog","link":"/blog/first-post","filePath":"./blog/first-post.md","fileName":"first-post","template":"blog","__typename":"Page"},"Page:9a4ce9aeeb41a94":{"id":"9a4ce9aeeb41a94","title":"Blog","link":"/blog/second-post","filePath":"./blog/second-post.md","fileName":"second-post","template":"blog","__typename":"Page"}}'

So looking at them more closely, the issue isn't the the order, but rather the overall shape of the objects, which is something specific to GraphQL / Apollo.


I think I just need to relax my expectations of what is coming out of GraphQL and just leverage our unit tests more, which is the better place to capture specific APIs that our users will actually be using and not focus so much on things like Page id and hash values, as well as all the unique keys that GraphQL creates. How data comes in / out of GraphQL is more of an implementation details of our libraries.

So we should do as good as we can to validate the output in index.html, but if we go to granular, it will always just be a game of whack-a-mole. Will test for pages order, which is what we care about the most from this output.

@thescientist13 thescientist13 removed their assignment Feb 27, 2020
* graphql server working

* apollo client connect to apollo server

* connected header example using lit apollo

* todo

* todos

* query and client + server refactor

* schema refactoring

* clean up console logging

* alias all @greenwood/cli/data module imports

* avoid paramater destructuring

* graphql example in the header

* multiple schemas

* internal data sources documentation

* shelf refactor and children query integration

* refactor out ApolloQuery

* ability to intercept client.query calls

* basic semi-working implementation

* remove extra config from server context

* have puppeteer wait for graphql requests before returning content

* fix and add test cases for apollo

* merged resolvers not actually working

* multiple queries support

* everything working

* todos

* TODO tracking

* fix fallback apollo client fetch handling

* full test suite

* cache json test cases

* stablize test due to inconsistent data results ordering

* clean up deps

* todo cleanup

* remove forced client call in SSG mode for client

* represent graph through the schema

* updated data docs

* typos and grammer

* typos and community link fixes
@thescientist13 thescientist13 force-pushed the bug/issue-271-determinism branch from c81db68 to 5d4b836 Compare March 2, 2020 01:37
@thescientist13
Copy link
Member Author

Merging per consensus reached during the last project meeting and no standing objections / comments on this PR.

@thescientist13 thescientist13 merged commit a24bcde into release/0.5.0 Mar 2, 2020
@thescientist13 thescientist13 deleted the bug/issue-271-determinism branch March 2, 2020 01:47
thescientist13 added a commit that referenced this pull request Mar 11, 2020
* Rfc/issue 115 build time data access (#269)

* graphql server working

* apollo client connect to apollo server

* connected header example using lit apollo

* todo

* todos

* query and client + server refactor

* schema refactoring

* clean up console logging

* alias all @greenwood/cli/data module imports

* avoid paramater destructuring

* graphql example in the header

* multiple schemas

* internal data sources documentation

* shelf refactor and children query integration

* refactor out ApolloQuery

* ability to intercept client.query calls

* basic semi-working implementation

* remove extra config from server context

* have puppeteer wait for graphql requests before returning content

* fix and add test cases for apollo

* merged resolvers not actually working

* multiple queries support

* everything working

* todos

* TODO tracking

* fix fallback apollo client fetch handling

* full test suite

* cache json test cases

* stablize test due to inconsistent data results ordering

* clean up deps

* todo cleanup

* remove forced client call in SSG mode for client

* represent graph through the schema

* updated data docs

* typos and grammer

* typos and community link fixes

* unit test data graph

* linting

* lint fix

* added ordered index tracking when serializing pages

* formatting

* document graph page ordering

* cli data graph unit tests and expand mocha spec globbing

* address missing hash in mock graph

* loosen graph test case asserts

* update graph tests to focus less on implementation details

* add back missing develop task
thescientist13 added a commit that referenced this pull request Mar 15, 2020
* Rfc/issue 115 build time data access (#269)

* graphql server working

* apollo client connect to apollo server

* connected header example using lit apollo

* todo

* todos

* query and client + server refactor

* schema refactoring

* clean up console logging

* alias all @greenwood/cli/data module imports

* avoid paramater destructuring

* graphql example in the header

* multiple schemas

* internal data sources documentation

* shelf refactor and children query integration

* refactor out ApolloQuery

* ability to intercept client.query calls

* basic semi-working implementation

* remove extra config from server context

* have puppeteer wait for graphql requests before returning content

* fix and add test cases for apollo

* merged resolvers not actually working

* multiple queries support

* everything working

* todos

* TODO tracking

* fix fallback apollo client fetch handling

* full test suite

* cache json test cases

* stablize test due to inconsistent data results ordering

* clean up deps

* todo cleanup

* remove forced client call in SSG mode for client

* represent graph through the schema

* updated data docs

* typos and grammer

* typos and community link fixes

* unit test data graph

* linting

* lint fix

* added ordered index tracking when serializing pages

* formatting

* document graph page ordering

* cli data graph unit tests and expand mocha spec globbing

* address missing hash in mock graph

* loosen graph test case asserts

* update graph tests to focus less on implementation details

* add back missing develop task
thescientist13 added a commit that referenced this pull request Apr 22, 2020
* Rfc/issue 115 build time data access (#269)

* graphql server working

* apollo client connect to apollo server

* connected header example using lit apollo

* todo

* todos

* query and client + server refactor

* schema refactoring

* clean up console logging

* alias all @greenwood/cli/data module imports

* avoid paramater destructuring

* graphql example in the header

* multiple schemas

* internal data sources documentation

* shelf refactor and children query integration

* refactor out ApolloQuery

* ability to intercept client.query calls

* basic semi-working implementation

* remove extra config from server context

* have puppeteer wait for graphql requests before returning content

* fix and add test cases for apollo

* merged resolvers not actually working

* multiple queries support

* everything working

* todos

* TODO tracking

* fix fallback apollo client fetch handling

* full test suite

* cache json test cases

* stablize test due to inconsistent data results ordering

* clean up deps

* todo cleanup

* remove forced client call in SSG mode for client

* represent graph through the schema

* updated data docs

* typos and grammer

* typos and community link fixes

* Bug/issue 271 determinism (#292)

* Rfc/issue 115 build time data access (#269)

* graphql server working

* apollo client connect to apollo server

* connected header example using lit apollo

* todo

* todos

* query and client + server refactor

* schema refactoring

* clean up console logging

* alias all @greenwood/cli/data module imports

* avoid paramater destructuring

* graphql example in the header

* multiple schemas

* internal data sources documentation

* shelf refactor and children query integration

* refactor out ApolloQuery

* ability to intercept client.query calls

* basic semi-working implementation

* remove extra config from server context

* have puppeteer wait for graphql requests before returning content

* fix and add test cases for apollo

* merged resolvers not actually working

* multiple queries support

* everything working

* todos

* TODO tracking

* fix fallback apollo client fetch handling

* full test suite

* cache json test cases

* stablize test due to inconsistent data results ordering

* clean up deps

* todo cleanup

* remove forced client call in SSG mode for client

* represent graph through the schema

* updated data docs

* typos and grammer

* typos and community link fixes

* unit test data graph

* linting

* lint fix

* added ordered index tracking when serializing pages

* formatting

* document graph page ordering

* cli data graph unit tests and expand mocha spec globbing

* address missing hash in mock graph

* loosen graph test case asserts

* update graph tests to focus less on implementation details

* add back missing develop task

* task: refactor into single menu query, enable menu filtering with markdown declarations

* fix shelf

* fix: shelf rendering collapse/expand

* test: update al related tests

* fix: remove debug

* task: basic sorting label/index

* fix: index sorting

* fix: remove debug

* fix: current tests

* test: amending tests, removing prev mock

* test: revert previous graphql test case

* test: remove hello query

* fix: remove deprecated .json files

* fix: refactor mock graph func

* test: adding sort/filter menu tests

* task: add documentation for menus

* fix: amend documentation

* fix: amend docs for route var

* fix: typo

* task: add headingLevel and route condition, remove hardcoded vars

* fix: non-pathname menus may want linkheadings children

* task: amend docs for child heading level

* fix: change linkheadings to integer, use for headingLevel

* docs: remove navigation query docs

* test: fix test

* task: revert stub generation code

* fix: update data sources doc

* fix: amend docs for route/linkheadings additions

* fix: update filter to use title instead of label

* fix: test

* task: update docs with linkheadings query result

Co-authored-by: Owen Buckley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Content as Data P0 Critical issue that should get addressed ASAP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant