Skip to content

Commit f36066e

Browse files
committed
tests
1 parent 50e4618 commit f36066e

File tree

9 files changed

+10703
-3
lines changed

9 files changed

+10703
-3
lines changed

csharp-specflow-mstest-selenium/Steps/SignUpStepDefinitions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
2-
using System.Net;
32
using System.Text.RegularExpressions;
43
using FluentAssertions;
54
using mailslurp.Api;
65
using mailslurp.Client;
7-
using mailslurp.Model;
86
using OpenQA.Selenium;
97
using OpenQA.Selenium.Firefox;
108
using TechTalk.SpecFlow;

java-testng-selenium/src/test/java/com/mailslurp/examples/SignUpTestNGExample.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.testng.annotations.AfterSuite;
1414
import org.testng.annotations.BeforeSuite;
1515
import org.testng.annotations.Test;
16-
import ru.stqa.selenium.factory.WebDriverPool;
1716
import java.io.File;
1817
import java.util.Random;
1918
import java.util.concurrent.TimeUnit;

javascript-testcafe/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
artifacts
2+
coverage
3+
node_modules

javascript-testcafe/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-include ../.env
2+
3+
node_modules:
4+
npm install
5+
6+
clean:
7+
rm -rf artifacts
8+
9+
fmt:
10+
npm run fmt
11+
12+
test: node_modules
13+
API_KEY=$(API_KEY) npm t

javascript-testcafe/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TestCafe MFA Test

javascript-testcafe/mfa-test.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Selector } from "testcafe";
2+
import { MailSlurp } from "mailslurp-client";
3+
4+
let mailslurp;
5+
const password = "test-password";
6+
7+
fixture`mfa sign-up test`.page`https://playground.mailslurp.com`.before(
8+
async (_) => {
9+
const apiKey = process.env.API_KEY;
10+
if (!apiKey) {
11+
throw "No MailSlurp API KEY defined";
12+
}
13+
mailslurp = new MailSlurp({ apiKey });
14+
}
15+
);
16+
17+
test("Can sign-up and verify account", async (t) => {
18+
// create email address for a test user
19+
const inbox = await mailslurp.inboxController.createInbox();
20+
// load the page and click sign up
21+
await t
22+
.expect(Selector("title").innerText)
23+
.eql("React App")
24+
.click(Selector("[data-test=sign-in-create-account-link]"));
25+
// wait for sign up form then fill with email address and sign up
26+
const emailInput = await Selector('[name="email"]')();
27+
await t
28+
.typeText(emailInput, inbox.emailAddress)
29+
.typeText(Selector('[name="password"]'), password)
30+
.click(Selector("[data-test=sign-up-create-account-button]"));
31+
// wait for verification code to arrive to email then extract code
32+
const email = await mailslurp.waitController.waitForLatestEmail(
33+
inbox.id,
34+
30000,
35+
true
36+
);
37+
// use regex to extract the confirmation code which is 6 digits
38+
const code = /([0-9]{6})$/.exec(email.body)[1];
39+
// now enter code to confirm
40+
await t
41+
.typeText(Selector('[name="code"]'), code)
42+
.click(Selector('[data-test="confirm-sign-up-confirm-button"]'));
43+
// now sign up
44+
const username = await Selector('[name="username"]')();
45+
await t
46+
.typeText(username, inbox.emailAddress)
47+
.typeText(Selector('[name="password"]'), password);
48+
const signIn = await Selector("[data-test=sign-in-sign-in-button]")();
49+
await t.click(signIn);
50+
// wait for sign up
51+
const h1 = await Selector("h1")();
52+
await t.expect(h1.innerText).eql("Welcome");
53+
});

javascript-testcafe/output.gif

165 KB
Loading

0 commit comments

Comments
 (0)