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

[TESTID-58,59] Inspect functionality for Discover and Visualizations #9292

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

ArgusLi
Copy link
Contributor

@ArgusLi ArgusLi commented Jan 28, 2025

Description

Adds a Cypress test spec for the inspect functionality in the Discover and Dashboards pages.

Issues Resolved

Closes #8955, #8956.

Screenshot

inspect.mp4

Testing the changes

With OSD running, run yarn run cypress open. In E2E specs, you will see 1 new test spec inspect.spec.js. Run the test spec.

Changelog

  • test: Add cypress integration test for the inspect functionality in the Discover and Dashboards pages.

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.71%. Comparing base (85e2187) to head (4924170).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9292   +/-   ##
=======================================
  Coverage   61.70%   61.71%           
=======================================
  Files        3816     3816           
  Lines       91824    91829    +5     
  Branches    14542    14543    +1     
=======================================
+ Hits        56664    56668    +4     
  Misses      31506    31506           
- Partials     3654     3655    +1     
Flag Coverage Δ
Linux_1 28.99% <ø> (-0.01%) ⬇️
Linux_2 56.46% <ø> (ø)
Linux_3 39.18% <ø> (-0.01%) ⬇️
Linux_4 28.90% <ø> (-0.01%) ⬇️
Windows_1 29.00% <ø> (-0.01%) ⬇️
Windows_2 56.41% <ø> (ø)
Windows_3 39.18% <ø> (+<0.01%) ⬆️
Windows_4 28.90% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ananzh
Copy link
Member

ananzh commented Jan 29, 2025

@ArgusLi could you upload a video?

@ananzh ananzh added v2.19.0 backport 2.x discover_2.0-test Issues that are specific to the Discover 2.0 testing initiative labels Jan 29, 2025
cy.intercept('POST', '**/search/*').as('docTablePostRequest');

cy.getElementByTestId('docTable').get('tbody tr').should('have.length.above', 3); // To ensure it waits until a full table is loaded into the DOM, instead of a bug where table only has 1 hit.
docTable.toggleDocTableRow(0);
Copy link
Member

Choose a reason for hiding this comment

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

Why this toggleDocTableRow is to // To ensure it waits until a full table is loaded into the DOM, instead of a bug where table only has 1 hit.?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment is for cy.getElementByTestId('docTable').get('tbody tr').should('have.length.above', 3);. I can move the comment above the line instead if it makes it more legible?

* Toggle expansion of row rowNumber of Doc Table.
* @param {number} rowNumber rowNumber of Doc Table starts at 0 for row 1.
*/
export const toggleDocTableRow = (rowNumber) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe call it expandDocTableRow is more straightforward?

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 would prefer that name, but it can also shrink the tableRow, so I think toggle is a better word.

cypress/utils/apps/query_enhancements/inspect.js Outdated Show resolved Hide resolved
];

/**
* Gets Date and returns string of date in format Jan 24, 2025 @ 16:20:08.000
Copy link
Member

Choose a reason for hiding this comment

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

should add example for input and output

Copy link
Member

Choose a reason for hiding this comment

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

should not Jan 24, 2025 @ 16:20:08.000 in overall description. we can use it as example as line 24. check my comment for formatValue and add more details.

}

/**
* Format value to the corresponding string expected in the UI.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Format value to the corresponding string expected in the UI.
/**
* Formats values for UI display by:
* - Adding thousand separators to numbers using locale settings
* - Converting SQL/PPL datetime strings (YYYY-MM-DD HH:MM:SS.SSS) to formatted dates
* - Passing through other values unchanged
* @param {string|number} value - The value to format
* @returns {string} The formatted value
* @example
* formatValue(1000) // "1,000"
* formatValue("2025-01-24 16:20:08.000") // "Jan 24, 2025 @ 16:20:08.000"
*/

Copy link
Member

Choose a reason for hiding this comment

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

nit: It would be great if you could have separate functions for number, string and date, like formatNumber, formatString and formatDate. Then in the formatValue you call them. I think in sharing or some other tests, we also need to format date. So it would be great to have separate format helpers.

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 have separated it and moved all format functions into shared.js.

};

/**
* Flatten the object in the format e.g. {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Flatten the object in the format e.g. {
/**
* Recursively flattens a nested object structure into dot notation and formats all values
* @param {object} obj - Object to be flattened
* @param {string} [parentKey] - Key prefix for nested properties
* @param {object} [properties={}] - Accumulator for flattened properties
* @returns {object} Flattened object with formatted values
* @example
* const input = {
* FlightNum: "SYS76NQ",
* DestLocation: { lat: "38.94449997", lon: "-77.45580292" }
* };
* flattenObjectAndFormatValues(input)
* // Returns: {
* // FlightNum: "SYS76NQ",
* // "DestLocation.lat": "38.94449997",
* // "DestLocation.lon": "-77.45580292"
* // }
*/

better to have both input and output and don't put the example in the overall discription

};

/**
* Flatten the array in the format e.g. [
Copy link
Member

Choose a reason for hiding this comment

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

same issue

Copy link
Member

Choose a reason for hiding this comment

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

description is not clear. suggest to change to Flattens an array of field definitions and extracts values for a specific row

}
};

/**
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
/**
* Verifies that specified visualizations in the Flights dashboard do not have inspect options
* Tests each visualization in visualizationTitlesWithNoInspectOptions array
*/

};

/**
* In the Flights dashboard, verify that the visualizations identified as having an inspect option have the option.
Copy link
Member

Choose a reason for hiding this comment

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

same to clarify description

ananzh
ananzh previously approved these changes Jan 30, 2025
@ananzh
Copy link
Member

ananzh commented Jan 30, 2025

Can you update ciGroup10 or 12 in include this test?

Signed-off-by: Argus Li <[email protected]>
LDrago27
LDrago27 previously approved these changes Jan 30, 2025
cy.deleteWorkspaceByName(workspaceName);
cy.visit('/app/home');
cy.osd.createInitialWorkspaceWithDataSource(datasourceName, workspaceName);
cy.wait(2000);
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think we need this wait here

config.language
);

cy.log(flattenedFieldsWithValues);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this cy.log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, should have cleaned it up.

(config.language === QueryLanguages.SQL.name ||
config.language === QueryLanguages.PPL.name)
) {
cy.log(`Skipped for ${key}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this?

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 want to keep this here. These are skipped because of a bug (#9305), and I want to make it clear they are skipped. I'll add the link to the bug to the comment as well.

Removed a log and a wait.

Signed-off-by: Argus Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport 2.19 discover_2.0-test Issues that are specific to the Discover 2.0 testing initiative v2.19.0 valued-contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Inspect Functionality Testing] TESTID-58: Test inspect for queries
4 participants