Skip to content

Commit 65030d6

Browse files
committed
added selenium tests
1 parent 3aa7d52 commit 65030d6

File tree

1 file changed

+89
-10
lines changed

1 file changed

+89
-10
lines changed

e2e/seleniumTest.js

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,53 @@
11
const webdriver = require('selenium-webdriver');
22
const { By, until } = webdriver;
33

4-
(async function() {
4+
async function localHostedTest(driver, servType, dbType, dbUri, dbName, dbDesc) {
5+
await driver.findElement(By.id('serv-type')).sendKeys(servType);
6+
await driver.findElement(By.id('db-type')).sendKeys(dbType);
7+
await driver.findElement(By.id('db-uri')).sendKeys(dbUri);
8+
await driver.findElement(By.id('db-name')).sendKeys(dbName);
9+
await driver.findElement(By.id('db-desc')).sendKeys(dbDesc);
10+
await driver.findElement(By.xpath('//button[text()="Submit"]')).click();
11+
}
12+
13+
async function cloudHostedTest(
14+
driver,
15+
servType,
16+
awsInstance,
17+
awsRegion,
18+
awsAccessKey,
19+
awsSecretAccessKey,
20+
awsURL,
21+
awsName,
22+
dbDesc
23+
) {
24+
await driver.findElement(By.id('serv-type')).sendKeys(servType);
25+
await driver.findElement(By.id('aws-instance')).sendKeys(awsInstance);
26+
await driver.findElement(By.id('aws-region')).sendKeys(awsRegion);
27+
await driver.findElement(By.id('aws-access-key')).sendKeys(awsAccessKey);
28+
await driver.findElement(By.id('aws-secret-access-key')).sendKeys(awsSecretAccessKey);
29+
await driver.findElement(By.id('aws-url')).sendKeys(awsURL);
30+
await driver.findElement(By.id('aws-name')).sendKeys(awsName);
31+
await driver.findElement(By.id('db-desc')).sendKeys(dbDesc);
32+
await driver.findElement(By.xpath('//button[text()="Submit"]')).click();
33+
}
34+
35+
async function signupTest(driver, username, email, password, passwordConfirm) {
36+
await driver.wait(until.elementLocated(By.className('main-routes')), 30000);
37+
await driver.findElement(By.id('username')).sendKeys(username);
38+
await driver.findElement(By.id('email')).sendKeys(email);
39+
await driver.findElement(By.id('password')).sendKeys(password);
40+
await driver.findElement(By.id('passwordConfirm')).sendKeys(passwordConfirm);
41+
await driver.findElement(By.xpath('//button[text()="Sign Up"]')).click();
42+
}
43+
44+
(async function () {
545
const driver = new webdriver.Builder()
646
.usingServer('http://localhost:9515')
747
.withCapabilities({
848
'goog:chromeOptions': {
949
debuggerAddress: 'localhost:9222',
10-
}
50+
},
1151
})
1252
.forBrowser('chrome')
1353
.build();
@@ -17,20 +57,59 @@ const { By, until } = webdriver;
1757
await driver.findElement(By.className('card')).click();
1858
await driver.wait(until.elementLocated(By.className('add-container')), 10000);
1959
await driver.findElement(By.className('env-button2')).click();
20-
await driver.wait(until.elementLocated(By.className('add-container')), 10000);
60+
await driver.wait(until.elementLocated(By.className('add-container')), 10000);
61+
await localHostedTest(
62+
driver,
63+
'Docker',
64+
'SQL',
65+
'mongodb://localhost:27017/mydb',
66+
'Test Docker',
67+
'A description of my app'
68+
);
69+
70+
await driver.findElement(By.id('card-add')).click();
71+
await driver.wait(until.elementLocated(By.className('add-container')), 10000);
72+
await driver.findElement(By.className('env-button2')).click();
73+
await driver.wait(until.elementLocated(By.className('add-container')), 10000);
74+
await localHostedTest(
75+
driver,
76+
'Kubernetes',
77+
'MongoDB',
78+
'mongodb://localhost:27017/mydb',
79+
'Test Kubernetes',
80+
'A description of my app'
81+
);
82+
83+
await driver.findElement(By.id('card-add')).click();
84+
await driver.wait(until.elementLocated(By.className('add-container')), 10000);
85+
await driver.findElement(By.className('env-button')).click();
86+
await driver.wait(until.elementLocated(By.className('add-container')), 10000);
87+
await cloudHostedTest(
88+
driver,
89+
'Elastic Compute Cloud (EC2)',
90+
'i-1234567890abcdef0',
91+
'us-east-1',
92+
'your-access-key',
93+
'your-secret-access-key',
94+
'mongodb://your-mongodb-url',
95+
'Test AWS',
96+
'Test MongoDB Database'
97+
);
2198

22-
await driver.findElement(By.id('serv-type')).sendKeys('Docker');
23-
await driver.findElement(By.id('db-type')).sendKeys('SQL');
24-
await driver.findElement(By.id('db-uri')).sendKeys('mongodb://localhost:27017/mydb');
25-
await driver.findElement(By.id('db-name')).sendKeys('My App');
26-
await driver.findElement(By.id('db-desc')).sendKeys('A description of my app');
99+
await driver.findElement(By.className('personIconArea')).click();
100+
const signUpButton = await driver.wait(
101+
until.elementLocated(By.xpath('//span[text()="Sign Up"]')),
102+
10000
103+
);
104+
await driver.wait(until.elementIsEnabled(signUpButton), 10000);
105+
await signUpButton.click();
106+
await signupTest(driver, 'testUser', '[email protected]', 'testPassword', 'testPassword');
27107

28-
await driver.findElement(By.xpath('//button[text()="Submit"]')).click();
29108
console.log('E2E test completed successfully');
30-
31109
} catch (error) {
32110
console.error('E2E test failed:', error);
33111
} finally {
112+
await driver.executeScript('window.close()');
34113
await driver.quit();
35114
}
36115
})();

0 commit comments

Comments
 (0)