Skip to content

Commit 0285345

Browse files
committed
chore: fix test
1 parent 49d278a commit 0285345

File tree

4 files changed

+67
-69
lines changed

4 files changed

+67
-69
lines changed

cypress/e2e/page/more-page-action.cy.ts

Lines changed: 29 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -34,65 +34,37 @@ describe('More Page Actions', () => {
3434
// Find the Getting started page and hover to reveal the more actions
3535
cy.task('log', 'Looking for Getting started page');
3636

37-
// Find the page by its text content
38-
cy.contains('Getting started').should('exist').and('be.visible');
39-
40-
// Hover over the page item to reveal the more actions button
41-
cy.task('log', 'Hovering over page item to reveal more actions');
37+
// Hover over the Getting started page to reveal more actions
38+
cy.task('log', 'Hovering over Getting started page');
4239
cy.contains('Getting started')
43-
.parents('[data-testid*="view-item"]')
44-
.first()
40+
.parent()
41+
.parent()
4542
.trigger('mouseenter', { force: true })
46-
.wait(500);
43+
.trigger('mouseover', { force: true });
4744

48-
// Find and click the more actions button (...)
49-
cy.task('log', 'Looking for more actions button');
50-
cy.contains('Getting started')
51-
.parents('[data-testid*="view-item"]')
52-
.first()
53-
.within(() => {
54-
// Try multiple ways to find the more actions button
55-
cy.get('[data-testid="view-item-more-actions"]')
56-
.should('exist')
57-
.and('be.visible')
58-
.click({ force: true });
59-
});
45+
cy.wait(1000);
46+
47+
// Click the more actions button
48+
cy.task('log', 'Clicking more actions button');
49+
PageSelectors.moreActionsButton().first().click({ force: true });
6050

6151
waitForReactUpdate(500);
6252

63-
// Verify the popover is open
64-
cy.task('log', 'Verifying popover is open');
65-
cy.get('[data-testid="more-actions-popover"]').should('exist').and('be.visible');
66-
cy.wait(500);
53+
// Verify the menu is open
54+
cy.task('log', 'Verifying menu is open');
55+
cy.get('[data-slot="dropdown-menu-content"]', { timeout: 5000 }).should('exist');
6756

6857
// Now verify the expected menu items
69-
cy.task('log', 'Verifying menu items in popover');
70-
cy.get('[data-testid="more-actions-popover"]').within(() => {
71-
// Check for Delete option
72-
cy.task('log', 'Checking for Delete option');
73-
cy.get('[data-testid="delete-page-option"]')
74-
.should('exist')
75-
.and('be.visible')
76-
.and('contain.text', 'Delete');
77-
78-
// Check for Rename option
79-
cy.task('log', 'Checking for Rename option');
80-
cy.get('[data-testid="rename-page-option"]')
81-
.should('exist')
82-
.and('be.visible')
83-
.and('contain.text', 'Rename');
84-
85-
// Check for Duplicate option
86-
cy.task('log', 'Checking for Duplicate option');
87-
cy.get('[data-testid="duplicate-page-option"]')
88-
.should('exist')
89-
.and('be.visible')
90-
.and('contain.text', 'Duplicate');
91-
92-
// Optional: Check for additional menu items
93-
cy.task('log', 'Successfully verified all core menu items in More actions popover');
58+
cy.task('log', 'Verifying menu items');
59+
cy.get('[data-slot="dropdown-menu-content"]').within(() => {
60+
// Look for items by text content since test ids might vary
61+
cy.contains('Delete').should('exist');
62+
cy.contains('Duplicate').should('exist');
63+
cy.contains('Move to').should('exist');
9464
});
9565

66+
cy.task('log', 'Successfully verified all core menu items');
67+
9668
// Close the popover
9769
cy.task('log', 'Closing popover');
9870
cy.get('body').click(0, 0);
@@ -128,30 +100,23 @@ describe('More Page Actions', () => {
128100
cy.task('log', 'Hovering over the created page');
129101
PageSelectors.names()
130102
.last()
131-
.parents('[data-testid*="view-item"]')
132-
.first()
103+
.parent()
104+
.parent()
133105
.trigger('mouseenter', { force: true })
134-
.wait(500);
106+
.trigger('mouseover', { force: true });
107+
108+
cy.wait(1000);
135109

136110
// Click the more actions button
137111
cy.task('log', 'Clicking more actions button');
138-
PageSelectors.names()
139-
.last()
140-
.parents('[data-testid*="view-item"]')
141-
.first()
142-
.within(() => {
143-
cy.get('[data-testid="view-item-more-actions"]')
144-
.should('exist')
145-
.and('be.visible')
146-
.click({ force: true });
147-
});
112+
PageSelectors.moreActionsButton().first().click({ force: true });
148113

149114
waitForReactUpdate(500);
150115

151116
// Click Rename option
152117
cy.task('log', 'Clicking Rename option');
153-
cy.get('[data-testid="more-actions-popover"]').within(() => {
154-
cy.get('[data-testid="rename-page-option"]').click();
118+
cy.get('[data-slot="dropdown-menu-content"]').within(() => {
119+
cy.contains('Rename').click();
155120
});
156121

157122
waitForReactUpdate(500);

cypress/e2e/page/publish-page.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ describe('Publish Page Test', () => {
4545

4646
// 6. Click Publish tab
4747
cy.task('log', 'Clicking Publish tab');
48-
ShareSelectors.publishTab().click();
48+
ShareSelectors.publishTabButton().click();
4949
cy.wait(1000);
5050

5151
// 7. Publish the page
5252
cy.task('log', 'Publishing the page');
53-
ShareSelectors.publishButton().click();
53+
ShareSelectors.publishConfirmButton().click();
5454
cy.wait(3000); // Wait for publish action to complete
5555

5656
// 8. Copy the publish URL

cypress/e2e/page/share-page.cy.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,20 @@ describe('Share Page Test', () => {
4444
PageSelectors.names().last().invoke('text').then((pageTitle) => {
4545
cy.task('log', `Page created: ${pageTitle}`);
4646

47+
// Wait for any modals to close after page creation
48+
cy.wait(1000);
49+
50+
// Close any open modals or dialogs
51+
cy.get('body').then($body => {
52+
if ($body.find('[role="dialog"]').length > 0) {
53+
cy.get('body').type('{esc}');
54+
cy.wait(500);
55+
}
56+
});
57+
4758
// 5. Open share dialog
4859
cy.task('log', 'Opening share dialog');
49-
cy.get('[data-testid="share-button"]').click();
60+
cy.get('[data-testid="share-button"]').first().click({ force: true });
5061
waitForReactUpdate(500);
5162

5263
// 6. Input user B's email

cypress/support/page-utils.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,29 @@ export class TestTool {
152152
}
153153

154154
// Additional custom methods used in tests
155-
155+
156+
/**
157+
* Edits the page title
158+
* Used in publish-page.cy.ts and other tests
159+
*/
160+
static editPageTitle(title: string) {
161+
cy.task('log', `Editing page title to: ${title}`);
162+
PageSelectors.titleInput()
163+
.clear()
164+
.type(title);
165+
cy.wait(500); // Wait for title to be saved
166+
}
167+
168+
/**
169+
* Adds a paragraph to the current page
170+
* Used in publish-page.cy.ts and other tests
171+
*/
172+
static addParagraph(content: string) {
173+
cy.task('log', `Adding paragraph: ${content}`);
174+
cy.get('[role="textbox"]').first().type(content);
175+
cy.wait(500); // Wait for content to be saved
176+
}
177+
156178
/**
157179
* Verifies that a page exists in the sidebar
158180
* Used in create-delete-page.cy.ts
@@ -163,7 +185,7 @@ export class TestTool {
163185
.should('exist')
164186
.should('be.visible');
165187
}
166-
188+
167189
/**
168190
* Verifies that a page does not exist in the sidebar
169191
* Used in create-delete-page.cy.ts

0 commit comments

Comments
 (0)