Skip to content

Commit

Permalink
fix(cypress): fixing AllowButton detachment from DOM (#3125)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Sep 6, 2023
1 parent 2334662 commit 1feaf9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 5 additions & 5 deletions web/cypress/e2e/TestRunDetail/Outputs.spec.ts
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
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
Expand Up @@ -190,6 +190,7 @@ const TestSpecForm = ({
type="primary"
disabled={!isValid}
onClick={form.submit}
htmlType="submit"
data-cy="assertion-form-submit-button"
>
Save Test Spec
Expand Down

0 comments on commit 1feaf9b

Please sign in to comment.