Skip to content
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

Update Cypress tests to reference elements by name and role instead of data-testid #353

Merged
merged 32 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
afb2cba
Install "Cypress Testing Library" from react testing library
felixhabib May 17, 2024
dd806c4
Add typescript to react testing library
felixhabib May 20, 2024
0beaefc
Switch files to typescript
felixhabib May 20, 2024
74ba535
Remove unnecessary testids and refactor
felixhabib May 22, 2024
00a0342
Refactor
felixhabib May 22, 2024
0c3d967
Remove more unecessary testids
felixhabib May 22, 2024
ef010f3
Refactor
felixhabib May 22, 2024
ea02d95
Changeset
felixhabib May 22, 2024
a176e49
Refactor wait logic in `assertCodePaneLineCount`
felixhabib May 22, 2024
9e812a9
Refactor `jumpToLine` function
felixhabib May 22, 2024
03c38a4
Remove 'force' on width selection cypress test
felixhabib May 22, 2024
f8ae3b1
Update changeset
felixhabib May 22, 2024
11583af
Format
felixhabib May 22, 2024
c66638c
Update aria-label
felixhabib May 22, 2024
92a0039
Fix centering of settings panel and toolbar icons (#354)
askoufis May 22, 2024
d8f0b3d
Install "Cypress Testing Library" from react testing library
felixhabib May 17, 2024
edc4385
Add typescript to react testing library
felixhabib May 20, 2024
5a16ae9
Switch files to typescript
felixhabib May 20, 2024
8b2e897
Remove unnecessary testids and refactor
felixhabib May 22, 2024
84244ac
Refactor
felixhabib May 22, 2024
41d759c
Remove more unecessary testids
felixhabib May 22, 2024
0f520b5
Refactor
felixhabib May 22, 2024
fe83789
Changeset
felixhabib May 22, 2024
e6cacbc
Refactor wait logic in `assertCodePaneLineCount`
felixhabib May 22, 2024
dee2b38
Refactor `jumpToLine` function
felixhabib May 22, 2024
3627247
Remove 'force' on width selection cypress test
felixhabib May 22, 2024
a318f42
Update changeset
felixhabib May 22, 2024
fece77f
Format
felixhabib May 22, 2024
ddcf7dc
Update aria-label
felixhabib May 22, 2024
f2a29a9
Update eslint version and increase memory
felixhabib May 23, 2024
4c9b78b
Refactor assertFramesMatch function
felixhabib May 23, 2024
60f461a
Refactor
felixhabib May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strange-zoos-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'playroom': patch
---

Fix Playroom UI icon centering
5 changes: 5 additions & 0 deletions .changeset/swift-fans-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'playroom': patch
---

Remove `data-testid` attributes from UI elements
2 changes: 1 addition & 1 deletion cypress/e2e/editor.cy.js → cypress/e2e/editor.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Editor', () => {
});

it('autocompletes', () => {
typeCode('<F{enter} c{enter}={downarrow}{enter} />', { delay: 100 });
typeCode('<F{enter} c{enter}={downarrow}{enter} />', 100);
assertFirstFrameContains('Foo');
assertCodePaneContains('<Foo color="blue" />');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/keymaps.cy.js → cypress/e2e/keymaps.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ describe('Keymaps', () => {
});

it('should jump to line and column number correctly', () => {
jumpToLine('6:10');
jumpToLine(6, 10);
typeCode('a');

assertCodePaneContains(dedent`
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions cypress/e2e/snippets.cy.js → cypress/e2e/snippets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
filterSnippets,
toggleSnippets,
assertSnippetCount,
assertSnippetsListIsVisible,
assertSnippetsSearchFieldIsVisible,
mouseOverSnippet,
loadPlayroom,
} from '../support/utils';
Expand All @@ -23,7 +23,7 @@ describe('Snippets', () => {
it('driven with mouse', () => {
// Open and format for insertion point
toggleSnippets();
assertSnippetsListIsVisible();
assertSnippetsSearchFieldIsVisible();
assertCodePaneLineCount(8);

// Browse snippetlist
Expand Down Expand Up @@ -69,12 +69,12 @@ describe('Snippets', () => {
it('driven with keyboard', () => {
// Open and format for insertion point
typeCode(`${isMac() ? '{cmd}' : '{ctrl}'}k`);
assertSnippetsListIsVisible();
assertSnippetsSearchFieldIsVisible();
assertCodePaneLineCount(8);
filterSnippets('{esc}');
assertCodePaneLineCount(1, { wait: 500 });
assertCodePaneLineCount(1, true);
typeCode(`${isMac() ? '{cmd}' : '{ctrl}'}k`);
assertSnippetsListIsVisible();
assertSnippetsSearchFieldIsVisible();
assertCodePaneLineCount(8);

// Browse snippetlist
Expand All @@ -89,7 +89,7 @@ describe('Snippets', () => {
// Close without persisting
filterSnippets('{esc}');
assertCodePaneContains('<div>Initial <span>code</span></div>');
assertCodePaneLineCount(1, { wait: 500 });
assertCodePaneLineCount(1, true);

// Re-open and persist
typeCode(`${isMac() ? '{cmd}' : '{ctrl}'}k`);
Expand Down
9 changes: 5 additions & 4 deletions cypress/e2e/toolbar.cy.js → cypress/e2e/toolbar.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
assertFramesMatch,
selectWidthPreferenceByIndex,
assertPreviewContains,
typeCode,
gotoPreview,
loadPlayroom,
selectWidthPreference,
} from '../support/utils';

describe('Toolbar', () => {
Expand All @@ -13,11 +13,11 @@ describe('Toolbar', () => {
});

it('filter widths', () => {
const frames = ['320px', '375px', '768px', '1024px'];
const frames = [320, 375, 768, 1024];
const widthIndexToSelect = 1;

assertFramesMatch(frames);
selectWidthPreferenceByIndex(widthIndexToSelect);
selectWidthPreference(frames[widthIndexToSelect]);
assertFramesMatch([frames[widthIndexToSelect]]);
});

Expand Down Expand Up @@ -45,8 +45,9 @@ describe('Toolbar', () => {
}
});
})
.get('[data-testid="copyToClipboard"]')
.findByRole('button', { name: /Copy Playroom link/i })
.click();

cy.then(() => expect(copySpy).to.have.been.called);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('URL handling', () => {
'http://localhost:9000/#?code=N4Ig7glgJgLgFgZxALgNoGYDsBWANJgNgA4BdAXyA'
);

assertFramesMatch(['375px', '768px']);
assertFramesMatch([375, 768]);
});
});

Expand All @@ -40,10 +40,10 @@ describe('URL handling', () => {
);

assertFramesMatch([
'themeOne – 375px',
'themeTwo – 375px',
'themeOne – 768px',
'themeTwo – 768px',
['themeOne', 375],
['themeTwo', 375],
['themeOne', 768],
['themeTwo', 768],
]);
});
});
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import '@testing-library/cypress/add-commands';

Cypress.Commands.add(
'getFromPreviewFrame',
{ prevSubject: 'element' },
Expand Down
Loading