mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(toast): migrate e2e tests
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { By, until } = require('selenium-webdriver');
|
||||
const { register, Page, platforms } = require('../../../../../scripts/e2e');
|
||||
|
||||
class E2ETestPage extends Page {
|
||||
constructor(driver, platform) {
|
||||
super(driver, `http://localhost:3333/src/components/toast/test/basic?ionic:mode=${platform}`);
|
||||
}
|
||||
|
||||
async present(buttonId) {
|
||||
await this.navigate('#content');
|
||||
this.driver.findElement(By.id(buttonId)).click();
|
||||
await this.driver.wait(until.elementLocated(By.css('.toast-wrapper')));
|
||||
return await this.driver.wait(until.elementIsVisible(this.driver.findElement(By.css('.toast-wrapper'))));
|
||||
}
|
||||
|
||||
async closeWithBackdrop() {
|
||||
this.driver.findElement(By.css('ion-backdrop')).click();
|
||||
return await this.driver.wait(until.elementIsNotVisible(this.driver.findElement(By.css('ion-backdrop'))));
|
||||
}
|
||||
}
|
||||
|
||||
platforms.forEach(platform => {
|
||||
describe('toast/basic', () => {
|
||||
register('should init', driver => {
|
||||
const page = new E2ETestPage(driver, platform);
|
||||
return page.navigate('#content');
|
||||
});
|
||||
|
||||
register('shows bottom toast', driver => {
|
||||
const page = new E2ETestPage(driver, platform);
|
||||
return page.present('showBottomToast');
|
||||
});
|
||||
});
|
||||
});
|
||||
25
core/src/components/toast/test/basic/e2e.ts
Normal file
25
core/src/components/toast/test/basic/e2e.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { newE2EPage } from '@stencil/core/testing';
|
||||
|
||||
it('toast: basic', async () => {
|
||||
const page = await newE2EPage({
|
||||
url: '/src/components/toast/test/basic?ionic:animated=false'
|
||||
});
|
||||
|
||||
const button = await page.find('#showBottomToast');
|
||||
await button.click();
|
||||
|
||||
let toast = await page.find('ion-toast');
|
||||
await toast.waitForVisible();
|
||||
|
||||
let compare = await page.compareScreenshot();
|
||||
expect(compare).toMatchScreenshot();
|
||||
|
||||
await toast.callMethod('dismiss');
|
||||
await toast.waitForNotVisible();
|
||||
|
||||
compare = await page.compareScreenshot('dismissed');
|
||||
expect(compare).toMatchScreenshot();
|
||||
|
||||
toast = await page.find('ion-toast');
|
||||
expect(toast).toBeNull();
|
||||
});
|
||||
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { By, until } = require('selenium-webdriver');
|
||||
const { register, Page, platforms } = require('../../../../../scripts/e2e');
|
||||
|
||||
class E2ETestPage extends Page {
|
||||
constructor(driver, platform) {
|
||||
super(driver, `http://localhost:3333/src/components/toast/test/standalone?ionic:mode=${platform}`);
|
||||
}
|
||||
|
||||
async present(buttonId) {
|
||||
await this.navigate('#basic');
|
||||
this.driver.findElement(By.id(buttonId)).click();
|
||||
await this.driver.wait(until.elementLocated(By.css('.toast-wrapper')));
|
||||
return await this.driver.wait(until.elementIsVisible(this.driver.findElement(By.css('.toast-wrapper'))));
|
||||
}
|
||||
}
|
||||
|
||||
platforms.forEach(platform => {
|
||||
describe('toast/standalone', () => {
|
||||
register('should init', driver => {
|
||||
const page = new E2ETestPage(driver, platform);
|
||||
return page.navigate('#basic');
|
||||
});
|
||||
|
||||
register('shows basic toast', driver => {
|
||||
const page = new E2ETestPage(driver, platform);
|
||||
return page.present('basic');
|
||||
});
|
||||
});
|
||||
});
|
||||
17
core/src/components/toast/test/standalone/e2e.ts
Normal file
17
core/src/components/toast/test/standalone/e2e.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { newE2EPage } from '@stencil/core/testing';
|
||||
|
||||
it('toast: standalone', async () => {
|
||||
const page = await newE2EPage({
|
||||
url: '/src/components/toast/test/standalone?ionic:animated=false'
|
||||
});
|
||||
|
||||
const button = await page.find('#basic');
|
||||
await button.click();
|
||||
|
||||
const toast = await page.find('ion-toast');
|
||||
await toast.waitForVisible();
|
||||
|
||||
const compare = await page.compareScreenshot();
|
||||
expect(compare).toMatchScreenshot();
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user