Skip to content

Commit

Permalink
fix: E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Feb 15, 2024
1 parent b4e9fba commit 8eb5869
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 39 deletions.
21 changes: 11 additions & 10 deletions test/e2e/cypress/integration/profiles/passkey/flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { testRegistrationWebhook } from "../../../helpers/webhook"
const signup = (registration: string, app: string, email = gen.email()) => {
cy.visit(registration)

const emailTrait = `${
app === "express" ? '[data-testid="passwordless-flow"]' : ""
} [name="traits.email"]`
const websiteTrait = `${
app === "express" ? '[data-testid="passwordless-flow"]' : ""
} [name="traits.website"]`
app === "express" ? `form[data-testid="passkey-flow"]` : ""
} input[name="traits.website"]`
const emailTrait = `${
app === "express" ? `form[data-testid="passkey-flow"]` : ""
} input[name="traits.email"]`

cy.get(emailTrait).type(email)
cy.get(websiteTrait).type("https://www.ory.sh")
Expand Down Expand Up @@ -118,12 +118,12 @@ context("Passkey registration", () => {
})

const websiteTrait = `${
app === "express" ? `[data-testid="passwordless-flow"]` : ""
} [name="traits.website"]`
app === "express" ? `form[data-testid="passkey-flow"]` : ""
} input[name="traits.website"]`

const emailTrait = `${
app === "express" ? `[data-testid="passwordless-flow"]` : ""
} [name="traits.email"]`
app === "express" ? `form[data-testid="passkey-flow"]` : ""
} input[name="traits.email"]`

cy.get(websiteTrait).type("b")
cy.get('[name="method"][value="passkey"]').click()
Expand All @@ -139,7 +139,8 @@ context("Passkey registration", () => {
cy.get('[data-testid="ui/message/4000001"]').should("to.exist")
cy.get(websiteTrait).should("have.value", "b")
cy.get(emailTrait).should("have.value", email)
cy.get(websiteTrait).clear().type("https://www.ory.sh")
cy.get(websiteTrait).clear()
cy.get(websiteTrait).type("https://www.ory.sh")

cy.get('[name="method"][value="passkey"]').click()

Expand Down
52 changes: 23 additions & 29 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,12 @@ prepare() {
export TEST_DATABASE_COCKROACHDB="cockroach://root@localhost:3446/defaultdb?sslmode=disable"
fi

if [ -n ${SKIP_UI_NODE+x} ]; then
if [ -z ${NODE_UI_PATH+x} ]; then
node_ui_dir="$(mktemp -d -t ci-XXXXXXXXXX)/kratos-selfservice-ui-node"
git clone --depth 1 --branch master https://github.com/ory/kratos-selfservice-ui-node.git "$node_ui_dir"
(cd "$node_ui_dir" && npm i --legacy-peer-deps && npm run build)
else
node_ui_dir="${NODE_UI_PATH}"
fi
if [ -z ${NODE_UI_PATH+x} ]; then
node_ui_dir="$(mktemp -d -t ci-XXXXXXXXXX)/kratos-selfservice-ui-node"
git clone --depth 1 --branch master https://github.com/ory/kratos-selfservice-ui-node.git "$node_ui_dir"
(cd "$node_ui_dir" && npm i --legacy-peer-deps && npm run build)
else
node_ui_dir="${NODE_UI_PATH}"
fi

if [ -z ${RN_UI_PATH+x} ]; then
Expand Down Expand Up @@ -206,29 +204,25 @@ prepare() {
PORT=4746 HYDRA_ADMIN_URL=http://localhost:4745 ./hydra-kratos-login-consent >"${base}/test/e2e/hydra-kratos-ui.e2e.log" 2>&1 &
)

if [ -n ${SKIP_UI_NODE+x} ]; then
(
cd "$node_ui_dir"
PORT=4456 SECURITY_MODE=cookie npm run start \
>"${base}/test/e2e/ui-node.e2e.log" 2>&1 &
)

if [ -z ${REACT_UI_PATH+x} ]; then
(
cd "$node_ui_dir"
PORT=4456 SECURITY_MODE=cookie npm run start \
>"${base}/test/e2e/ui-node.e2e.log" 2>&1 &
cd "$react_ui_dir"
NEXT_PUBLIC_KRATOS_PUBLIC_URL=http://localhost:4433 npm run build
NEXT_PUBLIC_KRATOS_PUBLIC_URL=http://localhost:4433 npm run start -- --hostname 127.0.0.1 --port 4458 \
>"${base}/test/e2e/react-iu.e2e.log" 2>&1 &
)
else
(
cd "$react_ui_dir"
PORT=4458 NEXT_PUBLIC_KRATOS_PUBLIC_URL=http://localhost:4433 npm run dev \
>"${base}/test/e2e/react-iu.e2e.log" 2>&1 &
)
fi

if [ -n ${SKIP_REACT_UI+x} ]; then
if [ -z ${REACT_UI_PATH+x} ]; then
(
cd "$react_ui_dir"
NEXT_PUBLIC_KRATOS_PUBLIC_URL=http://localhost:4433 npm run build
NEXT_PUBLIC_KRATOS_PUBLIC_URL=http://localhost:4433 npm run start -- --hostname 127.0.0.1 --port 4458 \
>"${base}/test/e2e/react-iu.e2e.log" 2>&1 &
)
else
(
cd "$react_ui_dir"
PORT=4458 NEXT_PUBLIC_KRATOS_PUBLIC_URL=http://localhost:4433 npm run dev \
>"${base}/test/e2e/react-iu.e2e.log" 2>&1 &
)
fi
fi

(
Expand Down

0 comments on commit 8eb5869

Please sign in to comment.