`);
const wordTestText = 'This desktop textarea has exactly seven words total.';
const charTestText = 'Character counting test for desktop layouts.';
cy.get('#word-count-textarea').type(wordTestText);
cy.get('.usa-word-count').should('contain', '7 words');
cy.get('#char-count-textarea').type(charTestText);
cy.get('.usa-character-count').should(
'contain',
`${charTestText.length} characters of 300 used`
);
});
});
describe('Large Desktop Responsive Behavior', () => {
beforeEach(() => {
cy.viewport(1440, 900); // Large Desktop
});
it('should maintain proper spacing on large screens', () => {
cy.mount(`
`);
// Should have proper two-column layout with adequate spacing
cy.get('.desktop\\:grid-col-6').should('have.length', 2);
// Container should be properly centered
cy.get('.grid-container').should('have.css', 'max-width');
// Textareas should have adequate size on large screens
cy.get('textarea').each(($textarea) => {
cy.wrap($textarea).then(($el) => {
const width = $el.outerWidth();
const height = $el.outerHeight();
expect(width).to.be.greaterThan(400);
expect(height).to.be.greaterThan(150);
});
});
});
it('should handle large desktop auto-resize efficiently', () => {
cy.mount(`
`);
const veryLongContent = Array(20)
.fill(
'This is a very long line of content that will test auto-resize functionality on large desktop screens.'
)
.join('\n');
cy.get('textarea').type(veryLongContent);
// Should expand significantly on large screens
cy.get('textarea').then(($textarea) => {
const height = $textarea.outerHeight();
expect(height).to.be.greaterThan(300);
});
});
});
describe('Responsive Edge Cases', () => {
it('should handle viewport transitions smoothly', () => {
cy.mount(`
`);
const transitionText = 'This text will test smooth transitions between viewport sizes.';
// Test mobile to tablet transition
cy.viewport(375, 667);
cy.get('textarea').type(transitionText).should('be.visible');
cy.viewport(768, 1024);
cy.get('textarea').should('be.visible').should('have.value', transitionText);
cy.viewport(1200, 800);
cy.get('textarea').should('be.visible').should('have.value', transitionText);
});
it('should handle long content without horizontal overflow', () => {
const longLineText =
'This is an extremely long line of text that should not cause horizontal scrolling or layout issues at any viewport size regardless of screen width or device orientation.';
cy.mount(`
`);
// Test at different viewports
const viewports = [
[320, 568], // Small mobile
[768, 1024], // Tablet
[1200, 800], // Desktop
];
viewports.forEach(([width, height]) => {
cy.viewport(width, height);
cy.get('textarea').clear().type(longLineText);
// Should not cause horizontal overflow
cy.get('textarea').then(($textarea) => {
expect($textarea[0].scrollWidth).to.be.at.most($textarea[0].clientWidth + 10);
});
});
});
it('should handle dynamic height changes at different screen sizes', () => {
cy.mount(`
`);
const scenarios = [
{ viewport: [375, 667], content: 'Short content' },
{
viewport: [768, 1024],
content: 'Medium length content\nWith multiple lines\nFor tablet testing',
},
{
viewport: [1200, 800],
content:
'Very long content\nWith many lines\nFor desktop testing\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8',
},
];
scenarios.forEach(({ viewport, content }) => {
cy.viewport(viewport[0], viewport[1]);
cy.get('textarea').clear().type(content);
// Should auto-resize appropriately
cy.get('textarea').then(($textarea) => {
const height = $textarea.outerHeight();
const lineCount = content.split('\n').length;
expect(height).to.be.greaterThan(lineCount * 15); // Rough estimate
});
});
});
it('should maintain accessibility at all screen sizes', () => {
cy.mount(`
This textarea should be accessible at all screen sizes
`);
const viewports = [
[375, 667], // Mobile
[768, 1024], // Tablet
[1200, 800], // Desktop
];
viewports.forEach(([width, height]) => {
cy.viewport(width, height);
cy.injectAxe();
cy.checkAccessibility();
// Check focus indicators work at all sizes
cy.get('textarea')
.focus()
.should('have.focus')
.should('have.css', 'outline-width')
.and('not.equal', '0px');
});
});
it('should handle copy-paste operations at different screen sizes', () => {
cy.mount(`
`);
const pasteContent =
'This is pasted content\nWith multiple lines\nThat should work consistently\nAcross all screen sizes';
const viewports = [
[375, 667], // Mobile
[768, 1024], // Tablet
[1200, 800], // Desktop
];
viewports.forEach(([width, height]) => {
cy.viewport(width, height);
cy.get('textarea').clear().type(pasteContent);
cy.get('textarea').should('have.value', pasteContent);
// Select all and replace (simulating paste)
cy.get('textarea').select().type('Replaced content at different viewport');
cy.get('textarea').should('have.value', 'Replaced content at different viewport');
});
});
});
});