Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

801 remove single event dependecy #804

Merged
merged 8 commits into from
May 16, 2023
20 changes: 1 addition & 19 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
<template>
<div>
<!-- One life event version. -->
<div v-if="isUsaGov">
<div>
<UsaGovHeader />
<main id="main-content">
<Nuxt />
</main>
<UsaGovFooter />
</div>
</div>
<!-- Multi life event version. (uses beta site design) -->
<div v-else>
<!-- Beta USA Header. /-->
<div>
<UsaGovHeader />
<main id="main-content">
<Nuxt />
</main>
<!-- Beta USA Footer. /-->
<UsaGovFooter />
</div>
</div>
</template>

<script>
export default {
data() {
return {
isUsaGov: this.$config.oneEventVersion !== false,
}
},
head() {
return {
htmlAttrs: {
Expand Down
20 changes: 0 additions & 20 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,12 @@ const getLifeEvents = () => {
// https://federalist.18f.gov/documentation/env-vars-on-federalist-builds/#default-environment-variables
const sitePrefix = process.env.BASEURL ? `${process.env.BASEURL}/` : ""

const SITE_URLPREFIX =
process.env.SITE_URLPREFIX || "https://federalist-edd11e6f-8be2-4dc2-a85e-1782e0bcb08e.app.cloud.gov"
const SITE_PREFIX = process.env.SITE_PREFIX || ""

if (process.env.NODE_ENV !== "test") {
console.log("SITE_URLPREFIX:", SITE_URLPREFIX)
console.log("SITE_PREFIX:", SITE_PREFIX)
}

// Figure out one life event version
const landingPageMd = fs.readFileSync("./content/landing-page.md", "utf8")
const oneEventVersion = () => {
if (landingPageMd.includes("lifeEvent:")) {
return landingPageMd.split("lifeEvent:")[1].split("\n")[0].trim()
} else {
return false
}
}
const oneEvent = oneEventVersion()

export default {
publicRuntimeConfig: {
// This is used to toggle whether or not internationalization is enabled
languageToggleActive: true,
branchName: process.env.BRANCH,
oneEventVersion: false,
},

// Target: https://go.nuxtjs.dev/config-target
Expand Down
5 changes: 1 addition & 4 deletions pages/_lifeEvent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@
</div>
</section>
<CrossSell
v-if="$config.oneEventVersion === false"
:cards="lifeEvent.related"
:title="$t('crossSell.title')"
class="print:display-none" />
Expand Down Expand Up @@ -242,9 +241,7 @@ export default {
},

async fetch() {
const chosenEvent =
this.$config.oneEventVersion === false ? this.$route.params.lifeEvent : this.$config.oneEventVersion

const chosenEvent = this.$route.params.lifeEvent
const lifeEvent = await this.$content("life-events", chosenEvent).fetch()
const lifeEventBenefits = await this.$content("benefits")
.where({
Expand Down
55 changes: 1 addition & 54 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,55 +1,5 @@
<template>
<div>
<section
class="grid-container usa-section"
:style="$config.oneEventVersion !== false ? 'display: none' : ''">
<div class="grid-row grid-gap">
<div class="tablet:grid-col-10">
<h1 class="font-heading-lg tablet:font-heading-xl margin-top-0 text-secondary">
{{ landingPage.title }}
</h1>
<p class="tablet:font-heading-lg line-height-serif-6 text-normal measure-6">
{{ landingPage.summary }}
</p>
<ol class="usa-process-list">
<li
v-for="step in landingPage.processListSteps"
:key="step"
class="usa-process-list__item padding-bottom-4">
<p class="usa-process-list__heading font-sans-md tablet:font-sans-lg line-height-sans-1">
{{ step }}
</p>
</li>
</ol>
</div>
</div>

<div class="grid-row grid-gap margin-top-4">
<div class="tablet:grid-col-10">
<ul
v-if="lifeEvents && lifeEvents.length > 0"
class="usa-card-group">
<li
v-for="event in lifeEvents"
:key="event.slug"
class="usa-card desktop:grid-col-6"
:aria-label="$t(event.title)">
<nuxt-link
class="display-block height-full margin-x-1"
style="text-decoration: none; outline-offset: 0.25rem"
:to="localePath(`/${event.slug}`)">
<Card
:card-body="$t(event.summary)"
:card-title="$t(event.title)"
:card-container-classes="['hover:border-base-light', 'margin-x-0']"
card-title-heading-level="h2" />
</nuxt-link>
</li>
</ul>
</div>
</div>
</section>
</div>
<div></div>
</template>

<script>
Expand All @@ -69,9 +19,6 @@ export default {
}
},
mounted() {
if (this.$config.oneEventVersion !== false) {
this.$router.replace(this.$route.fullPath + this.$config.oneEventVersion)
}
this.landingPage = tObj.call(this, this.landingPage)
},
}
Expand Down
1 change: 0 additions & 1 deletion test/Components/UsaGovHeader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe("<UsaGovHeader />", () => {
},
$config: {
languageToggleActive: true,
oneEventVersion: false,
},
},
})
Expand Down
3 changes: 0 additions & 3 deletions test/beforeAllTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export default function beforeAllTests() {
config.stubs.NuxtLink = { template: "<a><slot /></a>" }
config.stubs.NuxtContent = { template: "<div><slot /></div>" }
config.stubs.ClientOnly = { template: "<div><slot /></div>" }
config.mocks.$config = {
oneEventVersion: false,
}
config.mocks.$i18n = {
locale: "en",
locales: [
Expand Down
3 changes: 0 additions & 3 deletions test/pages/LifeEvent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ describe("Life Event page", () => {
dispatchEvent: jest.fn(),
})),
})
config.mocks.$config = {
oneEventVersion: false,
}
config.mocks.lifeEvent = {}
await beforeAllTests()
})
Expand Down
18 changes: 0 additions & 18 deletions test/pages/LifeEvents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,6 @@ describe("LifeEventsPage", () => {
expect(wrapper.vm).toBeTruthy()
})

it("is a Vue instance (one-event-version)", () => {
config.mocks.$config = {
oneEventVersion: "death-of-a-loved-one",
}
const wrapper = shallowMount(LifeEventsPage)
expect(wrapper.vm).toBeTruthy()
config.mocks.$config = {
oneEventVersion: false,
}
})

it("displays a list of one life event", async () => {
const wrapper = shallowMount(LifeEventsPage)
await wrapper.setData(mockContent2)
expect(wrapper.find(".usa-card-group").exists()).toBeTruthy()
expect(wrapper.findAll(".usa-card").length).toBe(1)
})

it("asyncData() fetches the given data", async () => {
let contentRequest
const contentMock = {
Expand Down