-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Two more Test Suites for Hooks and Selenium GUI Testing
- Loading branch information
1 parent
d20e091
commit 5c5a3b1
Showing
7 changed files
with
282 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ | ||
"id": "5961be57-55dc-4f00-854f-8c09b6e6875f", | ||
"version": "2.0", | ||
"name": "PhotoGallery", | ||
"url": "http://localhost:3000", | ||
"tests": [{ | ||
"id": "c196feb8-a3a1-4b30-aa00-896b11c5977f", | ||
"name": "Logging in and uploading image", | ||
"commands": [{ | ||
"id": "b4d664ef-2971-4428-90da-822bbd627110", | ||
"comment": "", | ||
"command": "open", | ||
"target": "/login", | ||
"targets": [], | ||
"value": "" | ||
}, { | ||
"id": "df90103a-093c-4981-8b5f-6747e9fdb05b", | ||
"comment": "", | ||
"command": "setWindowSize", | ||
"target": "954x693", | ||
"targets": [], | ||
"value": "" | ||
}, { | ||
"id": "82335a41-e785-4a5d-a3bc-700cd57c70e9", | ||
"comment": "", | ||
"command": "click", | ||
"target": "id=username", | ||
"targets": [ | ||
["id=username", "id"], | ||
["css=#username", "css:finder"], | ||
["xpath=//input[@id='username']", "xpath:attributes"], | ||
["xpath=//div[@id='root']/div/div/div/div/div/form/div[2]/input", "xpath:idRelative"], | ||
["xpath=//input", "xpath:position"] | ||
], | ||
"value": "" | ||
}, { | ||
"id": "cd74eff1-dc9c-48b5-962c-9a5630614d83", | ||
"comment": "", | ||
"command": "type", | ||
"target": "id=username", | ||
"targets": [ | ||
["id=username", "id"], | ||
["css=#username", "css:finder"], | ||
["xpath=//input[@id='username']", "xpath:attributes"], | ||
["xpath=//div[@id='root']/div/div/div/div/div/form/div[2]/input", "xpath:idRelative"], | ||
["xpath=//input", "xpath:position"] | ||
], | ||
"value": "AshIsHere" | ||
}, { | ||
"id": "58118ef3-5918-40fd-9d56-6da599f7ecc2", | ||
"comment": "", | ||
"command": "click", | ||
"target": "id=password", | ||
"targets": [ | ||
["id=password", "id"], | ||
["css=#password", "css:finder"], | ||
["xpath=//input[@id='password']", "xpath:attributes"], | ||
["xpath=//div[@id='root']/div/div/div/div/div/form/div[3]/input", "xpath:idRelative"], | ||
["xpath=//div[3]/input", "xpath:position"] | ||
], | ||
"value": "" | ||
}, { | ||
"id": "1a9597cc-3260-4407-b90a-e27ff5722a1c", | ||
"comment": "", | ||
"command": "type", | ||
"target": "id=password", | ||
"targets": [ | ||
["id=password", "id"], | ||
["css=#password", "css:finder"], | ||
["xpath=//input[@id='password']", "xpath:attributes"], | ||
["xpath=//div[@id='root']/div/div/div/div/div/form/div[3]/input", "xpath:idRelative"], | ||
["xpath=//div[3]/input", "xpath:position"] | ||
], | ||
"value": "Ash@12345" | ||
}, { | ||
"id": "91def1cf-f42a-4738-9fac-e3f513dbdba2", | ||
"comment": "", | ||
"command": "click", | ||
"target": "css=.css-1ikp3wz", | ||
"targets": [ | ||
["css=.css-1ikp3wz", "css:finder"], | ||
["xpath=//button[@type='submit']", "xpath:attributes"], | ||
["xpath=//div[@id='root']/div/div/div/div/div/form/button", "xpath:idRelative"], | ||
["xpath=//button", "xpath:position"], | ||
["xpath=//button[contains(.,'Log In')]", "xpath:innerText"] | ||
], | ||
"value": "" | ||
}, { | ||
"id": "77e9dfc5-89d9-47dd-94ca-dbef5ccaa556", | ||
"comment": "", | ||
"command": "click", | ||
"target": "css=.css-6r4ark", | ||
"targets": [ | ||
["css=.css-6r4ark", "css:finder"], | ||
["xpath=//div[@id='root']/div/div/div[2]/div/div/div/p", "xpath:idRelative"], | ||
["xpath=//div[2]/div/div/div/p", "xpath:position"], | ||
["xpath=//p[contains(.,'View Type:')]", "xpath:innerText"] | ||
], | ||
"value": "" | ||
}, { | ||
"id": "ef3a29f4-4db6-4565-a45c-2fba0960c730", | ||
"comment": "", | ||
"command": "click", | ||
"target": "id=field-:r9:", | ||
"targets": [ | ||
["id=field-:r9:", "id"], | ||
["css=#field-\\3Ar9\\3A", "css:finder"], | ||
["xpath=//input[@id='field-:r9:']", "xpath:attributes"], | ||
["xpath=//div[@id='root']/div/div/div[2]/div/div/form/div/input", "xpath:idRelative"], | ||
["xpath=//input", "xpath:position"] | ||
], | ||
"value": "" | ||
}] | ||
}], | ||
"suites": [{ | ||
"id": "1fb9c823-da16-48d5-8c26-cccc61116a03", | ||
"name": "Default Suite", | ||
"persistSession": false, | ||
"parallel": false, | ||
"timeout": 300, | ||
"tests": ["c196feb8-a3a1-4b30-aa00-896b11c5977f"] | ||
}], | ||
"urls": ["http://localhost:3000/"], | ||
"plugins": [] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import renderer from 'react-test-renderer'; | ||
import React from 'react'; | ||
import { render, fireEvent, waitFor } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import '@testing-library/jest-dom'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { configure } from '@testing-library/react'; | ||
|
||
// automatically unmount and cleanup DOM after the test is finished. | ||
configure({ autoCleanup: true }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
view_generator_serv/src/context/__test__/AuthContext.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { AuthContextProvider, AuthContext } from '../AuthContext'; | ||
import { useContext } from 'react'; | ||
|
||
const TestingComponent = () => { | ||
const { user } = useContext(AuthContext); | ||
return ( | ||
<> | ||
<p data-testid="user-name">{user?.name}</p> | ||
</> | ||
); | ||
}; | ||
|
||
describe('<AuthContextProvider />', () => { | ||
let user; | ||
|
||
beforeAll(() => { | ||
user = { | ||
name: 'John Doe', | ||
}; | ||
}); | ||
|
||
beforeEach(() => { | ||
// Mock localStorage | ||
Storage.prototype.getItem = jest.fn(() => JSON.stringify(user)); | ||
|
||
render( | ||
<AuthContextProvider> | ||
<TestingComponent /> | ||
</AuthContextProvider>, | ||
); | ||
}); | ||
|
||
it('provides expected AuthContext to child elements', () => { | ||
const userName = screen.getByTestId('user-name'); | ||
expect(userName.textContent).toEqual(user.name); | ||
}); | ||
}); |
Oops, something went wrong.