refactor: update hash fn in test config

This commit is contained in:
Joe Previte 2021-06-02 13:31:50 -07:00
parent 1134780b8b
commit 788b958e20
No known key found for this signature in database
GPG Key ID: 2C91590C6B742C24
1 changed files with 6 additions and 4 deletions

View File

@ -8,21 +8,21 @@ import {
Config,
globalSetup,
} from "@playwright/test"
import * as bcrypt from "bcrypt"
import * as argon2 from "argon2"
import path from "path"
import { PASSWORD } from "./utils/constants"
import * as wtfnode from "./utils/wtfnode"
// Playwright doesn't like that ../src/node/util has an enum in it
// so I had to copy hash in separately
const hash = (str: string): string => {
return bcrypt.hashSync(str, 10)
const hash = async (str: string): Promise<string> => {
return await argon2.hash(str)
}
const cookieToStore = {
sameSite: "Lax" as const,
name: "key",
value: hash(PASSWORD),
value: "",
domain: "localhost",
path: "/",
expires: -1,
@ -38,6 +38,8 @@ globalSetup(async () => {
wtfnode.setup()
}
cookieToStore.value = await hash(PASSWORD)
const storage = {
cookies: [cookieToStore],
}