Skip to content

Commit

Permalink
fix(oidc-provider): add view property on pageContext level
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Feb 27, 2023
1 parent 829cd4e commit f04a30c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
Expand Up @@ -7,10 +7,7 @@ export interface ViteRenderContext<Data = Record<string, unknown>, Session = Rec
protocol: string;
method: string;
url: string;
urlOriginal: string;
secure: boolean;
headers: IncomingHttpHeaders;
session?: Session;
data: VitePageProps;
view: string;
}
Expand Up @@ -55,14 +55,11 @@ describe("ViteService", () => {

expect(result).toEqual("html");
expect(renderPage).toHaveBeenCalledWith({
view: "*",
pageProps: {
view: "*"
},
contextProps: {
data: {
view: "*"
},
view: "*",
headers: {
host: "host",
"x-header": "x-header"
Expand All @@ -73,8 +70,7 @@ describe("ViteService", () => {
secure: true,
session: {},
stateSnapshot: {state: "state"},
url: "/",
urlOriginal: "/"
url: "/"
},
url: "/",
urlOriginal: "/"
Expand All @@ -92,31 +88,29 @@ describe("ViteService", () => {
const result = await service.render("vue.vite", $ctx);

expect(result).toEqual(undefined);
expect(renderPage).toHaveBeenCalledWith({
pageProps: {
view: "vue"
},
contextProps: {
data: {
expect(renderPage).toHaveBeenCalledWith(
expect.objectContaining({
view: "vue",
pageProps: {
view: "vue"
},
headers: {
contextProps: {
headers: {
host: "host",
"x-header": "x-header"
},
host: "host",
"x-header": "x-header"
method: "GET",
protocol: "https",
secure: true,
session: {},
stateSnapshot: {state: "state"},
url: "/"
},
view: "vue",
host: "host",
method: "GET",
protocol: "https",
secure: true,
session: {},
stateSnapshot: {state: "state"},
url: "/",
urlOriginal: "/"
},
url: "/",
urlOriginal: "/"
});
})
);
expect($ctx.response.status).not.toHaveBeenCalled();
expect($ctx.response.setHeader).not.toHaveBeenCalled();
expect($ctx.response.body).not.toHaveBeenCalled();
Expand Down
Expand Up @@ -38,20 +38,18 @@ export class ViteService {
};

const contextProps: ViteRenderContext = {
view,
host: $ctx.request.host,
protocol: $ctx.request.protocol,
method: $ctx.request.method,
url: urlOriginal,
urlOriginal,
secure: $ctx.request.secure,
headers: $ctx.request.headers,
session: $ctx.request.session,
stateSnapshot: this.config.stateSnapshot && this.config.stateSnapshot(),
data: pageProps
stateSnapshot: this.config.stateSnapshot && this.config.stateSnapshot()
};

const pageContext = await renderPage({
view,
url: urlOriginal,
urlOriginal,
pageProps,
Expand Down

0 comments on commit f04a30c

Please sign in to comment.