initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
128
static/test/e2e/image-repo.scenario.ts
Normal file
128
static/test/e2e/image-repo.scenario.ts
Normal file
|
@ -0,0 +1,128 @@
|
|||
import { browser, element, by, $, $$ } from 'protractor';
|
||||
import { appHost } from '../protractor.conf';
|
||||
import { CorTabsViewObject } from '../../js/directives/ui/cor-tabs/cor-tabs.view-object';
|
||||
|
||||
|
||||
describe("Image Repository", () => {
|
||||
const username = 'devtable';
|
||||
const password = 'password';
|
||||
const repoTabs: CorTabsViewObject = new CorTabsViewObject();
|
||||
|
||||
beforeAll((done) => {
|
||||
browser.waitForAngularEnabled(false);
|
||||
|
||||
// Sign in
|
||||
browser.get(appHost);
|
||||
$$('a[href="/signin/"]').get(1).click();
|
||||
$('#signin-username').sendKeys(username);
|
||||
$('#signin-password').sendKeys(password);
|
||||
element(by.partialButtonText('Sign in')).click();
|
||||
browser.sleep(4000);
|
||||
|
||||
// Navigate to image repository
|
||||
browser.get(`${appHost}/repository/devtable/simple`).then(() => done());
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
browser.waitForAngularEnabled(true);
|
||||
});
|
||||
|
||||
describe("information tab", () => {
|
||||
const tabTitle: string = 'Information';
|
||||
|
||||
beforeAll((done) => {
|
||||
repoTabs.selectTabByTitle(tabTitle).then(() => done());
|
||||
});
|
||||
|
||||
it("displays repository description", () => {
|
||||
expect(repoTabs.isActiveTab(tabTitle)).toBe(true);
|
||||
expect(element(by.cssContainingText('h4', 'Description')).isDisplayed()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("tags tab", () => {
|
||||
const tabTitle: string = 'Tags';
|
||||
|
||||
beforeAll((done) => {
|
||||
repoTabs.selectTabByTitle(tabTitle).then(() => done());
|
||||
});
|
||||
|
||||
it("displays repository tags", () => {
|
||||
expect(repoTabs.isActiveTab(tabTitle)).toBe(true);
|
||||
expect(element(by.cssContainingText('.tab-header', 'Repository Tags')).isDisplayed()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("tag history tab", () => {
|
||||
const tabTitle: string = 'Tag History';
|
||||
|
||||
beforeAll((done) => {
|
||||
repoTabs.selectTabByTitle(tabTitle).then(() => done());
|
||||
});
|
||||
|
||||
it("displays repository tags", () => {
|
||||
expect(repoTabs.isActiveTab(tabTitle)).toBe(true);
|
||||
expect(element(by.cssContainingText('.tab-header', 'Tag History')).isDisplayed()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("builds tab", () => {
|
||||
const tabTitle: string = 'Builds';
|
||||
|
||||
beforeAll((done) => {
|
||||
repoTabs.selectTabByTitle(tabTitle).then(() => done());
|
||||
});
|
||||
|
||||
it("displays repository tags", () => {
|
||||
expect(repoTabs.isActiveTab(tabTitle)).toBe(true);
|
||||
expect(element(by.cssContainingText('.tab-header', 'Repository Builds')).isDisplayed()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("usage logs tab", () => {
|
||||
const tabTitle: string = 'Usage Logs';
|
||||
|
||||
beforeAll((done) => {
|
||||
repoTabs.selectTabByTitle(tabTitle).then(() => done());
|
||||
});
|
||||
|
||||
it("displays repository tags", () => {
|
||||
expect(repoTabs.isActiveTab(tabTitle)).toBe(true);
|
||||
expect(element(by.cssContainingText('h3', 'Usage Logs')).isDisplayed()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("settings tab", () => {
|
||||
const tabTitle: string = 'Settings';
|
||||
|
||||
beforeAll((done) => {
|
||||
repoTabs.selectTabByTitle(tabTitle).then(() => done());
|
||||
});
|
||||
|
||||
it("displays repository tags", () => {
|
||||
expect(repoTabs.isActiveTab(tabTitle)).toBe(true);
|
||||
expect(element(by.cssContainingText('.tab-header', 'Settings')).isDisplayed()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("tabs navigation", () => {
|
||||
|
||||
beforeAll((done) => {
|
||||
repoTabs.selectTabByTitle('Information');
|
||||
repoTabs.selectTabByTitle('Tags');
|
||||
done();
|
||||
});
|
||||
|
||||
it("back button returns to previous tab", () => {
|
||||
browser.navigate().back();
|
||||
|
||||
expect(repoTabs.isActiveTab('Information')).toBe(true);
|
||||
});
|
||||
|
||||
it("forward button returns to next tab", () => {
|
||||
browser.navigate().forward();
|
||||
|
||||
expect(repoTabs.isActiveTab('Tags')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
19
static/test/e2e/sanity.scenario.ts
Normal file
19
static/test/e2e/sanity.scenario.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { browser } from 'protractor';
|
||||
import { appHost } from '../protractor.conf';
|
||||
|
||||
|
||||
describe("sanity test", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
browser.get(appHost);
|
||||
});
|
||||
|
||||
it("loads home view with no AngularJS errors", () => {
|
||||
browser.manage().logs().get('browser')
|
||||
.then((browserLog: any) => {
|
||||
browserLog.forEach((log: any) => {
|
||||
expect(log.message).not.toContain("angular");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
154
static/test/e2e/trigger-creation.scenario.ts
Normal file
154
static/test/e2e/trigger-creation.scenario.ts
Normal file
|
@ -0,0 +1,154 @@
|
|||
import { browser, element, by, $, $$ } from 'protractor';
|
||||
import { ManageTriggerViewObject } from '../../js/directives/ui/manage-trigger/manage-trigger.view-object';
|
||||
import { appHost } from '../protractor.conf';
|
||||
|
||||
|
||||
describe("Trigger Creation", () => {
|
||||
const username = 'devtable';
|
||||
const password = 'password';
|
||||
var manageTriggerView: ManageTriggerViewObject = new ManageTriggerViewObject();
|
||||
|
||||
beforeAll((done) => {
|
||||
browser.waitForAngularEnabled(false);
|
||||
|
||||
// Sign in
|
||||
browser.get(appHost);
|
||||
$$('a[href="/signin/"]').get(1).click();
|
||||
$('#signin-username').sendKeys(username);
|
||||
$('#signin-password').sendKeys(password);
|
||||
element(by.partialButtonText('Sign in')).click();
|
||||
browser.sleep(4000).then(() => done());
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
browser.waitForAngularEnabled(true);
|
||||
});
|
||||
|
||||
describe("for custom git", () => {
|
||||
|
||||
beforeAll(() => {
|
||||
// Navigate to trigger setup
|
||||
browser.get(`${appHost}/repository/devtable/simple?tab=builds`)
|
||||
});
|
||||
|
||||
it("can select custom git repository push as a trigger option", (done) => {
|
||||
element(by.buttonText('Create Build Trigger')).click();
|
||||
element(by.linkText('Custom Git Repository Push')).click();
|
||||
browser.sleep(1000);
|
||||
done();
|
||||
});
|
||||
|
||||
it("shows custom git repository section first", () => {
|
||||
expect(manageTriggerView.sections['customrepo'].isDisplayed()).toBe(true);
|
||||
});
|
||||
|
||||
it("does not accept invalid custom git repository URL's", () => {
|
||||
manageTriggerView.continue()
|
||||
.then(() => fail('Should not accept empty input for repository URL'))
|
||||
.catch(() => manageTriggerView.enterRepositoryURL('git@some'))
|
||||
.then(() => manageTriggerView.continue())
|
||||
.then(() => fail('Should not accept invalid input for repository URL'))
|
||||
.catch(() => null);
|
||||
});
|
||||
|
||||
it("proceeds to Dockerfile location section when given valid URL", () => {
|
||||
manageTriggerView.enterRepositoryURL('git@somegit.com:someuser/somerepo.git');
|
||||
manageTriggerView.continue()
|
||||
.then(() => {
|
||||
expect(manageTriggerView.sections['dockerfilelocation'].isDisplayed()).toBe(true);
|
||||
})
|
||||
.catch(reason => fail(reason));
|
||||
});
|
||||
|
||||
it("does not accept Dockerfile location that does not end with a filename", () => {
|
||||
manageTriggerView.enterDockerfileLocation('/')
|
||||
.then(() => manageTriggerView.continue())
|
||||
.then(() => fail('Should not accept Dockerfile location that does not end with a filename'))
|
||||
.catch(() => null);
|
||||
});
|
||||
|
||||
it("does not provide Dockerfile location suggestions", () => {
|
||||
manageTriggerView.getDockerfileSuggestions()
|
||||
.then((results) => {
|
||||
expect(results.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
it("proceeds to Docker context location section when given a valid Dockerfile location", () => {
|
||||
manageTriggerView.enterDockerfileLocation('/Dockerfile')
|
||||
.then(() => manageTriggerView.continue())
|
||||
.then(() => {
|
||||
expect(manageTriggerView.sections['contextlocation'].isDisplayed()).toBe(true);
|
||||
})
|
||||
.catch(reason => fail(reason));
|
||||
});
|
||||
|
||||
it("does not accept invalid Docker context", () => {
|
||||
manageTriggerView.enterDockerContext('')
|
||||
.then(() => manageTriggerView.continue())
|
||||
.then(() => fail('Should not acccept invalid Docker context location'))
|
||||
.catch(() => null);
|
||||
});
|
||||
|
||||
it("provides suggestions for Docker context based on Dockerfile location", () => {
|
||||
manageTriggerView.getDockerContextSuggestions()
|
||||
.then((results) => {
|
||||
expect(results).toContain('/');
|
||||
});
|
||||
});
|
||||
|
||||
it("proceeds to robot selection section when given valid Docker context", () => {
|
||||
manageTriggerView.enterDockerContext('/')
|
||||
.then(() => manageTriggerView.continue())
|
||||
.then(() => {
|
||||
expect(manageTriggerView.sections['robot'].isDisplayed()).toBe(true);
|
||||
})
|
||||
.catch(reason => fail(reason));
|
||||
});
|
||||
|
||||
it("allows selection of optional robot account", () => {
|
||||
manageTriggerView.selectRobotAccount(0)
|
||||
.catch(reason => fail(reason));
|
||||
});
|
||||
|
||||
it("proceeds to verification section", () => {
|
||||
manageTriggerView.continue()
|
||||
.then(() => {
|
||||
expect(manageTriggerView.sections['verification'].isDisplayed()).toBe(true);
|
||||
})
|
||||
.catch(reason => fail(reason));
|
||||
});
|
||||
|
||||
it("displays success message after creating the trigger", () => {
|
||||
manageTriggerView.continue()
|
||||
.then(() => {
|
||||
browser.sleep(2000);
|
||||
expect($('h3').getText()).toEqual('Trigger has been successfully activated');
|
||||
})
|
||||
.catch(reason => fail(reason));
|
||||
});
|
||||
});
|
||||
|
||||
describe("for githost", () => {
|
||||
|
||||
beforeAll(() => {
|
||||
// Navigate to trigger setup
|
||||
browser.get(`${appHost}/repository/devtable/simple?tab=builds`);
|
||||
});
|
||||
|
||||
it("can select GitHub repository push as a trigger option", () => {
|
||||
element(by.partialButtonText('Create Build Trigger')).click();
|
||||
element(by.linkText('GitHub Repository Push')).click();
|
||||
});
|
||||
|
||||
it("redirects to GitHub login page for granting authentication", () => {
|
||||
expect(browser.getCurrentUrl()).toContain('github.com');
|
||||
|
||||
// TODO: Which credentials do we use to login to GitHub?
|
||||
});
|
||||
|
||||
xit("shows namespace select section first", () => {
|
||||
expect(manageTriggerView.sections['namespace'].isDisplayed()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
6
static/test/jasmine.json
Normal file
6
static/test/jasmine.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spec_dir": "./static/js",
|
||||
"spec_files": [
|
||||
"**/*.spec.js"
|
||||
]
|
||||
}
|
67
static/test/protractor.conf.ts
Normal file
67
static/test/protractor.conf.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
import { Config, browser } from 'protractor';
|
||||
import * as request from 'request';
|
||||
|
||||
|
||||
/*
|
||||
* Use a set environment variable or default value for the app host.
|
||||
*/
|
||||
export const appHost: string = process.env.APP_HOST || 'http://localhost:5000';
|
||||
|
||||
|
||||
/**
|
||||
* Protractor is configured to run against a Selenium instance running locally on port 4444 and a Quay instance running
|
||||
* locally on port 5000.
|
||||
* Easiest method is running the Quay and Selenium containers:
|
||||
* $ docker run -d --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.4.0
|
||||
* $ docker run -d --net=host quay.io/quay/quay
|
||||
* $ yarn run e2e
|
||||
*/
|
||||
export const config: Config = {
|
||||
framework: 'jasmine',
|
||||
seleniumAddress: 'http://localhost:4444/wd/hub',
|
||||
// Uncomment to run tests against local Chrome instance
|
||||
// directConnect: true,
|
||||
capabilities: {
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
args: [
|
||||
'--disable-infobars'
|
||||
],
|
||||
prefs: {
|
||||
'profile.password_manager_enabled': false,
|
||||
'credentials_enable_service': false,
|
||||
'password_manager_enabled': false
|
||||
}
|
||||
}
|
||||
},
|
||||
onPrepare: () => {
|
||||
browser.driver.manage().window().maximize();
|
||||
|
||||
// Resolve promise when request returns HTTP 200
|
||||
return new Promise((resolve, reject) => {
|
||||
const pollServer = (success, failure) => {
|
||||
request(appHost, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
console.log(`Successfully connected to server at ${appHost}`);
|
||||
success();
|
||||
} else {
|
||||
console.log(`Could not connect to server at ${appHost}`);
|
||||
setTimeout(() => {
|
||||
failure(success, failure);
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
pollServer(resolve, pollServer);
|
||||
});
|
||||
},
|
||||
onComplete: () => {
|
||||
browser.close();
|
||||
},
|
||||
specs: [
|
||||
// './e2e/sanity.scenario.ts',
|
||||
// './e2e/trigger-creation.scenario.ts',
|
||||
'./e2e/image-repo.scenario.ts',
|
||||
],
|
||||
};
|
30
static/test/shims/window.shim.js
Normal file
30
static/test/shims/window.shim.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Add properties to window object used by 'app.js' to avoid test errors
|
||||
|
||||
window.__config = {
|
||||
'SERVER_HOSTNAME': "",
|
||||
'PREFERRED_URL_SCHEME': "",
|
||||
};
|
||||
window.__features = {};
|
||||
window.__oauth = {
|
||||
'GITHUB_TRIGGER_CONFIG': {
|
||||
'CLIENT_ID': "",
|
||||
'GITHUB_ENDPOINT': "",
|
||||
'AUTHORIZE_ENDPOINT': "",
|
||||
},
|
||||
'GITLAB_TRIGGER_CONFIG': {
|
||||
'CLIENT_ID': "",
|
||||
'GITLAB_ENDPOINT': "",
|
||||
'AUTHORIZE_ENDPOINT': "",
|
||||
}
|
||||
};
|
||||
window.__endpoints = {
|
||||
"/api/v1/user/": {
|
||||
"get": {
|
||||
"operationId": "getLoggedInUser",
|
||||
"parameters": []
|
||||
},
|
||||
"x-name": "endpoints.api.user.User",
|
||||
"x-path": "/api/v1/user/",
|
||||
"x-tag": "user"
|
||||
},
|
||||
};
|
5
static/test/test-index.ts
Normal file
5
static/test/test-index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
declare var require: NodeRequire;
|
||||
|
||||
// Require all modules ending in ".spec.ts" from the js directory and all subdirectories
|
||||
var testsContext = (<any>require).context("../js", true, /\.spec\.ts$/);
|
||||
testsContext.keys().forEach(testsContext);
|
Reference in a new issue