61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
// RightMenu.spec.js
|
|
import RightMenu from 'src/components/common/RightMenu.vue';
|
|
|
|
describe.only('<RightMenu />', () => {
|
|
beforeEach(() => {
|
|
// Mock stores and composables
|
|
cy.stub(window, 'useStateStore').returns({
|
|
rightDrawer: false,
|
|
isHeaderMounted: () => true,
|
|
});
|
|
cy.stub(window, 'useI18n').returns({ t: (key) => key });
|
|
});
|
|
|
|
it('renders correctly', () => {
|
|
cy.createWrapper(RightMenu);
|
|
cy.get('#actions-append').should('exist');
|
|
});
|
|
|
|
it('observes right panel content changes', () => {
|
|
cy.createWrapper(RightMenu);
|
|
const rightPanel = document.createElement('div');
|
|
rightPanel.id = 'right-panel';
|
|
document.body.appendChild(rightPanel);
|
|
|
|
const newChild = document.createElement('div');
|
|
rightPanel.appendChild(newChild);
|
|
|
|
cy.wrap(Cypress.vueWrapper.vm.hasContent).should('equal', 1);
|
|
rightPanel.remove();
|
|
});
|
|
|
|
it('hides right drawer when no content and no slot', () => {
|
|
cy.createWrapper(RightMenu);
|
|
cy.wrap(Cypress.vueWrapper.vm.stateStore.rightDrawer).should('be.false');
|
|
});
|
|
|
|
it('shows right drawer when slot content is provided', () => {
|
|
cy.createWrapper(RightMenu, {
|
|
slots: {
|
|
'right-panel': '<div>Slot Content</div>',
|
|
},
|
|
});
|
|
cy.wrap(Cypress.vueWrapper.vm.stateStore.rightDrawer).should('be.true');
|
|
});
|
|
|
|
it('teleports content to #actions-append when header is mounted', () => {
|
|
cy.createWrapper(RightMenu);
|
|
cy.get('#actions-append').should('exist');
|
|
});
|
|
|
|
it('does not teleport content when header is not mounted', () => {
|
|
cy.stub(window, 'useStateStore').returns({
|
|
rightDrawer: false,
|
|
isHeaderMounted: () => false,
|
|
});
|
|
|
|
cy.createWrapper(RightMenu);
|
|
cy.get('#actions-append').should('not.exist');
|
|
});
|
|
});
|