From b8b7c05fe21232d4bb6b3bf68fbe31169a732f6b Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:40:21 -0800 Subject: [PATCH] Revert changes to test/cases --- test/cases/01-routing.test.cjs | 74 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/test/cases/01-routing.test.cjs b/test/cases/01-routing.test.cjs index 7354b7a..7490cfa 100644 --- a/test/cases/01-routing.test.cjs +++ b/test/cases/01-routing.test.cjs @@ -8,20 +8,18 @@ describe(' component', function() { this.timeout(4000) it('renders on the page', (browser) => { - browser.restart() - browser .url(browser.launchUrl) .expect.element('body').to.be.present.before(1000) browser .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Home!') + .assert.containsText('h2.routetitle', 'Home!') + + browser.end() }) it('current path appears', (browser) => { - browser.restart() - browser .url(browser.launchUrl) .waitForElementVisible('#currentpath') @@ -31,14 +29,12 @@ describe(' component', function() { }) it('selecting route from hash', (browser) => { - browser.restart() - // Main route browser .url(browser.launchUrl + '/#/') .waitForElementVisible('#currentpath') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Home!') + .assert.containsText('h2.routetitle', 'Home!') .expect.element('#currentpath').text.to.equal('/') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('null') @@ -47,7 +43,7 @@ describe(' component', function() { browser .url(browser.launchUrl + '/#/wild') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Wild') + .assert.containsText('h2.routetitle', 'Wild') .expect.element('#currentpath').text.to.equal('/wild') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('null') @@ -56,95 +52,95 @@ describe(' component', function() { browser .url(browser.launchUrl + '/#/hello/svelte') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Hi there!') + .assert.containsText('h2.routetitle', 'Hi there!') .expect.element('#currentpath').text.to.equal('/hello/svelte') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}') + + browser.end() }) it('loading page with hash', (browser) => { - browser.restart() - browser .url(browser.launchUrl + '/#/hello/svelte') .waitForElementVisible('#currentpath') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Hi there!') + .assert.containsText('h2.routetitle', 'Hi there!') .expect.element('#currentpath').text.to.equal('/hello/svelte') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}') + + browser.end() }) it('refreshing page', (browser) => { - browser.restart() - // /hello/svelte browser .url(browser.launchUrl + '/#/hello/svelte') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Hi there!') + .assert.containsText('h2.routetitle', 'Hi there!') .expect.element('#currentpath').text.to.equal('/hello/svelte') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}') - + browser .refresh(() => { browser.waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Hi there!') + .assert.containsText('h2.routetitle', 'Hi there!') .expect.element('#currentpath').text.to.equal('/hello/svelte') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}') + + browser.end() }) }) it('catch-all route', (browser) => { - browser.restart() - browser .url(browser.launchUrl + '/#/does/not/exist') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'NotFound') + .assert.containsText('h2.routetitle', 'NotFound') .expect.element('#currentpath').text.to.equal('/does/not/exist') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('{"wild":"does/not/exist"}') + + browser.end() }) it('clicking on link', (browser) => { - browser.restart() - browser .url(browser.launchUrl + '/#/') .waitForElementVisible('ul.navigation-links') .click('.navigation-links a[href="#/hello/svelte"]', () => { browser .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Hi there!') + .assert.containsText('h2.routetitle', 'Hi there!') .expect.element('#currentpath').text.to.equal('/hello/svelte') browser .expect.element('#nameparams').text.to.equal('Your name is: svelte') + + browser.end() }) }) it('clicking link with children', (browser) => { - browser.restart() - browser .url(browser.launchUrl + '/#/hello/world') .waitForElementVisible('ul.navigation-links') .click('.navigation-links li a b', () => { browser .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Home!') + .assert.containsText('h2.routetitle', 'Home!') .expect.element('#currentpath').text.to.equal('/brand') browser.expect.element('#currentqs').text.to.equal('') browser.expect.element('#currentparams').text.to.equal('null') + + browser.end() }) }) it('back and forward buttons', (browser) => { - browser.restart() - browser .url(browser.launchUrl + '/#/hello/svelte/user') .waitForElementVisible('ul.navigation-links') @@ -170,26 +166,28 @@ describe(' component', function() { browser .waitForElementVisible('#nameparams') .expect.element('#nameparams').text.to.equal('Your name is: svelte') + + browser.end() }) }) }) }) it('push method', (browser) => { - browser.restart() - browser .url(browser.launchUrl + '/#/') .waitForElementVisible('p.navigation-buttons') .click('.navigation-buttons button:nth-of-type(1)', () => { browser .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Wild') + .assert.containsText('h2.routetitle', 'Wild') .expect.element('#currentpath').text.to.equal('/wild/something') browser.expect.element('#currentparams').text.to.equal('{"wild":"something"}') browser.url((url) => { assert.strictEqual(url.value, browser.launchUrl + '/#/wild/something') + + browser.end() }) }) }) @@ -206,7 +204,7 @@ describe(' component', function() { .click('.navigation-buttons button:nth-of-type(2)', () => { browser .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Wild') + .assert.containsText('h2.routetitle', 'Wild') .expect.element('#currentpath').text.to.equal('/wild/something') browser.url((url) => { @@ -230,7 +228,7 @@ describe(' component', function() { .click('.navigation-buttons button:nth-of-type(3)', () => { browser .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Wild') + .assert.containsText('h2.routetitle', 'Wild') .expect.element('#currentpath').text.to.equal('/wild/replaced') browser.url((url) => { @@ -242,7 +240,7 @@ describe(' component', function() { .click('.navigation-buttons button:nth-of-type(2)', () => { browser .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Wild') + .assert.containsText('h2.routetitle', 'Wild') .expect.element('#currentpath').text.to.equal('/wild/something') browser.url((url) => { @@ -262,7 +260,7 @@ describe(' component', function() { browser .url(browser.launchUrl + '/#/hello/svelte?search=query&sort=0') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Hi there!') + .assert.containsText('h2.routetitle', 'Hi there!') .expect.element('#currentpath').text.to.equal('/hello/svelte') browser.expect.element('#currentqs').text.to.equal('search=query&sort=0') @@ -270,7 +268,7 @@ describe(' component', function() { browser .refresh(() => { browser.waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Hi there!') + .assert.containsText('h2.routetitle', 'Hi there!') .expect.element('#currentpath').text.to.equal('/hello/svelte') browser.expect.element('#currentqs').text.to.equal('search=query&sort=0') @@ -320,7 +318,7 @@ describe(' component', function() { // Condition always fails browser.url(browser.launchUrl + '/#/lucky?pass=0') .waitForElementVisible('h2.routetitle') - .assert.textContains('h2.routetitle', 'Wild') + .assert.containsText('h2.routetitle', 'Wild') .expect.element('#currentpath').text.to.equal('/wild/conditions-failed') browser.expect.element('#currentqs').text.to.equal('')