-
Notifications
You must be signed in to change notification settings - Fork 113
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
add functional test for sidecar #1141
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
cypress/integration/plugins/dashboards-assistant/chatbot_sidecar_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { BASE_PATH } from '../../../utils/constants'; | ||
|
||
if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { | ||
describe('Assistant sidecar spec', () => { | ||
beforeEach(() => { | ||
// Set welcome screen tracking to false | ||
localStorage.setItem('home:welcome:show', 'false'); | ||
// Set new theme modal to false | ||
localStorage.setItem('home:newThemeModal:show', 'false'); | ||
}); | ||
|
||
beforeEach(() => { | ||
// Visit OSD | ||
cy.visit(`${BASE_PATH}/app/home`); | ||
|
||
// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load | ||
cy.get(`input[placeholder="Ask question"]`, { timeout: 120000 }).should( | ||
'be.length', | ||
1 | ||
); | ||
}); | ||
|
||
describe('sidecar spec', () => { | ||
it('open sidecar and render normally, support show and hide', () => { | ||
// The header may render multiple times, wait for UI to be stable | ||
cy.wait(5000); | ||
|
||
// enable to toggle and open sidecar, OSD will be pushed accordingly. | ||
cy.get(`img[aria-label="toggle chat flyout icon"]`).click(); | ||
cy.get('[class~="chatbot-sidecar"]').should('be.visible'); | ||
cy.get('[class~="chatbot-sidecar"]').should( | ||
'have.css', | ||
'width', | ||
'460px' | ||
); | ||
//Wrapper and header have related padding style. | ||
cy.get('[class~="app-wrapper"]').should( | ||
'have.css', | ||
'padding-right', | ||
'460px' | ||
); | ||
cy.get('[id="globalHeaderBars"]') | ||
.children() | ||
.should('have.css', 'padding-right', '460px'); | ||
|
||
// click toggle to call sidecar hide, sidecar will be hidden and paddingSize on header and wrapper will be zero. | ||
cy.get(`img[aria-label="toggle chat flyout icon"]`).click(); | ||
cy.get('[class~="chatbot-sidecar"]').should( | ||
'have.css', | ||
'display', | ||
'none' | ||
); | ||
cy.get('[class~="app-wrapper"]').should( | ||
'not.have.attr', | ||
'padding-right' | ||
); | ||
cy.get('[id="globalHeaderBars"]') | ||
.children() | ||
.should('not.have.attr', 'padding-right'); | ||
|
||
// click toggle to call sidecar show | ||
cy.get(`img[aria-label="toggle chat flyout icon"]`).click(); | ||
cy.get('[class~="chatbot-sidecar"]').should('be.visible'); | ||
cy.get('[class~="app-wrapper"]').should( | ||
'have.css', | ||
'padding-right', | ||
'460px' | ||
); | ||
cy.get('[id="globalHeaderBars"]') | ||
.children() | ||
.should('have.css', 'padding-right', '460px'); | ||
}); | ||
|
||
it('open sidecar and support to switch docked mode', () => { | ||
// The header may render multiple times, wait for UI to be stable | ||
cy.wait(5000); | ||
|
||
// enable to toggle and open sidecar, OSD will be pushed accordingly. | ||
cy.get(`img[aria-label="toggle chat flyout icon"]`).click(); | ||
cy.get('[class~="chatbot-sidecar"]').should('be.visible'); | ||
cy.get('[class~="app-wrapper"]').should( | ||
'have.css', | ||
'padding-right', | ||
'460px' | ||
); | ||
|
||
// switch to docked left | ||
cy.get('[id="sidecarModeIcon"]').click(); | ||
cy.get('[data-test-subj="sidecar-mode-icon-menu-item-left"]').click(); | ||
cy.get('[class~="app-wrapper"]').should( | ||
'have.css', | ||
'padding-left', | ||
'460px' | ||
); | ||
|
||
// switch to docked take over | ||
cy.get('[id="sidecarModeIcon"]').click(); | ||
cy.get( | ||
'[data-test-subj="sidecar-mode-icon-menu-item-takeover"]' | ||
).click(); | ||
cy.get('[class~="app-wrapper"]').should( | ||
'not.have.attr', | ||
'padding-left' | ||
); | ||
cy.get('[class~="app-wrapper"]').should( | ||
'not.have.attr', | ||
'padding-right' | ||
); | ||
}); | ||
|
||
it('open sidecar and support resizable', () => { | ||
// The header may render multiple times, wait for UI to be stable | ||
cy.wait(5000); | ||
|
||
// enable to toggle and open sidecar, OSD will be pushed accordingly. | ||
cy.get(`img[aria-label="toggle chat flyout icon"]`).click(); | ||
// switch to docked left | ||
cy.get('[id="sidecarModeIcon"]').click(); | ||
cy.get('[data-test-subj="sidecar-mode-icon-menu-item-left"]').click(); | ||
cy.get('[class~="chatbot-sidecar"]').should('be.visible'); | ||
cy.get('[class~="chatbot-sidecar"]').should( | ||
'have.css', | ||
'width', | ||
'460px' | ||
); | ||
|
||
//drag from left to right | ||
cy.get('[data-test-subj="resizableButton"]').trigger('mousedown', { | ||
clientX: 0, | ||
pageX: 0, | ||
pageY: 0, | ||
}); | ||
cy.window().trigger('mousemove', { clientX: 1000, pageX: 0, pageY: 0 }); | ||
cy.window().trigger('mouseup', { force: true }); | ||
cy.get('[class~="chatbot-sidecar"]').should( | ||
'have.css', | ||
'width', | ||
`${1000 + 460}px` | ||
); | ||
|
||
//drag from right to left | ||
cy.get('[data-test-subj="resizableButton"]').trigger('mousedown', { | ||
clientX: 0, | ||
pageX: 0, | ||
pageY: 0, | ||
}); | ||
cy.window().trigger('mousemove', { | ||
clientX: -1000, | ||
pageX: 0, | ||
pageY: 0, | ||
}); | ||
cy.window().trigger('mouseup', { force: true }); | ||
cy.get('[class~="chatbot-sidecar"]').should( | ||
'have.css', | ||
'width', | ||
`${1460 - 1000}px` | ||
); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we change to
cy.get("#sidecarModeIcon")
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both ways are OK.