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

Validate company application page #309

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
280f5bf
Added validation of company application route and unverified state
FranciscoCardoso913 Feb 4, 2023
6284d08
Implemented validation page design
FranciscoCardoso913 Feb 6, 2023
aa0ac75
Added appropriate error messages for application
FranciscoCardoso913 Feb 11, 2023
a246730
Changed hyperlinks and redirect to Link component and changed text to…
FranciscoCardoso913 May 9, 2023
80cfaf3
Solved redirected to home page issue and refactored validation page code
FranciscoCardoso913 Jun 20, 2023
b328a12
Added a waring to MyOffers page and to the CreateOffer page when comp…
FranciscoCardoso913 Jun 20, 2023
502ae8f
Added a waring to MyOffers page and to the CreateOffer page when comp…
FranciscoCardoso913 Jun 20, 2023
61dafc3
Merge remote-tracking branch 'origin/validate-company-application-Pag…
FranciscoCardoso913 Jun 20, 2023
df27afe
Conditionally render the alert for non yet approved companies and cha…
dsantosferreira Jun 27, 2023
02072ab
Rewriting the website messages to match the current flow
FranciscoCardoso913 Jul 4, 2023
52dbd3f
Rewriting the website messages to match the current flow
FranciscoCardoso913 Jul 4, 2023
a327f00
Fixing failing tests
FranciscoCardoso913 Aug 8, 2023
4c33b8d
Created test to check if approve and reject buttons are not rendered …
dsantosferreira Aug 18, 2023
3a5a721
Tests for validation page
FranciscoCardoso913 Aug 19, 2023
4f85e5f
Tests for validation page
FranciscoCardoso913 Aug 19, 2023
95794d0
Tests for the alerts components in the company offer management page …
FranciscoCardoso913 Aug 19, 2023
4198681
Making tests for the validate application and the fetch company appli…
FranciscoCardoso913 Aug 29, 2023
decd155
Add extra error message to validation page, fixed: can enter create o…
FranciscoCardoso913 Sep 16, 2023
23032fa
Merge branch 'develop' into validate-company-application-Page
FranciscoCardoso913 Sep 16, 2023
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
Prev Previous commit
Next Next commit
Fixing failing tests
FranciscoCardoso913 committed Aug 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a327f004c2951af92c7797655c0bf6e325bc2ce8
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ describe("Search URL Widget", () => {

const testString = "test-url";

global.window = Object.create(window);
// global.window = Object.create(window);
Object.defineProperty(window, "location", {
value: {
href: testString,
@@ -49,7 +49,7 @@ describe("Search URL Widget", () => {

const testString = "test-string";

global.window = Object.create(window);
//global.window = Object.create(window);
Object.defineProperty(window, "location", {
value: {
href: testString,
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ const generateApplications = (n, forceState) => {
for (let i = 0; i < n; i++) {
applications.push(generateApplication(
i,
forceState || STATES[i % 3]
forceState || STATES[(i) % 4]
));
}
return applications;
@@ -805,6 +805,8 @@ describe("Application Review Widget", () => {

it("Should reset filters", async () => {
const applications = generateApplications(5);
console.log("Hello");
console.log(applications);

fetch.mockResponse(JSON.stringify({ applications }));

@@ -820,13 +822,13 @@ describe("Application Review Widget", () => {

fireEvent.click(screen.getByLabelText("Filter list"));

fireEvent.change(screen.getByLabelText("Company Name"), { target: { value: "0" } });
fireEvent.change(screen.getByLabelText("Company Name"), { target: { value: "1" } });

fireEvent.change(screen.getByLabelText("Date From..."), { target: { value:
format(new Date(applications[0].submittedAt), "yyyy-MM-dd"),
format(new Date(applications[1].submittedAt), "yyyy-MM-dd"),
} });
fireEvent.change(screen.getByLabelText("Date To..."), { target: { value:
format(new Date(applications[0].submittedAt), "yyyy-MM-dd"),
format(new Date(applications[1].submittedAt), "yyyy-MM-dd"),
} });

await userEvent.click(screen.getByLabelText("State"));
@@ -837,7 +839,7 @@ describe("Application Review Widget", () => {

expect(screen.getAllByTestId("application-row")
.map((el) => el.querySelector("td:nth-child(2)").textContent)
).toStrictEqual([applications[0].companyName]);
).toStrictEqual([applications[1].companyName]);

fireEvent.click(screen.getByLabelText("Filter list"));

15 changes: 12 additions & 3 deletions src/utils/UndoableActionsHandlerProvider.js
Original file line number Diff line number Diff line change
@@ -86,16 +86,25 @@ const ActionNotification = connect(mapStateToProps, mapDispatchToProps)(BaseActi
const UndoableActionsHandlerProvider = ({ children }) => {
const [actions, setActions] = useState({});
const [closeLock, setCloseLock] = useState(false);
const initialBeforeUnloadEventListener = useRef();
const initialBeforeUnloadEventListener = useRef(window.onbeforeunload);

useEffect(() => {
if (Object.keys(actions).length && !closeLock) {
setCloseLock(true);
initialBeforeUnloadEventListener.current = window.onbeforeunload;
window.onbeforeunload = () => "Some changes might have not taken effect yet...";

Object.defineProperty(window, "onbeforeunload", {
value: () => "Some changes might have not taken effect yet...",
writable: true,
});

} else if (!Object.keys(actions).length && closeLock) {
setCloseLock(false);
window.onbeforeunload = initialBeforeUnloadEventListener.current;

Object.defineProperty(window, "onbeforeunload", {
value: initialBeforeUnloadEventListener.current,
writable: true,
});
}

}, [actions, closeLock]);