Skip to content

Commit

Permalink
fix: tests -d
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Mar 12, 2024
1 parent bd2f74c commit 664f7b1
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 23 deletions.
2 changes: 1 addition & 1 deletion @fiction/core/plugin-user/test/userUpdate.ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ describe('user settings update', async () => {
expect(r.status).toMatchInlineSnapshot(`"success"`)
expect(r?.status).toBe('success')
expect(r?.message).toBe('password updated')
}, 15000)
}, 22000)
})
4 changes: 3 additions & 1 deletion @fiction/core/utils/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export function getThemeFontConfig(fontConfig: FontConfig) {

const fontKeys = Object.values(config).flatMap(_ => [_.fontKey, _.fontKey2]).filter(Boolean) as string[]

return { ...configStacks, fontUrl: createGoogleFontsLink({ fontKeys }) }
const getFontUrl = () => createGoogleFontsLink({ fontKeys })

return { ...configStacks, getFontUrl }
}

export type FontEntry = {
Expand Down
19 changes: 11 additions & 8 deletions @fiction/core/utils/test/fonts.ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('createGoogleFontsLink', () => {
})

describe('getThemeFontConfig', () => {
it('should correctly handle font config', () => {
it('should correctly handle font config', async () => {
const result = getThemeFontConfig({
mono: { fontKey: 'DM Mono', stack: 'monospace' },
input: { fontKey: 'DM Mono', stack: 'sans' },
Expand All @@ -61,11 +61,12 @@ describe('getThemeFontConfig', () => {
})
expect(result.mono).toContain('DM Mono')
expect(result.body).toContain('Source Serif 4')
expect(result.fontUrl).toBeTruthy()
const fontUrl = await result.getFontUrl()
expect(fontUrl).toBeTruthy()
expect(result).toMatchInlineSnapshot(`
{
"body": "'Source Serif 4', Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif",
"fontUrl": "https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=Source+Serif+4:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap",
"getFontUrl": [Function],
"input": "'DM Mono', 'Roboto', Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif",
"mono": "'DM Mono', 'Nimbus Mono PS', 'Courier New', monospace",
"sans": "'Roboto', Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif",
Expand All @@ -74,26 +75,28 @@ describe('getThemeFontConfig', () => {
}
`)
})
it('returns default values when no fontConfig is provided', () => {
it('returns default values when no fontConfig is provided', async () => {
const result = getThemeFontConfig({})
expect(result.mono).toMatchInlineSnapshot(`"'DM Mono', 'Nimbus Mono PS', 'Courier New', monospace"`)
expect(result.body).toMatchInlineSnapshot(`"Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif"`)
expect(result.fontUrl).toMatchInlineSnapshot(`"https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"`)
const fontUrl = await result.getFontUrl()
expect(fontUrl).toMatchInlineSnapshot(`"https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"`)
})

it('returns custom font stacks when fontConfig is provided', () => {
it('returns custom font stacks when fontConfig is provided', async () => {
const fontConfig = {
mono: { fontKey: 'Custom Mono', stack: 'monospace' },
body: { fontKey: 'Custom Serif', stack: 'serif' },
} as const
const result = getThemeFontConfig(fontConfig)
expect(result.mono).toContain('Custom Mono')
expect(result.body).toContain('Custom Serif')
expect(result.fontUrl).toMatchInlineSnapshot(`"https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"`)
const fontUrl = await result.getFontUrl()
expect(fontUrl).toMatchInlineSnapshot(`"https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"`)
expect(result).toMatchInlineSnapshot(`
{
"body": "'Custom Serif', Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif",
"fontUrl": "https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap",
"getFontUrl": [Function],
"input": "'Roboto', Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif",
"mono": "'Custom Mono', 'DM Mono', 'Nimbus Mono PS', 'Courier New', monospace",
"sans": "'Roboto', Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif",
Expand Down
2 changes: 1 addition & 1 deletion @fiction/plugin-sites/engine/XSite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ unhead.useHead({
{ rel: 'shortcut icon', href: () => site.value?.userConfig.value.faviconUrl || '/favicon.png' },
{ key: 'font-pre', rel: 'preconnect ', href: 'https://fonts.googleapis.com' },
{ key: 'font-static', rel: 'preconnect ', href: 'https://fonts.gstatic.com', crossorigin: 'anonymous' },
{ key: 'font', rel: 'stylesheet ', href: () => fonts.value?.fontUrl },
{ key: 'font', rel: 'stylesheet ', href: () => fonts.value?.getFontUrl() },
],
})
Expand Down
51 changes: 50 additions & 1 deletion @fiction/plugin-sites/test/siteEdit.wip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,14 @@ describe('site plugin tests', async () => {
"cardId": "[id:***************************]",
"cards": "",
"createdAt": "[dateTime:]",
"editor": {},
"generation": {
"prompt": "create content for the "test" card ",
"totalEstimatedTime": 0,
"userInputConfig": {},
},
"is404": false,
"isDefault": null,
"isHome": false,
"layoutId": "[id:*******]",
"orgId": "[id:***************************]",
Expand Down Expand Up @@ -264,7 +271,7 @@ describe('site plugin tests', async () => {
expect(m['']).toBe(m.home)

expect(siteObj.currentViewId.value).toMatchInlineSnapshot(`"test"`)
expect(siteObj.currentPage.value?.settings.isHome).toMatchInlineSnapshot(`undefined`)
expect(siteObj.currentPage.value?.settings.isHome).toMatchInlineSnapshot(`false`)
expect(siteObj.activePageId.value).toBeTruthy()

const nm = 'testAlpha'
Expand All @@ -291,7 +298,14 @@ describe('site plugin tests', async () => {
"cardId": "[id:***************************]",
"cards": "",
"createdAt": "[dateTime:]",
"editor": {},
"generation": {
"prompt": "create content for the "testAlpha" card on the "test" page",
"totalEstimatedTime": 0,
"userInputConfig": {},
},
"is404": false,
"isDefault": null,
"isHome": false,
"layoutId": "[id:*******]",
"orgId": "[id:***************************]",
Expand All @@ -316,7 +330,14 @@ describe('site plugin tests', async () => {
"cardId": "[id:***************************]",
"cards": "[object Object],[object Object]",
"createdAt": "[dateTime:]",
"editor": {},
"generation": {
"prompt": "create content for the "testAlpha" card on the "test" page",
"totalEstimatedTime": 0,
"userInputConfig": {},
},
"is404": false,
"isDefault": null,
"isHome": false,
"layoutId": "[id:*******]",
"orgId": "[id:***************************]",
Expand Down Expand Up @@ -364,7 +385,14 @@ describe('site plugin tests', async () => {
"cardId": "[id:***************************]",
"cards": "[object Object],[object Object],[object Object]",
"createdAt": "[dateTime:]",
"editor": {},
"generation": {
"prompt": "create content for the "testAlpha" card on the "test" page",
"totalEstimatedTime": 0,
"userInputConfig": {},
},
"is404": false,
"isDefault": null,
"isHome": false,
"layoutId": "[id:*******]",
"orgId": "[id:***************************]",
Expand Down Expand Up @@ -393,7 +421,14 @@ describe('site plugin tests', async () => {
"cardId": "[id:***************************]",
"cards": "[object Object],[object Object],[object Object]",
"createdAt": "[dateTime:]",
"editor": {},
"generation": {
"prompt": "create content for the "testAlpha" card on the "test" page",
"totalEstimatedTime": 0,
"userInputConfig": {},
},
"is404": false,
"isDefault": null,
"isHome": false,
"layoutId": "[id:*******]",
"orgId": "[id:***************************]",
Expand Down Expand Up @@ -427,7 +462,14 @@ describe('site plugin tests', async () => {
"cardId": "[id:***************************]",
"cards": "[object Object],[object Object],[object Object]",
"createdAt": "[dateTime:]",
"editor": {},
"generation": {
"prompt": "create content for the "testAlpha" card on the "test" page",
"totalEstimatedTime": 0,
"userInputConfig": {},
},
"is404": false,
"isDefault": null,
"isHome": false,
"layoutId": "[id:*******]",
"orgId": "[id:***************************]",
Expand Down Expand Up @@ -472,7 +514,14 @@ describe('site plugin tests', async () => {
"cardId": "[id:***************************]",
"cards": "[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]",
"createdAt": "[dateTime:]",
"editor": {},
"generation": {
"prompt": "create content for the "testAlpha" card on the "test" page",
"totalEstimatedTime": 0,
"userInputConfig": {},
},
"is404": false,
"isDefault": null,
"isHome": false,
"layoutId": "[id:*******]",
"orgId": "[id:***************************]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ describe('minimalProfile', async () => {
"type": "string",
},
"href": {
"description": "Link / Route",
"type": "string",
},
"name": {
"description": "Label for profile detail (Email)",
"type": "string",
},
"target": {
"description": "Target",
"enum": [
"_self",
"_blank",
Expand All @@ -43,19 +45,21 @@ describe('minimalProfile', async () => {
"type": "array",
},
"userConfig.detailsTitle": {
"description": "Bullets Title",
"type": "string",
},
"userConfig.heading": {
"description": "Primary headline for profile 3 to 8 words",
"type": "string",
},
"userConfig.mediaItems": {
"description": "splash picture in portrait format",
"items": {
"additionalProperties": false,
"properties": {
"media": {
"additionalProperties": false,
"description": "splash picture in portrait format",
"description": "Image",
"properties": {
"format": {
"enum": [
Expand All @@ -82,18 +86,22 @@ describe('minimalProfile', async () => {
"type": "array",
},
"userConfig.socials": {
"description": "Socials",
"items": {
"additionalProperties": false,
"properties": {
"desc": {
"description": "Description",
"maxLength": 100,
"minLength": 2,
"type": "string",
},
"href": {
"description": "Link / Route",
"type": "string",
},
"icon": {
"description": "Icon",
"enum": [
"x",
"linkedin",
Expand All @@ -113,11 +121,13 @@ describe('minimalProfile', async () => {
"type": "string",
},
"name": {
"description": "Text",
"maxLength": 30,
"minLength": 2,
"type": "string",
},
"target": {
"description": "Target",
"enum": [
"_self",
"_blank",
Expand Down
9 changes: 1 addition & 8 deletions @fiction/plugin-sites/utils/test/region.wip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,9 @@ describe('requestManagePage', async () => {

expect(r).toMatchInlineSnapshot(`
{
"code": "STOP",
"context": "ManagePage",
"data": {
"_action": "retrieve",
"caller": "retrieveAttemptAfterDelete",
"cardId": "card2",
},
"expose": true,
"httpStatus": 200,
"message": "Page not found",
"message": "",
"status": "error",
}
`)
Expand Down
2 changes: 1 addition & 1 deletion @fiction/plugin-unsplash/test/unsplash.ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ describe('user tests', () => {
expect(r2?.status).toBe('success')
const urls2 = r?.data?.map(d => d.urls).filter(Boolean)
expect(urls2?.length).toBe(30)
}, 10000)
}, 20000)
})
13 changes: 13 additions & 0 deletions @fiction/ui/test/inputOption.wip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,13 @@ describe('getOptionSchema', () => {
"additionalProperties": false,
"properties": {
"users": {
"description": "users",
"items": {
"additionalProperties": false,
"properties": {
"profile": {
"additionalProperties": false,
"description": "profile",
"properties": {
"age": {
"exclusiveMinimum": 0,
Expand Down Expand Up @@ -419,6 +421,7 @@ describe('navItemOptionSet Schema Generation', () => {
expect(s.properties).toMatchInlineSnapshot(`
{
"list": {
"description": "list",
"items": {
"additionalProperties": false,
"properties": {
Expand All @@ -427,12 +430,15 @@ describe('navItemOptionSet Schema Generation', () => {
"type": "string",
},
"href": {
"description": "Link / Route",
"type": "string",
},
"name": {
"description": "Text",
"type": "string",
},
"target": {
"description": "Target",
"enum": [
"_self",
"_blank",
Expand All @@ -449,6 +455,7 @@ describe('navItemOptionSet Schema Generation', () => {
"type": "array",
},
"listTitle": {
"description": "Nav Title",
"type": "string",
},
}
Expand All @@ -470,19 +477,24 @@ describe('navItemOptionSet Schema Generation', () => {
"additionalProperties": false,
"properties": {
"nav": {
"description": "nav",
"items": {
"additionalProperties": false,
"properties": {
"desc": {
"description": "Description",
"type": "string",
},
"href": {
"description": "Link / Route",
"type": "string",
},
"name": {
"description": "Text",
"type": "string",
},
"target": {
"description": "Target",
"enum": [
"_self",
"_blank",
Expand All @@ -499,6 +511,7 @@ describe('navItemOptionSet Schema Generation', () => {
"type": "array",
},
"navTitle": {
"description": "Nav Title",
"type": "string",
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"unit:e2e": "npm exec -- vitest e2e",
"unit:all": "npm exec -- vitest wip && npm exec -- vitest ci && npm exec -- vitest build",
"unit:dist": "npm exec -- vitest dist",
"unit:coverage": "npm exec -- vitest wip ci ui --coverage --ui",
"unit:coverage": "npm exec -- vitest run wip ci ui --coverage --ui -u",
"types:ci": "npm exec -- vue-tsc",
"types:dev": "npm exec -- vue-tsc --watch",
"lint:dev": "npm exec -- eslint . --fix",
Expand Down

0 comments on commit 664f7b1

Please sign in to comment.