Skip to content

Commit 1dc77b1

Browse files
author
Umer Farooq
committed
develop - fix - added changelog - v6
1 parent 645b8e4 commit 1dc77b1

21 files changed

Lines changed: 2199 additions & 35 deletions

File tree

.eslintrc.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,10 @@
88
"ecmaVersion": 2023,
99
"sourceType": "module",
1010
"ecmaFeatures": {
11-
"jsx": true
11+
"jsx": true,
12+
"tsx": true
1213
}
1314
},
14-
"overrides": [
15-
{
16-
"files": ["*.tsx"],
17-
"parserOptions": {
18-
"project": "./tsconfig.json"
19-
}
20-
}
21-
],
2215
"plugins": ["@typescript-eslint", "prettier"],
2316
"rules": {
2417
// Custom rules for your project

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ yarn-error.log*
3434
# typescript
3535
*.tsbuildinfo
3636
next-env.d.ts
37+
38+
*storybook.log

.husky/commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ts-node ./utils/methods/git-hooks/git-commit-validator.ts
1+
ts-node ./lib/utils/methods/git-hooks/git-commit-validator.ts

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"editor.defaultFormatter": "esbenp.prettier-vscode",
33
"editor.formatOnSave": true,
44
"editor.codeActionsOnSave": {
5-
"source.fixAll.ts": true,
6-
"source.organizeImports": true
5+
"source.fixAll.ts": "explicit",
6+
"source.organizeImports": "explicit"
77
}
88
}

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Changelog
2+
3+
## 10.1.0
4+
5+
- Update to PrimeReact 10.2.1
6+
7+
## 10.0.0
8+
9+
- Upgrade to Next 13.4.8
10+
- Migrate to Next App Roter
11+
- Migrate to PrimeReactContext
12+
- Update to PrimeReact 9.6.2
13+
- Update other dependencies
14+
15+
## 9.1.2
16+
17+
- Refactored project files
18+
19+
## 9.1.1
20+
21+
- Fixed hydration warnings
22+
23+
## 9.1.0
24+
25+
- Add typescript support
26+
27+
## 9.0.0
28+
29+
- Upgrade PrimeReact to v9
30+
- Upgrade to PrimeReact 9.2.2
31+
- Upgrade to PrimeFlex 3.3.0
32+
- Upgrade to Next 13.2.3
33+
- Update other dependencies
34+
35+
## 8.1.0
36+
37+
- Migrate CRA to NextJS

