Skip to content

Commit

Permalink
fix(constants): fixed import (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin authored Apr 12, 2023
1 parent 92f591c commit 8ca23ec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/classes/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
// Constants
const FOOTER_PATH = "footer.yml"
const NAVIGATION_PATH = "navigation.yml"
const { HOMEPAGE_NAME } = require("@root/constants")
const { HOMEPAGE_FILENAME } = require("@root/constants")

const retrieveSettingsFiles = async (
accessToken,
Expand Down Expand Up @@ -42,7 +42,7 @@ const retrieveSettingsFiles = async (

// Retrieve homepage only if flag is set to true
if (shouldRetrieveHomepage) {
fileRetrievalObj.homepage = HomepageFile.read(HOMEPAGE_NAME)
fileRetrievalObj.homepage = HomepageFile.read(HOMEPAGE_FILENAME)
}

const fileContentsArr = await Bluebird.map(
Expand Down Expand Up @@ -233,7 +233,7 @@ class Settings {
const homepageContent = ["---\n", homepageFrontMatter, "---"].join("")
const newHomepageContent = Base64.encode(homepageContent)

await HomepageFile.update(HOMEPAGE_NAME, newHomepageContent, sha)
await HomepageFile.update(HOMEPAGE_FILENAME, newHomepageContent, sha)
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/routes/v1/authenticatedSites/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {
const { File, HomepageType } = require("@classes/File")

// Constants
const { HOMEPAGE_NAME } = require("@root/constants")
const { HOMEPAGE_FILENAME } = require("@root/constants")

// Read homepage index file
async function readHomepage(req, res) {
Expand All @@ -24,7 +24,9 @@ async function readHomepage(req, res) {
const IsomerFile = new File(accessToken, siteName)
const homepageType = new HomepageType()
IsomerFile.setFileType(homepageType)
const { sha, content: encodedContent } = await IsomerFile.read(HOMEPAGE_NAME)
const { sha, content: encodedContent } = await IsomerFile.read(
HOMEPAGE_FILENAME
)
const content = Base64.decode(encodedContent)

// TO-DO:
Expand All @@ -48,7 +50,7 @@ async function updateHomepage(req, res) {
const homepageType = new HomepageType()
IsomerFile.setFileType(homepageType)
const { newSha } = await IsomerFile.update(
HOMEPAGE_NAME,
HOMEPAGE_FILENAME,
Base64.encode(content),
sha
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
convertDataToMarkdown,
} = require("@utils/markdown-utils")

const { HOMEPAGE_NAME } = require("@root/constants")
const { HOMEPAGE_FILENAME } = require("@root/constants")

class HomepagePageService {
constructor({ gitHubService }) {
Expand All @@ -14,7 +14,7 @@ class HomepagePageService {
const { content: rawContent, sha } = await this.gitHubService.read(
sessionData,
{
fileName: HOMEPAGE_NAME,
fileName: HOMEPAGE_FILENAME,
}
)
const { frontMatter, pageContent } = retrieveDataFromMarkdown(rawContent)
Expand All @@ -26,7 +26,7 @@ class HomepagePageService {
const { newSha } = await this.gitHubService.update(sessionData, {
fileContent: newContent,
sha,
fileName: HOMEPAGE_NAME,
fileName: HOMEPAGE_FILENAME,
})
return {
content: { frontMatter, pageBody: content },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
homepageSha: mockHomepageSha,
rawHomepageContent: mockRawHomepageContent,
} = require("@fixtures/homepage")
const { HOMEPAGE_NAME } = require("@root/constants")
const { HOMEPAGE_FILENAME } = require("@root/constants")

describe("Homepage Page Service", () => {
const siteName = "test-site"
Expand Down Expand Up @@ -58,7 +58,7 @@ describe("Homepage Page Service", () => {
mockRawHomepageContent
)
expect(mockGithubService.read).toHaveBeenCalledWith(reqDetails, {
fileName: HOMEPAGE_NAME,
fileName: HOMEPAGE_FILENAME,
})
})
})
Expand All @@ -69,7 +69,7 @@ describe("Homepage Page Service", () => {
it("Updating page content works correctly", async () => {
await expect(
service.update(reqDetails, {
fileName: HOMEPAGE_NAME,
fileName: HOMEPAGE_FILENAME,
content: mockContent,
frontMatter: mockFrontMatter,
sha: oldSha,
Expand All @@ -84,7 +84,7 @@ describe("Homepage Page Service", () => {
mockContent
)
expect(mockGithubService.update).toHaveBeenCalledWith(reqDetails, {
fileName: HOMEPAGE_NAME,
fileName: HOMEPAGE_FILENAME,
fileContent: mockRawHomepageContent,
sha: oldSha,
})
Expand Down

0 comments on commit 8ca23ec

Please sign in to comment.