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

feat(test-data-generator): Output required Test Interface Actions #657

Merged
merged 20 commits into from
Mar 19, 2024

Conversation

lukehesluke
Copy link
Contributor

@lukehesluke lukehesluke commented Mar 14, 2024

Closes #656

Previously, test-data-generator generated one file, test-data/test-data.json, which listed the criteria of Opportunities that were required for testing.

Now, it generates two files:

  • output/opportunity-test-data.json: Same as the old one
  • output/test-interface-actions.json: Has TI Actions

I'll include some examples of the latter in the QA part.

The reason that I introduced TI Actions into a new file, rather than bringing them into the same file is because the original file has a very specific schema.org-style design. There's no where for TI Actions to be included – reasonable as it's really just a completely different style of data. So, instead there's a new file. It also uses the ItemList type, but each item, is just a TI Action type, with only @id, e.g. { "@type": "test:AccessChannelUpdateSimulateAction" }

QA

npm run test-data-generator (against default.json i.e. almost every feature):

{
  "@context": [
    "https://openactive.io/",
    "https://openactive.io/test-interface"
  ],
  "@type": "ItemList",
  "numberOfItems": 12,
  "itemListElement": [
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:AccessChannelUpdateSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:AccessCodeUpdateSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:AccessPassUpdateSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:AttendeeAbsentSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:AttendeeAttendedSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:CustomerNoticeSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:ReplacementSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerAcceptOrderProposalSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerAmendOrderProposalSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerRejectOrderProposalSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerRequestedCancellationSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerRequestedCancellationWithMessageSimulateAction"
      }
    }
  ]
}

npm run test-data-generator -- common-error-conditions (a minimal example)

{
  "@context": [
    "https://openactive.io/",
    "https://openactive.io/test-interface"
  ],
  "@type": "ItemList",
  "numberOfItems": 1,
  "itemListElement": [
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerAcceptOrderProposalSimulateAction"
      }
    }
  ]
}

Note: in theory, that one shouldn't have any actions in it at all. Accept Order Proposal action being in there is a kind of hack, explained in a code comment

npm run test-data-generator -- access-channel-update-notifications

{
  "@context": [
    "https://openactive.io/",
    "https://openactive.io/test-interface"
  ],
  "@type": "ItemList",
  "numberOfItems": 2,
  "itemListElement": [
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:AccessChannelUpdateSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerAcceptOrderProposalSimulateAction"
      }
    }
  ]
}

NODE_ENV=dev npm run test-data-generator, where I changed dev.json to be: required features only, except for Seller Requested Cancellation (w & w/o message) and Seller Requested Replacement; simple flow only:

{
  "@context": [
    "https://openactive.io/",
    "https://openactive.io/test-interface"
  ],
  "@type": "ItemList",
  "numberOfItems": 3,
  "itemListElement": [
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:ReplacementSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerRequestedCancellationSimulateAction"
      }
    },
    {
      "@type": "ListItem",
      "item": {
        "@type": "test:SellerRequestedCancellationWithMessageSimulateAction"
      }
    }
  ]
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this was just accidentally included in git

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(auto-generated file) Changed to feature-requirements.json (which also now has TI actions)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Auto-generated file

@@ -15,7 +15,7 @@ const { FeatureJsonSchema } = require('./featureJson.js');

const FEATURES_ROOT = path.join(__dirname, '..', 'test', 'features');
const INDEX_README_FILE = path.join(FEATURES_ROOT, 'README.md');
const INDEX_CRITERIA_REQUIREMENTS_JSON_FILE = path.join(FEATURES_ROOT, 'criteria-requirements.json');
const INDEX_FEATURE_REQUIREMENTS_JSON_FILE = path.join(FEATURES_ROOT, 'feature-requirements.json');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed because it now contains more info. But this new info (required TI Actions) is still per-feature. So, feature-requirements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the reviewer is not aware, Test Data Generator gets its metadata from this file which is generated during automatic documentation generation (which has access to each test's describeFeature(..) metadata)

Copy link
Contributor

Choose a reason for hiding this comment

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

Appreciate the rename very much!

@@ -13,10 +19,12 @@ npm run test-data-generator # all active features specified in the current confi

npm run test-data-generator -- common-error-conditions # only enough data for the common-error-conditions feature

npm run test-data-generator -- --output ./test-data.json # output to ./test-data.json
npm run test-data-generator -- --output-dir ../../../test-data-generator-output # output to ../../../test-data-generator-output
Copy link
Contributor Author

Choose a reason for hiding this comment

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

--output-dir seems a bit simpler to maintain when we're now dealing with multiple output files and I expect sufficiently customizable for most purposes? Please correct me if I'm wrong!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep makes sense

Comment on lines +192 to +197
! There is a sort-of bug here, which is that
test:SellerAcceptOrderProposalSimulateAction will be outputted even if Test
Data Generator has been called on a category or feature that doesn't include
successful bookings. This is technically incorrect. In the opinion of this
author, it's fine because every Booking System should be able to support
successful bookings (!) */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

of note

@lukehesluke lukehesluke marked this pull request as ready for review March 14, 2024 11:42
@lukehesluke lukehesluke requested a review from civsiv March 14, 2024 11:46
Base automatically changed from feature/annotate-ti-actions to master March 18, 2024 15:25
@lukehesluke lukehesluke merged commit dd45abd into master Mar 19, 2024
32 checks passed
@lukehesluke lukehesluke deleted the feature/test-data-generator-ti-actions branch March 19, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have Test-Data-Generator output which controlled mode actions are needed for a particular user
2 participants