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

fix(cypress): fixing AllowButton detachment from DOM #3125

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions web/cypress/e2e/TestRunDetail/Outputs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Outputs', () => {

// Save output
cy.wait('@getSelect');
cy.get('[data-cy=output-save-button]').click({force: true});
cy.get('[data-cy=output-save-button]').click();
cy.get('[data-cy=output-pending-tag]').should('have.length', 1);

// Add new output from scratch
Expand All @@ -27,7 +27,7 @@ describe('Outputs', () => {
cy.get('[data-cy=expression-editor] [contenteditable=true]').type('attr:http.status_code');
});
cy.wait('@getSelect');
cy.get('[data-cy=output-save-button]').click({force: true});
cy.get('[data-cy=output-save-button]').click();
cy.get('[data-cy=output-pending-tag]').should('have.length', 2);

// Publish and run
Expand All @@ -53,7 +53,7 @@ describe('Outputs', () => {

// Save output
cy.wait('@getSelect');
cy.get('[data-cy=output-save-button]').click({force: true});
cy.get('[data-cy=output-save-button]').click();
cy.get('[data-cy=output-pending-tag]').should('have.length', 1);

// Add new output from scratch
Expand All @@ -66,7 +66,7 @@ describe('Outputs', () => {
cy.get('[data-cy=expression-editor] [contenteditable=true]').type('attr:http.status_code');
});
cy.wait('@getSelect');
cy.get('[data-cy=output-save-button]').click({force: true});
cy.get('[data-cy=output-save-button]').click();
cy.get('[data-cy=output-pending-tag]').should('have.length', 2);

// Delete output
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('Outputs', () => {

// Save output
cy.wait('@getSelect');
cy.get('[data-cy=output-save-button]').click({force: true});
cy.get('[data-cy=output-save-button]').click();
cy.get('[data-cy=output-pending-tag]').should('have.length', 1);

// Revert
Expand Down
9 changes: 6 additions & 3 deletions web/src/components/AllowButton/AllowButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ const AllowButton = ({operation, ...props}: IProps) => {
const {getIsAllowed} = useCustomization();
const isAllowed = getIsAllowed(operation);

return (
<Tooltip title={!isAllowed ? 'You are not allowed to perform this operation' : ''}>
<Button {...props} disabled={!isAllowed || props.disabled} />
// the tooltip unmounts and remounts the children, detaching it from the DOM
return isAllowed ? (
<Button {...props} disabled={props.disabled} />
) : (
<Tooltip title="You are not allowed to perform this operation">
<Button {...props} disabled />
</Tooltip>
);
};
Expand Down
1 change: 1 addition & 0 deletions web/src/components/TestSpecForm/TestSpecForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
return () => {
onCancel();
};
}, []);

Check warning on line 77 in web/src/components/TestSpecForm/TestSpecForm.tsx

View workflow job for this annotation

GitHub Actions / WebUI unit tests

React Hook useEffect has missing dependencies: 'assertions', 'name', 'onCancel', 'onValuesChange', and 'selector'. Either include them or remove the dependency array. If 'onCancel' changes too often, find the parent component that defines it and wrap that definition in useCallback

useEffect(() => {
form.setFieldsValue({
Expand Down Expand Up @@ -190,6 +190,7 @@
type="primary"
disabled={!isValid}
onClick={form.submit}
htmlType="submit"
data-cy="assertion-form-submit-button"
>
Save Test Spec
Expand Down
Loading