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

[DFC-661]: Remove the Beta Banner from Strategic App view #2117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion src/components/common/layout/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@

{% block main %}
<div class="govuk-width-container {{ containerClasses }}">
{% if strategicAppChannel === true %}
{% else %}
{{ govukPhaseBanner({
tag: {
text: 'general.phaseBanner.tag' | translate
},
html: phaseBannerText
}) }}
{% endif %}
{% block beforeContent %}{% endblock %}
{% if languageToggleEnabled %}
{{ languageSelect({
Expand Down Expand Up @@ -163,4 +166,4 @@
}
}
</script>
{% endblock %}
{% endblock %}
69 changes: 69 additions & 0 deletions src/components/common/layout/tests/base-integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import request from "supertest";
import { describe } from "mocha";
import { expect } from "chai";
import * as cheerio from "cheerio";
import { sinon } from "../../../../../test/utils/test-utils";
import nock = require("nock");
import decache from "decache";
import { PATH_NAMES, CHANNEL } from "../../../../app.constants";

describe("Integration:: base page ", () => {
let app: any;

const setupApp = async (channel: string) => {
decache("../../../../app");
decache("../../../../middleware/session-middleware");
const sessionMiddleware = require("../../../../middleware/session-middleware");
sinon
.stub(sessionMiddleware, "validateSessionMiddleware")
.callsFake(function (req: any, res: any, next: any): void {
res.locals.sessionId = "tDy103saszhcxbQq0-mjdzU854";
if (channel === CHANNEL.WEB) {
res.locals.webChannel = true;
} else if (channel === CHANNEL.STRATEGIC_APP) {
res.locals.strategicAppChannel = true;
}

req.session.client = {
serviceType: "MANDATORY",
};
req.session.user = {
email: "test@test.com",

phoneNumber: "7867",
journey: {
nextPath: PATH_NAMES.SIGN_IN_OR_CREATE,
},
};

next();
});

app = await require("../../../../app").createApp();
};

beforeEach(() => {
nock.cleanAll();
});

after(() => {
sinon.restore();
app = undefined;
});

it("The beta banner should appear on the page when the channel is set to 'web'", async () => {
await setupApp(CHANNEL.WEB);
const response = await request(app).get(PATH_NAMES.SIGN_IN_OR_CREATE);
expect(response.status).to.equal(200);
const $ = cheerio.load(response.text);
expect($(".govuk-phase-banner").length).to.equal(1);
});

it("The beta banner should not appear on the page when the channel is set to 'strategic_app'", async () => {
await setupApp(CHANNEL.STRATEGIC_APP);
const response = await request(app).get(PATH_NAMES.SIGN_IN_OR_CREATE);
expect(response.status).to.equal(200);
const $ = cheerio.load(response.text);
expect($(".govuk-phase-banner").length).to.equal(0);
});
});
Loading