Skip to content

Commit

Permalink
test: update E2E tests to support protractor with native promises
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin committed Oct 5, 2020
1 parent 49be173 commit d53da2d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/tests/build/lazy-load-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export default async function () {
import { browser, logging, element, by } from 'protractor';
describe('workspace-project App', () => {
it('should display lazy route', () => {
browser.get(browser.baseUrl + '/lazy');
expect(element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
it('should display lazy route', async () => {
await browser.get(browser.baseUrl + '/lazy');
expect(await element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
});
afterEach(async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/tests/build/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export default async function () {
import { browser, logging, element, by } from 'protractor';
describe('workspace-project App', () => {
it('should display lazy route', () => {
browser.get(browser.baseUrl + '/lazy');
expect(element(by.css('app-lazy p')).getText()).toEqual('lazy works!');
it('should display lazy route', async () => {
await browser.get(browser.baseUrl + '/lazy');
expect(await element(by.css('app-lazy p')).getText()).toEqual('lazy works!');
});
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export default async function () {
page = new AppPage();
});
it('should display text from library component', () => {
page.navigateTo();
expect(element(by.css('lib-my-lib p')).getText()).toEqual('my-lib works!');
it('should display text from library component', async () => {
await page.navigateTo();
expect(await element(by.css('lib-my-lib p')).getText()).toEqual('my-lib works!');
});
afterEach(async () => {
Expand Down
18 changes: 9 additions & 9 deletions tests/legacy-cli/e2e/tests/i18n/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export async function setupI18nConfig(useLocalize = true, format: keyof typeof f
import { browser, logging, element, by } from 'protractor';
describe('workspace-project App', () => {
const getParagraph = (name: string) => element(by.css('app-root p#' + name)).getText();
const getParagraph = async (name: string) => element(by.css('app-root p#' + name)).getText();
beforeEach(() => browser.get(browser.baseUrl));
afterEach(async () => {
// Assert that there are no errors emitted from the browser
Expand All @@ -135,17 +135,17 @@ export async function setupI18nConfig(useLocalize = true, format: keyof typeof f
} as logging.Entry));
});
it('should display welcome message', () =>
expect(getParagraph('hello')).toEqual('${translation.hello}'));
it('should display welcome message', async () =>
expect(await getParagraph('hello')).toEqual('${translation.hello}'));
it('should display locale', () =>
expect(getParagraph('locale')).toEqual('${lang}'));
it('should display locale', async () =>
expect(await getParagraph('locale')).toEqual('${lang}'));
it('should display localized date', () =>
expect(getParagraph('date')).toEqual('${translation.date}'));
it('should display localized date', async () =>
expect(await getParagraph('date')).toEqual('${translation.date}'));
it('should display pluralized message', () =>
expect(getParagraph('plural')).toEqual('${translation.plural}'));
it('should display pluralized message', async () =>
expect(await getParagraph('plural')).toEqual('${translation.plural}'));
});
`);
}
Expand Down
22 changes: 11 additions & 11 deletions tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export default function () {
'./e2e/src/app.po.ts': `
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() { return browser.get('/'); }
async navigateTo() { return browser.get('/'); }
getIncrementButton() { return element(by.buttonText('Increment')); }
getDecrementButton() { return element(by.buttonText('Decrement')); }
getResetButton() { return element(by.buttonText('Reset Counter')); }
getCounter() { return element(by.xpath('/html/body/app-root/div/span')).getText(); }
async getCounter() { return element(by.xpath('/html/body/app-root/div/span')).getText(); }
}
`,
'./e2e/src/app.e2e-spec.ts': `
Expand All @@ -33,15 +33,15 @@ export default function () {
page = new AppPage();
});
it('should operate counter', () => {
page.navigateTo();
page.getIncrementButton().click();
page.getIncrementButton().click();
expect(page.getCounter()).toEqual('2');
page.getDecrementButton().click();
expect(page.getCounter()).toEqual('1');
page.getResetButton().click();
expect(page.getCounter()).toEqual('0');
it('should operate counter', async () => {
await page.navigateTo();
await page.getIncrementButton().click();
await page.getIncrementButton().click();
expect(await page.getCounter()).toEqual('2');
await page.getDecrementButton().click();
expect(await page.getCounter()).toEqual('1');
await page.getResetButton().click();
expect(await page.getCounter()).toEqual('0');
});
});
`,
Expand Down

0 comments on commit d53da2d

Please sign in to comment.