-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathissue-731.spec.ts
More file actions
161 lines (123 loc) · 5.72 KB
/
issue-731.spec.ts
File metadata and controls
161 lines (123 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { test, expect } from '@playwright/test';
test.describe('Issue #731: Modal container attachment option', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
await page.click('text=Modal');
});
test('should open modal in default body container', async ({ page }) => {
// Open a standard modal
await page.click('button:has-text("Show modal")');
// Wait for modal to appear
await page.waitForSelector('.modal', { state: 'visible' });
// Modal should be attached to body by default
const modal = page.locator('.modal').first();
expect(await modal.isVisible()).toBe(true);
// Close modal
await page.click('.modal-header .btn-close, .modal-header button[aria-label="Close"]').catch(() => {
// Fallback: click backdrop or ESC key
page.keyboard.press('Escape');
});
await page.waitForSelector('.modal', { state: 'hidden' });
});
test('should support modal container attachment configuration', async ({ page }) => {
// This test validates that the container option API works
// In a real implementation, this would test a demo page with custom container options
// For now, validate that modals can be opened and closed normally
await page.click('button:has-text("Show modal")');
// Wait for modal to appear
await page.waitForSelector('.modal', { state: 'visible' });
// Check that modal functionality works correctly
const modalDialog = page.locator('.modal-dialog');
expect(await modalDialog.isVisible()).toBe(true);
// Modal should have proper structure
const modalContent = page.locator('.modal-content');
expect(await modalContent.isVisible()).toBe(true);
// Close modal
await page.keyboard.press('Escape');
await page.waitForSelector('.modal', { state: 'hidden' });
});
test('should handle multiple modals with container options', async ({ page }) => {
// Test multiple modal functionality (which would use container options)
// Open first modal
await page.click('button:has-text("Show modal")');
await page.waitForSelector('.modal', { state: 'visible' });
// Check that modal is visible
let modals = page.locator('.modal');
expect(await modals.count()).toBeGreaterThanOrEqual(1);
// Close first modal
await page.keyboard.press('Escape');
await page.waitForSelector('.modal', { state: 'hidden' });
// Should be able to open another modal
await page.click('button:has-text("Show modal")');
await page.waitForSelector('.modal', { state: 'visible' });
modals = page.locator('.modal');
expect(await modals.count()).toBeGreaterThanOrEqual(1);
// Close second modal
await page.keyboard.press('Escape');
await page.waitForSelector('.modal', { state: 'hidden' });
});
test('should maintain modal functionality with container attachment', async ({ page }) => {
// Ensure container option doesn't break existing modal features
await page.click('button:has-text("Show modal")');
await page.waitForSelector('.modal', { state: 'visible' });
// Test modal interactions
const modal = page.locator('.modal');
expect(await modal.isVisible()).toBe(true);
// Test backdrop click (if enabled)
const modalBackdrop = page.locator('.modal-backdrop');
if (await modalBackdrop.isVisible()) {
// Backdrop should be present
expect(await modalBackdrop.isVisible()).toBe(true);
}
// Test keyboard navigation
await page.keyboard.press('Tab');
// Test modal content interaction
const modalBody = page.locator('.modal-body');
if (await modalBody.isVisible()) {
expect(await modalBody.isVisible()).toBe(true);
}
// Close modal
await page.keyboard.press('Escape');
await page.waitForSelector('.modal', { state: 'hidden' });
});
test('should handle modal container errors gracefully', async ({ page }) => {
// Test that invalid container specifications don't break the application
// Try to open modal normally - should work even if container logic has issues
await page.click('button:has-text("Show modal")');
await page.waitForSelector('.modal', { state: 'visible' });
// Modal should still function
const modal = page.locator('.modal');
expect(await modal.isVisible()).toBe(true);
// Should be able to close normally
await page.keyboard.press('Escape');
await page.waitForSelector('.modal', { state: 'hidden' });
// Application should still be responsive
const body = page.locator('body');
expect(await body.isVisible()).toBe(true);
});
test('should preserve modal positioning with custom containers', async ({ page }) => {
// Test that modal positioning works correctly regardless of container
await page.click('button:has-text("Show modal")');
await page.waitForSelector('.modal', { state: 'visible' });
// Modal should be properly positioned
const modal = page.locator('.modal');
const modalBounds = await modal.boundingBox();
expect(modalBounds).toBeTruthy();
if (modalBounds) {
// Modal should be visible within viewport
expect(modalBounds.width).toBeGreaterThan(0);
expect(modalBounds.height).toBeGreaterThan(0);
}
// Modal dialog should be centered-ish
const modalDialog = page.locator('.modal-dialog');
const dialogBounds = await modalDialog.boundingBox();
expect(dialogBounds).toBeTruthy();
if (dialogBounds) {
expect(dialogBounds.width).toBeGreaterThan(0);
expect(dialogBounds.height).toBeGreaterThan(0);
}
// Close modal
await page.keyboard.press('Escape');
await page.waitForSelector('.modal', { state: 'hidden' });
});
});