refactor(aio): rename directory (tests/deployment-config --> tests/deployment) (#23390)
PR Close #23390
This commit is contained in:

committed by
Jason Aden

parent
8b2101be9f
commit
d665d9a18c
52
aio/tests/deployment/e2e/protractor.conf.js
Normal file
52
aio/tests/deployment/e2e/protractor.conf.js
Normal file
@ -0,0 +1,52 @@
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'./*.e2e-spec.ts'
|
||||
],
|
||||
capabilities: {
|
||||
browserName: 'chrome',
|
||||
// For Travis
|
||||
chromeOptions: {
|
||||
binary: process.env.CHROME_BIN,
|
||||
args: ['--no-sandbox']
|
||||
}
|
||||
},
|
||||
directConnect: true,
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function() {}
|
||||
},
|
||||
params: {
|
||||
sitemapUrls: [],
|
||||
legacyUrls: [],
|
||||
},
|
||||
beforeLaunch() {
|
||||
const {register} = require('ts-node');
|
||||
register({});
|
||||
},
|
||||
onPrepare() {
|
||||
const {SpecReporter} = require('jasmine-spec-reporter');
|
||||
const {browser} = require('protractor');
|
||||
const {loadLegacyUrls, loadRemoteSitemapUrls} = require('../shared/helpers');
|
||||
|
||||
return Promise.all([
|
||||
browser.getProcessedConfig(),
|
||||
loadRemoteSitemapUrls(browser.baseUrl),
|
||||
loadLegacyUrls(),
|
||||
]).then(([config, sitemapUrls, legacyUrls]) => {
|
||||
if (sitemapUrls.length <= 100) {
|
||||
throw new Error(`Too few sitemap URLs. (Expected: >100 | Found: ${sitemapUrls.length})`);
|
||||
} else if (legacyUrls.length <= 100) {
|
||||
throw new Error(`Too few legacy URLs. (Expected: >100 | Found: ${legacyUrls.length})`);
|
||||
}
|
||||
|
||||
Object.assign(config.params, {sitemapUrls, legacyUrls});
|
||||
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
|
||||
});
|
||||
}
|
||||
};
|
50
aio/tests/deployment/e2e/redirection.e2e-spec.ts
Normal file
50
aio/tests/deployment/e2e/redirection.e2e-spec.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { browser } from 'protractor';
|
||||
|
||||
describe(browser.baseUrl, () => {
|
||||
const sitemapUrls = browser.params.sitemapUrls;
|
||||
const legacyUrls = browser.params.legacyUrls;
|
||||
const goTo = async url => {
|
||||
// Go to the specified URL and then unregister the ServiceWorker
|
||||
// to ensure subsequent requests are passed through to the server.
|
||||
await browser.get(url);
|
||||
await browser.executeAsyncScript(cb => navigator.serviceWorker
|
||||
.getRegistrations()
|
||||
.then(regs => Promise.all(regs.map(reg => reg.unregister())))
|
||||
.then(cb));
|
||||
};
|
||||
|
||||
beforeAll(async done => {
|
||||
// Make an initial request to unregister the ServiceWorker.
|
||||
await goTo(browser.baseUrl);
|
||||
done();
|
||||
});
|
||||
|
||||
beforeEach(() => browser.waitForAngularEnabled(false));
|
||||
afterEach(() => browser.waitForAngularEnabled(true));
|
||||
|
||||
describe('(with sitemap URLs)', () => {
|
||||
sitemapUrls.forEach((url, i) => {
|
||||
it(`should not redirect '${url}' (${i + 1}/${sitemapUrls.length})`, async () => {
|
||||
await goTo(url);
|
||||
|
||||
const expectedUrl = browser.baseUrl + url;
|
||||
const actualUrl = (await browser.getCurrentUrl()).replace(/\?.*$/, '');
|
||||
|
||||
expect(actualUrl).toBe(expectedUrl);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('(with legacy URLs)', () => {
|
||||
legacyUrls.forEach(([fromUrl, toUrl], i) => {
|
||||
it(`should redirect '${fromUrl}' to '${toUrl}' (${i + 1}/${legacyUrls.length})`, async () => {
|
||||
await goTo(fromUrl);
|
||||
|
||||
const expectedUrl = (/^http/.test(toUrl) ? '' : browser.baseUrl.replace(/\/$/, '')) + toUrl;
|
||||
const actualUrl = (await browser.getCurrentUrl()).replace(/\?.*$/, '');
|
||||
|
||||
expect(actualUrl).toBe(expectedUrl);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user