Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 9a90447

Browse files
authored
Merge pull request #200 from City-of-Helsinki/TILA-1217
TILA-1217 move queries requiring auth to client
2 parents fc01703 + 77cf38a commit 9a90447

19 files changed

Lines changed: 1408 additions & 1629 deletions

File tree

tilavaraus.graphql

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,15 +1363,15 @@ input ReservationUnitCreateMutationInput {
13631363
Authentication required for reserving this reservation unit. Possible values are WEAK, STRONG.
13641364
"""
13651365
authentication: String
1366-
descriptionFi: String
1367-
descriptionEn: String
1368-
descriptionSv: String
13691366
nameFi: String
13701367
nameEn: String
13711368
nameSv: String
13721369
termsOfUseFi: String
13731370
termsOfUseEn: String
13741371
termsOfUseSv: String
1372+
descriptionFi: String
1373+
descriptionEn: String
1374+
descriptionSv: String
13751375
additionalInstructionsFi: String
13761376
additionalInstructionsEn: String
13771377
additionalInstructionsSv: String
@@ -1467,15 +1467,15 @@ type ReservationUnitCreateMutationPayload {
14671467
Authentication required for reserving this reservation unit. Possible values are WEAK, STRONG.
14681468
"""
14691469
authentication: String
1470-
descriptionFi: String
1471-
descriptionEn: String
1472-
descriptionSv: String
14731470
nameFi: String
14741471
nameEn: String
14751472
nameSv: String
14761473
termsOfUseFi: String
14771474
termsOfUseEn: String
14781475
termsOfUseSv: String
1476+
descriptionFi: String
1477+
descriptionEn: String
1478+
descriptionSv: String
14791479
additionalInstructionsFi: String
14801480
additionalInstructionsEn: String
14811481
additionalInstructionsSv: String
@@ -1832,15 +1832,15 @@ input ReservationUnitUpdateMutationInput {
18321832
Authentication required for reserving this reservation unit. Possible values are WEAK, STRONG.
18331833
"""
18341834
authentication: String
1835-
descriptionFi: String
1836-
descriptionEn: String
1837-
descriptionSv: String
18381835
nameFi: String
18391836
nameEn: String
18401837
nameSv: String
18411838
termsOfUseFi: String
18421839
termsOfUseEn: String
18431840
termsOfUseSv: String
1841+
descriptionFi: String
1842+
descriptionEn: String
1843+
descriptionSv: String
18441844
additionalInstructionsFi: String
18451845
additionalInstructionsEn: String
18461846
additionalInstructionsSv: String
@@ -1936,15 +1936,15 @@ type ReservationUnitUpdateMutationPayload {
19361936
Authentication required for reserving this reservation unit. Possible values are WEAK, STRONG.
19371937
"""
19381938
authentication: String
1939-
descriptionFi: String
1940-
descriptionEn: String
1941-
descriptionSv: String
19421939
nameFi: String
19431940
nameEn: String
19441941
nameSv: String
19451942
termsOfUseFi: String
19461943
termsOfUseEn: String
19471944
termsOfUseSv: String
1945+
descriptionFi: String
1946+
descriptionEn: String
1947+
descriptionSv: String
19481948
additionalInstructionsFi: String
19491949
additionalInstructionsEn: String
19501950
additionalInstructionsSv: String
@@ -2105,12 +2105,12 @@ input ResourceCreateMutationInput {
21052105
"""
21062106
bufferTimeAfter: Int
21072107
isDraft: Boolean
2108-
descriptionFi: String
2109-
descriptionEn: String
2110-
descriptionSv: String
21112108
nameFi: String
21122109
nameEn: String
21132110
nameSv: String
2111+
descriptionFi: String
2112+
descriptionEn: String
2113+
descriptionSv: String
21142114
clientMutationId: String
21152115
}
21162116

@@ -2133,12 +2133,12 @@ type ResourceCreateMutationPayload {
21332133
"""
21342134
bufferTimeAfter: Int
21352135
isDraft: Boolean
2136-
descriptionFi: String
2137-
descriptionEn: String
2138-
descriptionSv: String
21392136
nameFi: String
21402137
nameEn: String
21412138
nameSv: String
2139+
descriptionFi: String
2140+
descriptionEn: String
2141+
descriptionSv: String
21422142

21432143
"""May contain more than one error for same field."""
21442144
errors: [ErrorType]
@@ -2221,12 +2221,12 @@ input ResourceUpdateMutationInput {
22212221
"""
22222222
bufferTimeAfter: Int
22232223
isDraft: Boolean
2224-
descriptionFi: String
2225-
descriptionEn: String
2226-
descriptionSv: String
22272224
nameFi: String
22282225
nameEn: String
22292226
nameSv: String
2227+
descriptionFi: String
2228+
descriptionEn: String
2229+
descriptionSv: String
22302230
clientMutationId: String
22312231
}
22322232

@@ -2249,12 +2249,12 @@ type ResourceUpdateMutationPayload {
22492249
"""
22502250
bufferTimeAfter: Int
22512251
isDraft: Boolean
2252-
descriptionFi: String
2253-
descriptionEn: String
2254-
descriptionSv: String
22552252
nameFi: String
22562253
nameEn: String
22572254
nameSv: String
2255+
descriptionFi: String
2256+
descriptionEn: String
2257+
descriptionSv: String
22582258

22592259
"""May contain more than one error for same field."""
22602260
errors: [ErrorType]
@@ -2603,15 +2603,15 @@ input UnitUpdateMutationInput {
26032603
webPage: String
26042604
email: String
26052605
phone: String
2606-
descriptionFi: String
2607-
descriptionEn: String
2608-
descriptionSv: String
26092606
nameFi: String
26102607
nameEn: String
26112608
nameSv: String
26122609
shortDescriptionFi: String
26132610
shortDescriptionEn: String
26142611
shortDescriptionSv: String
2612+
descriptionFi: String
2613+
descriptionEn: String
2614+
descriptionSv: String
26152615
clientMutationId: String
26162616
}
26172617

@@ -2621,15 +2621,15 @@ type UnitUpdateMutationPayload {
26212621
webPage: String
26222622
email: String
26232623
phone: String
2624-
descriptionFi: String
2625-
descriptionEn: String
2626-
descriptionSv: String
26272624
nameFi: String
26282625
nameEn: String
26292626
nameSv: String
26302627
shortDescriptionFi: String
26312628
shortDescriptionEn: String
26322629
shortDescriptionSv: String
2630+
descriptionFi: String
2631+
descriptionEn: String
2632+
descriptionSv: String
26332633

26342634
"""May contain more than one error for same field."""
26352635
errors: [ErrorType]

ui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ yarn-debug.log*
2525
yarn-error.log*
2626

2727
# local env files
28+
.env
2829
.env.local
2930
.env.development.local
3031
.env.test.local

ui/components/common/Navigation.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { authEnabled, isBrowser } from "../../modules/const";
99
import { breakpoint } from "../../modules/style";
1010
import { UserProfile } from "../../modules/types";
1111
import RequireAuthentication from "./RequireAuthentication";
12+
import { clearApiAccessToken } from "../../modules/auth/util";
1213

1314
interface LanguageOption {
1415
label: string;
@@ -180,7 +181,15 @@ const NavigationWithProfileAndLogout = (): JSX.Element => {
180181
render={(props: {
181182
profile: UserProfile | null;
182183
logout: (() => void) | undefined;
183-
}) => <Navigation profile={props.profile} logout={props.logout} />}
184+
}) => (
185+
<Navigation
186+
profile={props.profile}
187+
logout={() => {
188+
clearApiAccessToken();
189+
props.logout();
190+
}}
191+
/>
192+
)}
184193
/>
185194
);
186195
};

ui/components/common/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export const HorisontalRule = styled.div`
4747
margin-top: var(--spacing-layout-m);
4848
`;
4949

50-
export const CenterSpinner = styled(LoadingSpinner)`
50+
export const CenterSpinner = styled(LoadingSpinner).attrs({
51+
"data-testid": "loading-spinner",
52+
})`
5153
margin: 0 auto var(--spacing-2-xl) auto;
5254
`;
5355

ui/components/reservation/ReservationCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ const ReservationCard = ({ reservation, type }: Props): JSX.Element => {
300300
onClick={() => router.push(link)}
301301
data-testid="reservation-card__button--goto-reservation"
302302
>
303-
{t("reservationUnitCard:seeMore")}
303+
{t("reservationList:seeMore")}
304304
</MediumButton>
305305
</Actions>
306306
</MainContent>

ui/cypress/integration/reservation-unit-single.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,13 @@ describe("Tilavaraus ui reservation unit page (single)", () => {
466466

467467
describe("with reservation quota notification", () => {
468468
it("should display apt notification if quota is set and full", () => {
469+
cy.window().then(() => {
470+
sessionStorage.setItem(
471+
`oidc.apiToken.${Cypress.env("API_SCOPE")}`,
472+
"foobar"
473+
);
474+
});
475+
469476
cy.visit("/reservation-unit/single/901");
470477

471478
gotoCalendarButton().should("exist");
@@ -480,9 +487,20 @@ describe("Tilavaraus ui reservation unit page (single)", () => {
480487
"match",
481488
/^Sinulla on jo \d+ varausta tähän tilaan. Et voi tehdä uusia varauksia.$/
482489
);
490+
491+
cy.window().then(() => {
492+
sessionStorage.removeItem(`oidc.apiToken.${Cypress.env("API_SCOPE")}`);
493+
});
483494
});
484495

485496
it("should display apt notification if quota is set but not full", () => {
497+
cy.window().then(() => {
498+
sessionStorage.setItem(
499+
`oidc.apiToken.${Cypress.env("API_SCOPE")}`,
500+
"foobar"
501+
);
502+
});
503+
486504
cy.visit("/reservation-unit/single/902");
487505

488506
gotoCalendarButton().should("exist");
@@ -492,6 +510,10 @@ describe("Tilavaraus ui reservation unit page (single)", () => {
492510
reservationQuotaNotification()
493511
.invoke("text")
494512
.should("match", /^Sinulla on jo \d+\/\d+ varausta tähän tilaan.$/);
513+
514+
cy.window().then(() => {
515+
sessionStorage.removeItem(`oidc.apiToken.${Cypress.env("API_SCOPE")}`);
516+
});
495517
});
496518
});
497519

ui/cypress/integration/reservations.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import {
1010
cancelButton,
1111
detailButton,
12+
loader,
1213
redoReservationButton,
1314
reservationCards,
1415
tab,
@@ -27,20 +28,26 @@ import {
2728

2829
describe("Tilavaraus user reservations", () => {
2930
beforeEach(() => {
31+
cy.window().then(() => {
32+
sessionStorage.setItem(
33+
`oidc.apiToken.${Cypress.env("API_SCOPE")}`,
34+
"foobar"
35+
);
36+
});
37+
3038
cy.visit("/reservations");
3139
});
3240

41+
afterEach(() => {
42+
cy.window().then(() => {
43+
sessionStorage.removeItem(`oidc.apiToken.${Cypress.env("API_SCOPE")}`);
44+
});
45+
});
46+
3347
it("should list proper items with correct button states and link to reservation unit", () => {
34-
tab(1)
35-
.invoke("text")
36-
.then((text) => {
37-
expect(text).to.eq("Tulevat varaukset (5)");
38-
});
39-
tab(2)
40-
.invoke("text")
41-
.then((text) => {
42-
expect(text).to.eq("Menneet varaukset (2)");
43-
});
48+
loader().should("exist");
49+
50+
loader().should("not.exist");
4451

4552
reservationCards().should("have.length", 5);
4653
timeStrip()
@@ -53,7 +60,18 @@ describe("Tilavaraus user reservations", () => {
5360
}
5461
});
5562

56-
cancelButton().should("have.length", 1);
63+
tab(1)
64+
.invoke("text")
65+
.then((text) => {
66+
expect(text).to.eq("Tulevat varaukset (5)");
67+
});
68+
tab(2)
69+
.invoke("text")
70+
.then((text) => {
71+
expect(text).to.eq("Menneet varaukset (2)");
72+
});
73+
74+
cancelButton().should("have.length", 2);
5775

5876
reservationCards()
5977
.eq(0)

ui/cypress/model/reservation-list.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ export function timeStrip(): Cypress.Chainable<JQuery<HTMLElement>> {
3131
export function ticket(): Cypress.Chainable<JQuery<HTMLElement>> {
3232
return cy.get("[data-testid='reservation__ticket--container']");
3333
}
34+
35+
export function loader(): Cypress.Chainable<JQuery<HTMLElement>> {
36+
return cy.get("[data-testid='loading-spinner']");
37+
}

ui/cypress/plugins/index.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
/// <reference types="cypress" />
2+
3+
const { parseConfigFileTextToJson } = require("typescript");
4+
require("dotenv").config();
5+
26
// ***********************************************************
37
// This example plugins/index.js can be used to load plugins
48
//
@@ -19,20 +23,20 @@
1923
module.exports = (on, config) => {
2024
// `on` is used to hook into various events Cypress emits
2125
// `config` is the resolved Cypress config
22-
23-
on('task', {
26+
on("task", {
2427
log(message) {
25-
console.log(message)
28+
console.log(message);
2629

2730
return null;
2831
},
2932
table(message) {
30-
console.table(message)
33+
console.table(message);
3134

3235
return null;
33-
}
34-
})
35-
36-
}
36+
},
37+
});
3738

39+
config.env.API_SCOPE = process.env.NEXT_PUBLIC_TILAVARAUS_API_SCOPE;
3840

41+
return config;
42+
};

0 commit comments

Comments
 (0)