Skip to content

Commit 7db30de

Browse files
author
jack-mailslurp
committed
imports
2 parents 86bb199 + 881e529 commit 7db30de

File tree

13 files changed

+1206
-1152
lines changed

13 files changed

+1206
-1152
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ copy-manifest:
2424
aws s3 cp .manifest.json s3://assets.mailslurp.com/examples/manifest.json
2525

2626
copy-shortcodes:
27-
aws s3 sync shortcodes/ s3://api-spec.mailslurp.com/shortcodes-github
27+
aws s3 cp shortcodes/ s3://api-spec.mailslurp.com/shortcodes-github
2828

2929
copy-screenshots:
30-
aws s3 cp php-laravel-phpunit/tests/Browser/screenshots/ s3://api-spec.mailslurp.com/test-screenshots/examples/php-laravel-phpunit
30+
aws s3 cp -r php-laravel-phpunit/tests/Browser/screenshots/ s3://api-spec.mailslurp.com/test-screenshots/examples/php-laravel-phpunit

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ See developer page for [more guides and documentation](https://www.mailslurp.com
1717
- [dart-email-testing](./dart-email-testing)
1818
- [deno-email-api](./deno-email-api)
1919
- [elixir-phoenix-hound](./elixir-phoenix-hound)
20+
- [firebase-examples](./firebase-examples)
2021
- [flutter-email-test](./flutter-email-test)
2122
- [fsharp-email-mstest](./fsharp-email-mstest)
2223
- [golang-email-test](./golang-email-test)
@@ -64,6 +65,7 @@ See developer page for [more guides and documentation](https://www.mailslurp.com
6465
- [swift-email-smtp-examples](./swift-email-smtp-examples)
6566
- [telnet-imap-sh](./telnet-imap-sh)
6667
- [visualbasic](./visualbasic)
68+
- [wait-for-methods-vitest](./wait-for-methods-vitest)
6769

6870
## Running locally
6971
If you wish to run these examples yourself:

java-maven-selenium/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dependency>
1515
<groupId>com.mailslurp</groupId>
1616
<artifactId>mailslurp-client-java</artifactId>
17-
<version>15.17.1</version>
17+
<version>15.17.33</version>
1818
</dependency>
1919
<dependency>
2020
<groupId>org.seleniumhq.selenium</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.mailslurp.examples;
2+
3+
import com.mailslurp.apis.EmailControllerApi;
4+
import com.mailslurp.apis.InboxControllerApi;
5+
import com.mailslurp.apis.WaitForControllerApi;
6+
import com.mailslurp.clients.ApiClient;
7+
import com.mailslurp.clients.ApiException;
8+
import com.mailslurp.clients.Configuration;
9+
import com.mailslurp.models.*;
10+
import org.junit.BeforeClass;
11+
import org.junit.Test;
12+
import org.openqa.selenium.WebDriver;
13+
import org.openqa.selenium.firefox.FirefoxDriver;
14+
import org.openqa.selenium.firefox.FirefoxOptions;
15+
import org.openqa.selenium.firefox.FirefoxProfile;
16+
import org.openqa.selenium.remote.CapabilityType;
17+
import org.slf4j.Logger;
18+
import org.slf4j.LoggerFactory;
19+
20+
import java.io.File;
21+
import java.time.Duration;
22+
import java.time.temporal.ChronoUnit;
23+
import java.util.*;
24+
25+
import static org.junit.Assert.*;
26+
27+
public class MoreMethodsTest {
28+
29+
// get a MailSlurp API Key free at https://app.mailslurp.com
30+
private static final String YOUR_API_KEY = System.getenv("API_KEY");
31+
private static final Long TIMEOUT_MILLIS = 30000L;
32+
33+
private static ApiClient mailslurpClient;
34+
private Logger logger = LoggerFactory.getLogger(this.getClass());
35+
36+
@BeforeClass
37+
public static void beforeAll() {
38+
assertNotNull(YOUR_API_KEY);
39+
// setup mailslurp
40+
mailslurpClient = Configuration.getDefaultApiClient();
41+
mailslurpClient.setApiKey(YOUR_API_KEY);
42+
mailslurpClient.setConnectTimeout(TIMEOUT_MILLIS.intValue());
43+
}
44+
45+
@Test
46+
public void canCreateInboxAndFetch() throws ApiException {
47+
InboxControllerApi inboxControllerApi = new InboxControllerApi(mailslurpClient);
48+
//<gen>java_create_inbox_with_tags_and_names
49+
// use names, description, and tags to identify an inbox
50+
String randomString = String.valueOf(new Random().nextLong());
51+
String customName = "Test inbox " + randomString;
52+
String customDescription = "My custom description " + randomString;
53+
String customTag = "test-inbox-" + randomString;
54+
// create inbox with options so we can find it later
55+
CreateInboxDto options = new CreateInboxDto()
56+
.name(customName)
57+
.description(customDescription)
58+
.tags(Collections.singletonList(customTag));
59+
InboxDto inbox = inboxControllerApi.createInboxWithOptions(options);
60+
//</gen>
61+
assertEquals(inbox.getName(), customName);
62+
assertEquals(inbox.getDescription(), customDescription);
63+
assertEquals(Objects.requireNonNull(inbox.getTags()).get(0), customTag);
64+
//<gen>java_fetch_inbox_by_name
65+
InboxByNameResult inboxByName = inboxControllerApi.getInboxByName(customName);
66+
assertEquals(inboxByName.getInboxId(), inbox.getId());
67+
//</gen>
68+
//<gen>java_fetch_inbox_by_tags
69+
PageInboxProjection inboxSearchResult = inboxControllerApi.searchInboxes(
70+
new SearchInboxesOptions()
71+
.search(customTag)
72+
);
73+
assertEquals(inboxSearchResult.getNumberOfElements(), Integer.valueOf(1));
74+
assertEquals(inboxSearchResult.getContent().get(0).getId(), inbox.getId());
75+
//</gen>
76+
String mySubject = "Test subject " + randomString;
77+
inboxControllerApi.sendEmailAndConfirm(inbox.getId(), new SendEmailOptions()
78+
.to(Collections.singletonList(inbox.getEmailAddress()))
79+
.subject(mySubject)
80+
);
81+
//<gen>java_fetch_email_by_match
82+
WaitForControllerApi waitForControllerApi = new WaitForControllerApi(mailslurpClient);
83+
List<EmailPreview> matchingEmails = waitForControllerApi.waitFor(new WaitForConditions()
84+
.inboxId(inbox.getId())
85+
.timeout(120000L)
86+
.count(1)
87+
.countType(WaitForConditions.CountTypeEnum.ATLEAST)
88+
.unreadOnly(true)
89+
.addMatchesItem(new MatchOption()
90+
.field(MatchOption.FieldEnum.SUBJECT)
91+
.should(MatchOption.ShouldEnum.CONTAIN)
92+
.value("Test subject")
93+
)
94+
95+
);
96+
//</gen>
97+
assertEquals(matchingEmails.size(), 1);
98+
assertEquals(Objects.requireNonNull(matchingEmails).get(0).getFrom(), inbox.getEmailAddress());
99+
//<gen>java_fetch_email_by_search
100+
EmailControllerApi emailController = new EmailControllerApi(mailslurpClient);
101+
PageEmailProjection emailSearch = emailController.searchEmails(
102+
new SearchEmailsOptions()
103+
.searchFilter("Test subject")
104+
);
105+
//</gen>
106+
assertEquals(emailSearch.getNumberOfElements(), Integer.valueOf(1));
107+
assertEquals(Objects.requireNonNull(emailSearch.getContent()).get(0).getFrom(), inbox.getEmailAddress());
108+
UUID emailId = emailSearch.getContent().get(0).getId();
109+
//<gen>java_get_email_by_id
110+
Email email = emailController.getEmail(emailId, false);
111+
assertEquals(email.getSubject(), mySubject);
112+
assertNotNull(email.getBody());
113+
assertNotNull(email.getFrom());
114+
assertNotNull(email.getAttachments());
115+
//</gen>
116+
}
117+
}

javascript-cypress-mailslurp-plugin/README.md

+45-46
Original file line numberDiff line numberDiff line change
@@ -28,58 +28,57 @@ describe("user sign up test with mailslurp plugin", function () {
2828
})
2929
});
3030
//</gen>
31-
//<gen>cypress_plugin_01
3231
it("01 - can load the demo application", function () {
32+
//<gen>cypress_plugin_01
3333
// get wrapped email address and assert contains a mailslurp email address
3434
expect(this.emailAddress).to.contain("@mailslurp");
3535
// visit the demo application
3636
cy.visit("https://playground.mailslurp.com")
3737
cy.title().should('contain', 'React App');
38+
//</gen>
39+
//<gen>cypress_plugin_02
40+
cy.then(function () {
41+
// click sign up and fill out the form
42+
cy.get("[data-test=sign-in-create-account-link]").click()
43+
// use the email address and a test password
44+
cy.get("[name=email]").type(this.emailAddress).trigger('change');
45+
cy.get("[name=password]").type('test-password').trigger('change');
46+
// click the submit button
47+
cy.get("[data-test=sign-up-create-account-button]").click();
48+
//</gen>
49+
})
50+
//<gen>cypress_plugin_03
51+
cy.then(function () {
52+
// app will send user an email containing a code, use mailslurp to wait for the latest email
53+
cy.mailslurp()
54+
// use inbox id and a timeout of 30 seconds
55+
.then(mailslurp => mailslurp.waitForLatestEmail(this.inboxId, 30000, true))
56+
// extract the confirmation code from the email body
57+
.then(email => /.*verification code is (\d{6}).*/.exec(email.body!!)!![1])
58+
// fill out the confirmation form and submit
59+
.then(code => {
60+
cy.get("[name=code]").type(code).trigger('change');
61+
cy.get("[data-test=confirm-sign-up-confirm-button]").click();
62+
})
63+
})
64+
//</gen>
65+
//<gen>cypress_plugin_04
66+
// fill out sign in form
67+
cy.then( function () {
68+
// use the email address and a test password
69+
cy.get("[data-test=username-input]").type(this.emailAddress).trigger('change');
70+
cy.get("[data-test=sign-in-password-input]").type('test-password').trigger('change');
71+
// click the submit button
72+
cy.get("[data-test=sign-in-sign-in-button]").click();
73+
});
74+
//</gen>
75+
//<gen>cypress_plugin_05
76+
// can see authorized welcome screen
77+
cy.then(function () {
78+
// click sign up and fill out the form
79+
cy.get("h1").should("contain", "Welcome");
80+
})
81+
//</gen>
3882
});
39-
//</gen>
40-
//<gen>cypress_plugin_02
41-
// use function instead of arrow syntax to access aliased values on this
42-
it("02 - can sign up using email address", function () {
43-
// click sign up and fill out the form
44-
cy.get("[data-test=sign-in-create-account-link]").click()
45-
// use the email address and a test password
46-
cy.get("[name=email]").type(this.emailAddress).trigger('change');
47-
cy.get("[name=password]").type('test-password').trigger('change');
48-
// click the submit button
49-
cy.get("[data-test=sign-up-create-account-button]").click();
50-
});
51-
//</gen>
52-
//<gen>cypress_plugin_03
53-
it("03 - can receive confirmation code by email", function () {
54-
// app will send user an email containing a code, use mailslurp to wait for the latest email
55-
cy.mailslurp()
56-
// use inbox id and a timeout of 30 seconds
57-
.then(mailslurp => mailslurp.waitForLatestEmail(this.inboxId, 30000, true))
58-
// extract the confirmation code from the email body
59-
.then(email => /.*verification code is (\d{6}).*/.exec(email.body!!)!![1])
60-
// fill out the confirmation form and submit
61-
.then(code => {
62-
cy.get("[name=code]").type(code).trigger('change');
63-
cy.get("[data-test=confirm-sign-up-confirm-button]").click();
64-
})
65-
});
66-
//</gen>
67-
//<gen>cypress_plugin_04
68-
// fill out sign in form
69-
it("04 - can sign in with confirmed account", function () {
70-
// use the email address and a test password
71-
cy.get("[data-test=username-input]").type(this.emailAddress).trigger('change');
72-
cy.get("[data-test=sign-in-password-input]").type('test-password').trigger('change');
73-
// click the submit button
74-
cy.get("[data-test=sign-in-sign-in-button]").click();
75-
});
76-
//</gen>
77-
//<gen>cypress_plugin_05
78-
// can see authorized welcome screen
79-
it("05 - can see welcome screen", function () {
80-
// click sign up and fill out the form
81-
cy.get("h1").should("contain", "Welcome");
82-
});
83-
//</gen>
8483
});
8584
```

javascript-cypress-mailslurp-plugin/cypress/e2e/integration-test.cy.ts

+45-46
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,56 @@ describe("user sign up test with mailslurp plugin", function () {
1515
})
1616
});
1717
//</gen>
18-
//<gen>cypress_plugin_01
1918
it("01 - can load the demo application", function () {
19+
//<gen>cypress_plugin_01
2020
// get wrapped email address and assert contains a mailslurp email address
2121
expect(this.emailAddress).to.contain("@mailslurp");
2222
// visit the demo application
2323
cy.visit("https://playground.mailslurp.com")
2424
cy.title().should('contain', 'React App');
25+
//</gen>
26+
//<gen>cypress_plugin_02
27+
cy.then(function () {
28+
// click sign up and fill out the form
29+
cy.get("[data-test=sign-in-create-account-link]").click()
30+
// use the email address and a test password
31+
cy.get("[name=email]").type(this.emailAddress).trigger('change');
32+
cy.get("[name=password]").type('test-password').trigger('change');
33+
// click the submit button
34+
cy.get("[data-test=sign-up-create-account-button]").click();
35+
//</gen>
36+
})
37+
//<gen>cypress_plugin_03
38+
cy.then(function () {
39+
// app will send user an email containing a code, use mailslurp to wait for the latest email
40+
cy.mailslurp()
41+
// use inbox id and a timeout of 30 seconds
42+
.then(mailslurp => mailslurp.waitForLatestEmail(this.inboxId, 30000, true))
43+
// extract the confirmation code from the email body
44+
.then(email => /.*verification code is (\d{6}).*/.exec(email.body!!)!![1])
45+
// fill out the confirmation form and submit
46+
.then(code => {
47+
cy.get("[name=code]").type(code).trigger('change');
48+
cy.get("[data-test=confirm-sign-up-confirm-button]").click();
49+
})
50+
})
51+
//</gen>
52+
//<gen>cypress_plugin_04
53+
// fill out sign in form
54+
cy.then( function () {
55+
// use the email address and a test password
56+
cy.get("[data-test=username-input]").type(this.emailAddress).trigger('change');
57+
cy.get("[data-test=sign-in-password-input]").type('test-password').trigger('change');
58+
// click the submit button
59+
cy.get("[data-test=sign-in-sign-in-button]").click();
60+
});
61+
//</gen>
62+
//<gen>cypress_plugin_05
63+
// can see authorized welcome screen
64+
cy.then(function () {
65+
// click sign up and fill out the form
66+
cy.get("h1").should("contain", "Welcome");
67+
})
68+
//</gen>
2569
});
26-
//</gen>
27-
//<gen>cypress_plugin_02
28-
// use function instead of arrow syntax to access aliased values on this
29-
it("02 - can sign up using email address", function () {
30-
// click sign up and fill out the form
31-
cy.get("[data-test=sign-in-create-account-link]").click()
32-
// use the email address and a test password
33-
cy.get("[name=email]").type(this.emailAddress).trigger('change');
34-
cy.get("[name=password]").type('test-password').trigger('change');
35-
// click the submit button
36-
cy.get("[data-test=sign-up-create-account-button]").click();
37-
});
38-
//</gen>
39-
//<gen>cypress_plugin_03
40-
it("03 - can receive confirmation code by email", function () {
41-
// app will send user an email containing a code, use mailslurp to wait for the latest email
42-
cy.mailslurp()
43-
// use inbox id and a timeout of 30 seconds
44-
.then(mailslurp => mailslurp.waitForLatestEmail(this.inboxId, 30000, true))
45-
// extract the confirmation code from the email body
46-
.then(email => /.*verification code is (\d{6}).*/.exec(email.body!!)!![1])
47-
// fill out the confirmation form and submit
48-
.then(code => {
49-
cy.get("[name=code]").type(code).trigger('change');
50-
cy.get("[data-test=confirm-sign-up-confirm-button]").click();
51-
})
52-
});
53-
//</gen>
54-
//<gen>cypress_plugin_04
55-
// fill out sign in form
56-
it("04 - can sign in with confirmed account", function () {
57-
// use the email address and a test password
58-
cy.get("[data-test=username-input]").type(this.emailAddress).trigger('change');
59-
cy.get("[data-test=sign-in-password-input]").type('test-password').trigger('change');
60-
// click the submit button
61-
cy.get("[data-test=sign-in-sign-in-button]").click();
62-
});
63-
//</gen>
64-
//<gen>cypress_plugin_05
65-
// can see authorized welcome screen
66-
it("05 - can see welcome screen", function () {
67-
// click sign up and fill out the form
68-
cy.get("h1").should("contain", "Welcome");
69-
});
70-
//</gen>
7170
});

0 commit comments

Comments
 (0)