Skip to content

Commit 960a767

Browse files
committed
Naming convention changes for clarity & additional testing
- Tests cover functionality of query options - Clearing and user input of the code fields - Clicking on the HTML previews - Validating the query option selections change the descriptive content
1 parent 72eac23 commit 960a767

File tree

5 files changed

+46
-14
lines changed

5 files changed

+46
-14
lines changed

cypress/fixtures/userStubs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"html": {
33
"helloWorld": "<div data-testid='hello'>Hello World",
4-
"example": "<label for='username'>Username</label> <input id='username' name='username' placeholder='Enter Name' data-testid='uname-testid' title='enter your username' alt='enter your username' value='john-doe' type='text'/> <button name='signup' type='submit' data-testid='button-testid'>signup"
4+
"example": "<label for='username'>Username</label> <input id='username' name='username' placeholder='Enter Name' data-testid='uname-testid' title='enter your username' alt='enter your username' value='john-doe' type='text'/> <button name='signup' type='submit' data-testid='button-testid'>signup",
5+
"shortExample": "<button name='signup' type='submit' data-testid='button-testid'>signup"
56
},
67
"query": {
78
"helloWorld": "screen.getByTestId('hello')",
Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
describe('All Query Selections & Buttons Funtionality', () => {
22
beforeEach(() => {
3-
cy.seedAndVisit();
4-
5-
cy.fixture('userStubs.json').then((stub) =>
6-
cy.get('.CodeMirror textarea').first().type(stub.html.example, {
7-
force: true,
8-
}),
9-
);
10-
3+
cy.visitAndClear();
114
cy.fixture('userStubs.json').then((stub) =>
125
cy
136
.get('.CodeMirror textarea')
@@ -18,9 +11,47 @@ describe('All Query Selections & Buttons Funtionality', () => {
1811
);
1912
});
2013

21-
it('click on HTML preview "signup" button', () => {
14+
it('Click on HTML preview "signup" & query options "text", "testId", and "role"', () => {
15+
cy.fixture('userStubs.json').then((stub) =>
16+
cy.get('.CodeMirror textarea').first().type(stub.html.shortExample, {
17+
force: true,
18+
}),
19+
);
2220
cy.get('[data-testid=button-testid]').click();
23-
2421
cy.get('[data-cy=suggested-query]').should('contain', 'signup');
22+
23+
cy.get(':nth-child(2) > .field > .truncate').click();
24+
cy.get('p').should('contain', 'getByTestId');
25+
26+
cy.get('.grid > :nth-child(1) > :nth-child(5)').click();
27+
cy.get('p').should('contain', 'getByText');
28+
29+
cy.get('.grid > :nth-child(1) > :nth-child(2) > .truncate').click();
30+
cy.get('p').should('contain', 'great');
31+
});
32+
33+
it('Click on HTML preview input field & query options "labelText", "placeholderText", "displayValue", "altText" and "title"', () => {
34+
cy.fixture('userStubs.json').then((stub) =>
35+
cy.get('.CodeMirror textarea').first().type(stub.html.example, {
36+
force: true,
37+
}),
38+
);
39+
cy.get('[data-testid=uname-testid]').click();
40+
cy.get('[data-cy=suggested-query]').should('contain', 'textbox');
41+
42+
cy.get('.grid > :nth-child(1) > :nth-child(3) > .truncate').click();
43+
cy.get('p').should('contain', 'getByLabelText');
44+
45+
cy.get(':nth-child(4) > .truncate').click();
46+
cy.get('p').should('contain', 'getByPlaceholderText');
47+
48+
cy.get(':nth-child(6) > .truncate').click();
49+
cy.get('p').should('contain', 'getByDisplayValue');
50+
51+
cy.get('.space-y-8 > :nth-child(1) > :nth-child(2) > .truncate').click();
52+
cy.get('p').should('contain', 'getByAltText');
53+
54+
cy.get('.space-y-8 > :nth-child(1) > :nth-child(3) > .truncate').click();
55+
cy.get('p').should('contain', 'getByTitle');
2556
});
2657
});

cypress/integration/initApp.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
describe('App Initialization Smoke Test', () => {
22
beforeEach(() => {
3-
cy.seedAndVisit();
3+
cy.visitAndClear();
44

55
cy.fixture('userStubs.json').then((stub) =>
66
cy.get('.CodeMirror textarea').first().type(stub.html.helloWorld, {

cypress/support/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/// <reference types="cypress" />
2-
import './init-seed';
2+
import './init-clear';

cypress/support/init-seed.js renamed to cypress/support/init-clear.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Cypress.Commands.add('seedAndVisit', () => {
1+
Cypress.Commands.add('visitAndClear', () => {
22
cy.visit('/');
33
cy.get('.CodeMirror')
44
.first()

0 commit comments

Comments
 (0)