cypress.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:3000',
6+
// `cypress/plugins/index.js` is required to load your plugins
7+
},
8+
retries: 3,
9+
video: false,
10+
videoCompression: 32,
11+
videosFolder: 'cypress/videos',
12+
});
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/// <reference types="cypress" />
2+
3+
// Welcome to Cypress!
4+
//
5+
// This spec file contains a variety of sample tests
6+
// for a todo list app that are designed to demonstrate
7+
// the power of writing tests in Cypress.
8+
//
9+
// To learn more about how Cypress works and
10+
// what makes it such an awesome testing tool,
11+
// please read our getting started guide:
12+
// https://on.cypress.io/introduction-to-cypress
13+
14+
describe('example to-do app', () => {
15+
beforeEach(() => {
16+
// Cypress starts out with a blank slate for each test
17+
// so we must tell it to visit our website with the `cy.visit()` command.
18+
// Since we want to visit the same URL at the start of all our tests,
19+
// we include it in our beforeEach function so that it runs before each test
20+
cy.visit('https://example.cypress.io/todo')
21+
})
22+
23+
it('displays two todo items by default', () => {
24+
// We use the `cy.get()` command to get all elements that match the selector.
25+
// Then, we use `should` to assert that there are two matched items,
26+
// which are the two default items.
27+
cy.get('.todo-list li').should('have.length', 2)
28+
29+
// We can go even further and check that the default todos each contain
30+
// the correct text. We use the `first` and `last` functions
31+
// to get just the first and last matched elements individually,
32+
// and then perform an assertion with `should`.
33+
cy.get('.todo-list li').first().should('have.text', 'Pay electric bill')
34+
cy.get('.todo-list li').last().should('have.text', 'Walk the dog')
35+
})
36+
37+
it('can add new todo items', () => {
38+
// We'll store our item text in a variable so we can reuse it
39+
const newItem = 'Feed the cat'
40+
41+
// Let's get the input element and use the `type` command to
42+
// input our new list item. After typing the content of our item,
43+
// we need to type the enter key as well in order to submit the input.
44+
// This input has a data-test attribute so we'll use that to select the
45+
// element in accordance with best practices:
46+
// https://on.cypress.io/selecting-elements
47+
cy.get('[data-test=new-todo]').type(`${newItem}{enter}`)
48+
49+
// Now that we've typed our new item, let's check that it actually was added to the list.
50+
// Since it's the newest item, it should exist as the last element in the list.
51+
// In addition, with the two default items, we should have a total of 3 elements in the list.
52+
// Since assertions yield the element that was asserted on,
53+
// we can chain both of these assertions together into a single statement.
54+
cy.get('.todo-list li')
55+
.should('have.length', 3)
56+
.last()
57+
.should('have.text', newItem)
58+
})
59+
60+
it('can check off an item as completed', () => {
61+
// In addition to using the `get` command to get an element by selector,
62+
// we can also use the `contains` command to get an element by its contents.
63+
// However, this will yield the <label>, which is lowest-level element that contains the text.
64+
// In order to check the item, we'll find the <input> element for this <label>
65+
// by traversing up the dom to the parent element. From there, we can `find`
66+
// the child checkbox <input> element and use the `check` command to check it.
67+
cy.contains('Pay electric bill')
68+
.parent()
69+
.find('input[type=checkbox]')
70+
.check()
71+
72+
// Now that we've checked the button, we can go ahead and make sure
73+
// that the list element is now marked as completed.
74+
// Again we'll use `contains` to find the <label> element and then use the `parents` command
75+
// to traverse multiple levels up the dom until we find the corresponding <li> element.
76+
// Once we get that element, we can assert that it has the completed class.
77+
cy.contains('Pay electric bill')
78+
.parents('li')
79+
.should('have.class', 'completed')
80+
})
81+
82+
context('with a checked task', () => {
83+
beforeEach(() => {
84+
// We'll take the command we used above to check off an element
85+
// Since we want to perform multiple tests that start with checking
86+
// one element, we put it in the beforeEach hook
87+
// so that it runs at the start of every test.
88+
cy.contains('Pay electric bill')
89+
.parent()
90+
.find('input[type=checkbox]')
91+
.check()
92+
})
93+
94+
it('can filter for uncompleted tasks', () => {
95+
// We'll click on the "active" button in order to
96+
// display only incomplete items
97+
cy.contains('Active').click()
98+
99+
// After filtering, we can assert that there is only the one
100+
// incomplete item in the list.
101+
cy.get('.todo-list li')
102+
.should('have.length', 1)
103+
.first()
104+
.should('have.text', 'Walk the dog')
105+
106+
// For good measure, let's also assert that the task we checked off
107+
// does not exist on the page.
108+
cy.contains('Pay electric bill').should('not.exist')
109+
})
110+
111+
it('can filter for completed tasks', () => {
112+
// We can perform similar steps as the test above to ensure
113+
// that only completed tasks are shown
114+
cy.contains('Completed').click()
115+
116+
cy.get('.todo-list li')
117+
.should('have.length', 1)
118+
.first()
119+
.should('have.text', 'Pay electric bill')
120+
121+
cy.contains('Walk the dog').should('not.exist')
122+
})
123+
124+
it('can delete all completed tasks', () => {
125+
// First, let's click the "Clear completed" button
126+
// `contains` is actually serving two purposes here.
127+
// First, it's ensuring that the button exists within the dom.
128+
// This button only appears when at least one task is checked
129+
// so this command is implicitly verifying that it does exist.
130+
// Second, it selects the button so we can click it.
131+
cy.contains('Clear completed').click()
132+
133+
// Then we can make sure that there is only one element
134+
// in the list and our element does not exist
135+
cy.get('.todo-list li')
136+
.should('have.length', 1)
137+
.should('not.have.text', 'Pay electric bill')
138+
139+
// Finally, make sure that the clear button no longer exists.
140+
cy.contains('Clear completed').should('not.exist')
141+
})
142+
})
143+
})

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/support/commands.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/// <reference types="cypress" />
2+
3+
export {};
4+
5+
// ***********************************************
6+
// This example commands.ts shows you how to
7+
// create various custom commands and overwrite
8+
// existing commands.
9+
//
10+
// For more comprehensive examples of custom
11+
// commands please read more here:
12+
// https://on.cypress.io/custom-commands
13+
// ***********************************************
14+
//
15+
//
16+
// -- This is a parent command --
17+
// Cypress.Commands.add('login', (email, password) => { ... })
18+
//
19+
//
20+
// -- This is a child command --
21+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This is a dual command --
25+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
26+
//
27+
//
28+
// -- This will overwrite an existing command --
29+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
30+
//
31+
/* declare global {
32+
namespace Cypress {
33+
interface Chainable {
34+
login(email: string, password: string): Chainable<void>;
35+
drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>;
36+
dismiss(
37+
subject: string,
38+
options?: Partial<TypeOptions>
39+
): Chainable<Element>;
40+
visit(
41+
originalFn: CommandOriginalFn,
42+
url: string,
43+
options: Partial<VisitOptions>
44+
): Chainable<Element>;
45+
}
46+
}
47+
}
48+
*/

cypress/support/e2e.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/e2e.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

0 commit comments

Comments
 (0)