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

Synchronizing shared expression tests with backend #2917

Merged
merged 8 commits into from
Jan 20, 2025

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Jan 16, 2025

Description

I compared the folders with those in app-lib-dotnet, and updating tests to match.

A few notes:

  • Backend is missing function tests for functions not yet implemented there (_experimentalSelectAndMap, displayValue, externalApi, formatDate, hasRole, linkToComponent, linkToPage, text and value).
  • The backend also gets to test duplicate component IDs here, but that check happens so early in frontend now that catching it and handling it in shared tests is difficult.
  • I added tests for argv, and made sure to test that every expression function has a folder with shared tests.

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

@olemartinorg olemartinorg added the kind/other Pull requests containing chores/repo structure/other changes label Jan 16, 2025
@olemartinorg olemartinorg self-assigned this Jan 16, 2025
Copy link
Contributor

@cammiida cammiida left a comment

Choose a reason for hiding this comment

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

Cool!

describe('DisplayValue tests', () => {
for (const [type, config] of Object.entries(getComponentConfigs())) {
if (implementsDisplayData(config.def)) {
it(`Component '${type}' should hava e matching test in functions/displayValue/type-${type}.json`, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hehe

Suggested change
it(`Component '${type}' should hava e matching test in functions/displayValue/type-${type}.json`, () => {
it(`Component '${type}' should have a matching test in functions/displayValue/type-${type}.json`, () => {

// inside this expression, because it will simply traverse the entire layout looking for expressions.
notAnActualExpression: expression,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any),
Copy link
Contributor

Choose a reason for hiding this comment

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

Kan caste til typen det burde være i stedet? 🤷‍♀️ ev object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Den typen finnes ikke, det er litt av poenget 🫣 Men jeg ser at object funker, så det får bort behovet for eslint-disable iallefall.

Comment on lines 197 to 200
// This makes sure that the expression is never evaluated, as it is not a valid property. All properties
// that can handle expressions will be evaluated in the hierarchy generation, but errors from there will
// not effect the actual test here. Still, DataModelsProvider will find the reference to any data models
// inside this expression, because it will simply traverse the entire layout looking for expressions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Har lest denne kommentaren 10 ganger og forstår fortsatt ikke helt 😬 er det mulig å forenkle på noen måte? Kortere kan forøvrig ofte være enklere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Usikker på om kortere er enklere å forstå her, om denne kommentaren var uforståelig. Det forklarer jo hvorfor vi må gjøre dette her, og kobler på dypt inngående detaljer til flere ting (NodesProvider, DataModelsProvider osv).

Hva med denne?

This makes sure that the expression is never evaluated, as it is not a valid property. All properties
that can handle expressions (like 'hidden') will be evaluated during hierarchy generation, but errors
from there (such as unknown extra properties like this one) will not cause test failures here (so doing
this is safe). DataModelsProvider however, will recursively look inside the layout and find anything
that resembles an expression and load the data model it refers to. In other words, this makes sure we
load any data models that are only references in the expression we're testing - not elsewhere in the
layout. For an example of a test that would fail without this, see 'dataModel-non-default-model.json'.
It has only a Paragraph component with no expressions in it, so without injecting the tested
expression into that layout, DataModelsProvider would not load the data model that the expression refers
to, and the test would fail.

@olemartinorg olemartinorg merged commit bde1e4c into main Jan 20, 2025
14 of 15 checks passed
@olemartinorg olemartinorg deleted the chore/sync-shared-expr branch January 20, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/other Pull requests containing chores/repo structure/other changes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants