-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
119 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import HouseholdRepository from '$lib/server/repository/Household'; | ||
import UserRepository from '$lib/server/repository/User'; | ||
|
||
export default async function upsertHousehold( | ||
name: string, | ||
publicNotes: string, | ||
householdId: number | null, | ||
userId: number | ||
) { | ||
const data = { | ||
name, | ||
publicNotes, | ||
updatedAt: new Date() | ||
}; | ||
|
||
if (householdId) return await HouseholdRepository.update(householdId, data); | ||
|
||
const household = await HouseholdRepository.create(data); | ||
|
||
// then associate user to it | ||
await UserRepository.update( | ||
{ | ||
id: userId | ||
}, | ||
{ | ||
householdId: household.id | ||
} | ||
); | ||
|
||
return household; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,8 @@ | |
b. BUSY? - Clear btn | ||
c. AVAILABLE? | ||
*/ | ||
/* | ||
create profile | ||
create kid | ||
save basic info | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { run } from '../prisma/seed'; | ||
|
||
// const url = 'http://localhost:5173/profile'; | ||
const host = 'http://localhost:5173'; | ||
|
||
test.beforeEach(async () => { | ||
await run(); | ||
}); | ||
|
||
test("User can create new profile with valid phone number", async ({ page, context }) => { | ||
await page.goto('http://localhost:5173'); | ||
|
||
await page.waitForTimeout(3000); | ||
await page.getByRole('textbox').fill('2015550127'); | ||
await page.getByRole('button').click(); | ||
|
||
let token: string, phone: string; | ||
page.on('dialog', async (dialog) => { | ||
const thing = dialog.message().split(' '); | ||
phone = thing[0]; | ||
token = thing[1]; | ||
dialog.accept(); | ||
}); | ||
page.on('console', async (msg) => { | ||
const first = await msg.args()[0]?.jsonValue(); | ||
if (first === 'PHONE_TOKEN') { | ||
phone = await msg.args()[1].jsonValue(); | ||
token = await msg.args()[2].jsonValue(); | ||
} | ||
}); | ||
await new Promise<void>((resolve) => { | ||
let intervalId = setInterval(() => { | ||
if (phone && token) { | ||
clearInterval(intervalId); | ||
resolve(); | ||
} | ||
}, 100); | ||
}); | ||
await page.goto(`http://localhost:5173/login/${phone!}/${token!}`); | ||
await page.mainFrame().waitForLoadState(); | ||
await expect(page).toHaveURL(host + '/profile'); | ||
}) |