How to use WithText method in storybook-root

Best JavaScript code snippet using storybook-root

single_choice.ts

Source: single_choice.ts Github

copy

Full Screen

1import { Selector } from 'testcafe';2import { request } from '../​../​util';3fixture(`Single choice selection`).beforeEach(async (test) => {4 await request('http:/​/​localhost:6543/​tests/​create?obj=experiment1&obj=experiment2');5 await test.resizeWindow(1100, 800)6 .navigateTo('http:/​/​localhost:6543/​')7 .click(Selector('a').withText('Sign in'))8 .expect(Selector('h1').innerText).eql('Sign in')9 .typeText(Selector('input[name="email"]'), 'test1@example.com')10 .typeText(Selector('input[name="password"]'), 'test1')11 .click(Selector('button').withText('Sign in'))12});13test('Create a required single choice dropdown question', async (test) => {14 await test15 .click(Selector('a').withText('Experiments'))16 .click(Selector('a').withText('Experiment 2'))17 .click(Selector('a').withText('Pages'))18 .click(Selector('a').withText('Welcome'))19 .click(Selector('a').withText('Single-choice'))20 .expect(Selector('li.question').exists).ok()21 .click(Selector('li.question a[aria-label="Edit"]'))22 .typeText(Selector('label').withText('Title').find('input'), 'Select your age')23 .click(Selector('label').withText('Required').find('input'))24 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))25 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(0), '0')26 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))27 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(1), '1')28 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))29 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(2), '2')30 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))31 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(0), 'under 18', {paste: true})32 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))33 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(1), '18 - 65', {paste: true})34 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))35 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(2), 'over 65', {paste: true})36 .click(Selector('label').withText('Display').find('select'))37 .click(Selector('label').withText('Display').find('select option').withText('dropdown'))38 .click(Selector('li.question a[aria-label="Save the question"]'))39 .click(Selector('li.question a[aria-label="Close the editor"]'))40 .expect(Selector('li.question h2.required').withText('Select your age').innerText).eql('Select your age')41 .expect(Selector('li.question select').exists).ok()42 .expect(Selector('li.question select').childElementCount).eql(3)43 .expect(Selector('li.question select option').nth(0).innerText).eql('under 18')44 .expect(Selector('li.question select option').nth(0).value).eql('0')45 .expect(Selector('li.question select option').nth(1).innerText).eql('18 - 65')46 .expect(Selector('li.question select option').nth(1).value).eql('1')47 .expect(Selector('li.question select option').nth(2).innerText).eql('over 65')48 .expect(Selector('li.question select option').nth(2).value).eql('2');49});50test('Create an optional single choice dropdown question', async (test) => {51 await test52 .click(Selector('a').withText('Experiments'))53 .click(Selector('a').withText('Experiment 2'))54 .click(Selector('a').withText('Pages'))55 .click(Selector('a').withText('Welcome'))56 .click(Selector('a').withText('Single-choice'))57 .expect(Selector('li.question').exists).ok()58 .click(Selector('li.question a[aria-label="Edit"]'))59 .typeText(Selector('label').withText('Title').find('input'), 'Select your age')60 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))61 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(0), '0')62 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))63 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(1), '1')64 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))65 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(2), '2')66 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))67 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(0), 'under 18', {paste: true})68 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))69 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(1), '18 - 65', {paste: true})70 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))71 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(2), 'over 65', {paste: true})72 .click(Selector('label').withText('Display').find('select'))73 .click(Selector('label').withText('Display').find('select option').withText('dropdown'))74 .click(Selector('li.question a[aria-label="Save the question"]'))75 .click(Selector('li.question a[aria-label="Close the editor"]'))76 .expect(Selector('li.question h2').withText('Select your age').innerText).eql('Select your age')77 .expect(Selector('li.question h2.required').exists).notOk()78 .expect(Selector('li.question select').exists).ok()79 .expect(Selector('li.question select').childElementCount).eql(3)80 .expect(Selector('li.question select option').nth(0).innerText).eql('under 18')81 .expect(Selector('li.question select option').nth(0).value).eql('0')82 .expect(Selector('li.question select option').nth(1).innerText).eql('18 - 65')83 .expect(Selector('li.question select option').nth(1).value).eql('1')84 .expect(Selector('li.question select option').nth(2).innerText).eql('over 65')85 .expect(Selector('li.question select option').nth(2).value).eql('2');86});87test('Create a required single choice vertical list question', async (test) => {88 await test89 .click(Selector('a').withText('Experiments'))90 .click(Selector('a').withText('Experiment 2'))91 .click(Selector('a').withText('Pages'))92 .click(Selector('a').withText('Welcome'))93 .click(Selector('a').withText('Single-choice'))94 .expect(Selector('li.question').exists).ok()95 .click(Selector('li.question a[aria-label="Edit"]'))96 .typeText(Selector('label').withText('Title').find('input'), 'Select your age')97 .click(Selector('label').withText('Required').find('input'))98 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))99 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(0), '0')100 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))101 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(1), '1')102 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))103 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(2), '2')104 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))105 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(0), 'under 18', {paste: true})106 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))107 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(1), '18 - 65', {paste: true})108 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))109 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(2), 'over 65', {paste: true})110 .click(Selector('label').withText('Display').find('select'))111 .click(Selector('label').withText('Display').find('select option').withText('vertical list'))112 .click(Selector('li.question a[aria-label="Save the question"]'))113 .click(Selector('li.question a[aria-label="Close the editor"]'))114 .expect(Selector('li.question h2.required').withText('Select your age').innerText).eql('Select your age')115 .expect(Selector('li.question ul.no-bullet').childElementCount).eql(3)116 .expect(Selector('li.question li label').nth(0).innerText).eql(' under 18')117 .expect(Selector('li.question li input[type="radio"]').nth(0).value).eql('0')118 .expect(Selector('li.question li label').nth(1).innerText).eql(' 18 - 65')119 .expect(Selector('li.question li input[type="radio"]').nth(1).value).eql('1')120 .expect(Selector('li.question li label').nth(2).innerText).eql(' over 65')121 .expect(Selector('li.question li input[type="radio"]').nth(2).value).eql('2');122});123test('Create an optional single choice vertical list question', async (test) => {124 await test125 .click(Selector('a').withText('Experiments'))126 .click(Selector('a').withText('Experiment 2'))127 .click(Selector('a').withText('Pages'))128 .click(Selector('a').withText('Welcome'))129 .click(Selector('a').withText('Single-choice'))130 .expect(Selector('li.question').exists).ok()131 .click(Selector('li.question a[aria-label="Edit"]'))132 .typeText(Selector('label').withText('Title').find('input'), 'Select your age')133 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))134 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(0), '0')135 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))136 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(1), '1')137 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))138 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(2), '2')139 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))140 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(0), 'under 18', {paste: true})141 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))142 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(1), '18 - 65', {paste: true})143 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))144 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(2), 'over 65', {paste: true})145 .click(Selector('label').withText('Display').find('select'))146 .click(Selector('label').withText('Display').find('select option').withText('vertical list'))147 .click(Selector('li.question a[aria-label="Save the question"]'))148 .click(Selector('li.question a[aria-label="Close the editor"]'))149 .expect(Selector('li.question h2').withText('Select your age').innerText).eql('Select your age')150 .expect(Selector('li.question h2.required').exists).notOk()151 .expect(Selector('li.question ul.no-bullet').childElementCount).eql(3)152 .expect(Selector('li.question li label').nth(0).innerText).eql(' under 18')153 .expect(Selector('li.question li input[type="radio"]').nth(0).value).eql('0')154 .expect(Selector('li.question li label').nth(1).innerText).eql(' 18 - 65')155 .expect(Selector('li.question li input[type="radio"]').nth(1).value).eql('1')156 .expect(Selector('li.question li label').nth(2).innerText).eql(' over 65')157 .expect(Selector('li.question li input[type="radio"]').nth(2).value).eql('2');158});159test('Create a required single choice horizontal list question', async (test) => {160 await test161 .click(Selector('a').withText('Experiments'))162 .click(Selector('a').withText('Experiment 2'))163 .click(Selector('a').withText('Pages'))164 .click(Selector('a').withText('Welcome'))165 .click(Selector('a').withText('Single-choice'))166 .expect(Selector('li.question').exists).ok()167 .click(Selector('li.question a[aria-label="Edit"]'))168 .typeText(Selector('label').withText('Title').find('input'), 'Select your age')169 .click(Selector('label').withText('Required').find('input'))170 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))171 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(0), '0')172 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))173 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(1), '1')174 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))175 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(2), '2')176 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))177 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(0), 'under 18', {paste: true})178 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))179 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(1), '18 - 65', {paste: true})180 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))181 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(2), 'over 65', {paste: true})182 .click(Selector('label').withText('Display').find('select'))183 .click(Selector('label').withText('Display').find('select option').withText('horizontal list'))184 .click(Selector('li.question a[aria-label="Save the question"]'))185 .click(Selector('li.question a[aria-label="Close the editor"]'))186 .expect(Selector('li.question h2.required').withText('Select your age').innerText).eql('Select your age')187 .expect(Selector('li.question table thead tr').childElementCount).eql(3)188 .expect(Selector('li.question table tbody tr').childElementCount).eql(3)189 .expect(Selector('li.question table thead th').nth(0).innerText).eql('under 18')190 .expect(Selector('li.question table tbody td input[type="radio"]').nth(0).value).eql('0')191 .expect(Selector('li.question table thead th').nth(1).innerText).eql('18 - 65')192 .expect(Selector('li.question table tbody td input[type="radio"]').nth(1).value).eql('1')193 .expect(Selector('li.question table thead th').nth(2).innerText).eql('over 65')194 .expect(Selector('li.question table tbody td input[type="radio"]').nth(2).value).eql('2');195});196test('Create an optional single choice horizontal list question', async (test) => {197 await test198 .click(Selector('a').withText('Experiments'))199 .click(Selector('a').withText('Experiment 2'))200 .click(Selector('a').withText('Pages'))201 .click(Selector('a').withText('Welcome'))202 .click(Selector('a').withText('Single-choice'))203 .expect(Selector('li.question').exists).ok()204 .click(Selector('li.question a[aria-label="Edit"]'))205 .typeText(Selector('label').withText('Title').find('input'), 'Select your age')206 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))207 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(0), '0')208 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))209 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(1), '1')210 .click(Selector('label').withText('Values').nextSibling().find('a[aria-label="Add a value"]'))211 .typeText(Selector('label').withText('Values').nextSibling().find('input').nth(2), '2')212 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))213 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(0), 'under 18', {paste: true})214 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))215 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(1), '18 - 65', {paste: true})216 .click(Selector('label').withText('Labels').nextSibling().find('a[aria-label="Add a value"]'))217 .typeText(Selector('label').withText('Labels').nextSibling().find('input').nth(2), 'over 65', {paste: true})218 .click(Selector('label').withText('Display').find('select'))219 .click(Selector('label').withText('Display').find('select option').withText('horizontal list'))220 .click(Selector('li.question a[aria-label="Save the question"]'))221 .click(Selector('li.question a[aria-label="Close the editor"]'))222 .expect(Selector('li.question h2').withText('Select your age').innerText).eql('Select your age')223 .expect(Selector('li.question table thead tr').childElementCount).eql(3)224 .expect(Selector('li.question table tbody tr').childElementCount).eql(3)225 .expect(Selector('li.question table thead th').nth(0).innerText).eql('under 18')226 .expect(Selector('li.question table tbody td input[type="radio"]').nth(0).value).eql('0')227 .expect(Selector('li.question table thead th').nth(1).innerText).eql('18 - 65')228 .expect(Selector('li.question table tbody td input[type="radio"]').nth(1).value).eql('1')229 .expect(Selector('li.question table thead th').nth(2).innerText).eql('over 65')230 .expect(Selector('li.question table tbody td input[type="radio"]').nth(2).value).eql('2');...

Full Screen

Full Screen

conditional.ts

Source: conditional.ts Github

copy

Full Screen

1import { Selector } from 'testcafe';2import { request, loadJSON } from '../​util';3fixture(`Frontend Conditional`).beforeEach(async (test) => {4 await request('http:/​/​localhost:6543/​tests/​create?obj=experiment6');5 await test6 .navigateTo('http:/​/​localhost:6543/​')7 .resizeWindow(1100, 800);8});9const h1 = Selector('h1');10const startExperiment = Selector('button').withText('Start');11const nextPage = Selector('button').withText('Next page');12const finishExperiment = Selector('button').withText('Finish');13const checkbox = Selector('input[type="checkbox"]');14const radio = Selector('input[type="radio"]');15const textarea = Selector('textarea')16const input = Selector('input')17test('Complete an experiment with conditional questions', async (test) => {18 await test19 .navigateTo('http:/​/​localhost:6543/​run/​experiment-6')20 .expect(h1.innerText).eql('Page 1 - Conditional on SingleChoice')21 .expect(Selector('p').withText('You selected A').exists).notOk()22 .expect(Selector('p').withText('You selected B').exists).notOk()23 .expect(Selector('p').withText('You selected C').exists).notOk()24 .click(radio.withAttribute('name', 'question-1').withAttribute('value', '0'))25 .expect(Selector('p').withText('You selected A').exists).ok()26 .expect(Selector('p').withText('You selected B').exists).notOk()27 .expect(Selector('p').withText('You selected C').exists).notOk()28 .click(radio.withAttribute('name', 'question-1').withAttribute('value', '1'))29 .expect(Selector('p').withText('You selected A').exists).notOk()30 .expect(Selector('p').withText('You selected B').exists).ok()31 .expect(Selector('p').withText('You selected C').exists).notOk()32 .click(radio.withAttribute('name', 'question-1').withAttribute('value', '2'))33 .expect(Selector('p').withText('You selected A').exists).notOk()34 .expect(Selector('p').withText('You selected B').exists).notOk()35 .expect(Selector('p').withText('You selected C').exists).ok()36 .click(startExperiment)37 .expect(h1.innerText).eql('Page 2 - Conditional on MultiChoice')38 .expect(Selector('p').withText('You selected A').exists).notOk()39 .expect(Selector('p').withText('You selected B').exists).notOk()40 .expect(Selector('p').withText('You selected C').exists).notOk()41 .click(checkbox.withAttribute('name', 'question-5').withAttribute('value', '0'))42 .expect(Selector('p').withText('You selected A').exists).ok()43 .expect(Selector('p').withText('You selected B').exists).notOk()44 .expect(Selector('p').withText('You selected C').exists).notOk()45 .click(checkbox.withAttribute('name', 'question-5').withAttribute('value', '1'))46 .expect(Selector('p').withText('You selected A').exists).ok()47 .expect(Selector('p').withText('You selected B').exists).ok()48 .expect(Selector('p').withText('You selected C').exists).notOk()49 .click(checkbox.withAttribute('name', 'question-5').withAttribute('value', '2'))50 .expect(Selector('p').withText('You selected A').exists).ok()51 .expect(Selector('p').withText('You selected B').exists).ok()52 .expect(Selector('p').withText('You selected C').exists).ok()53 .click(checkbox.withAttribute('name', 'question-5').withAttribute('value', '1'))54 .expect(Selector('p').withText('You selected A').exists).ok()55 .expect(Selector('p').withText('You selected B').exists).notOk()56 .expect(Selector('p').withText('You selected C').exists).ok()57 .click(nextPage)58 .expect(h1.innerText).eql('Page 3 - Conditional on Input')59 .expect(Selector('p').withText('That is correct').exists).notOk()60 .typeText(input.withAttribute('name', 'question-9'), '3')61 .expect(Selector('p').withText('That is correct').exists).ok()62 .typeText(input.withAttribute('name', 'question-9'), '5')63 .expect(Selector('p').withText('That is correct').exists).notOk()64 .click(nextPage)65 .expect(h1.innerText).eql('Page 4 - Conditional on SingleChoiceGrid')66 .expect(Selector('p').withText('Q1: You selected A').exists).notOk()67 .expect(Selector('p').withText('Q1: You selected B').exists).notOk()68 .expect(Selector('p').withText('Q1: You selected C').exists).notOk()69 .expect(Selector('p').withText('Q2: You selected A').exists).notOk()70 .expect(Selector('p').withText('Q2: You selected B').exists).notOk()71 .expect(Selector('p').withText('Q2: You selected C').exists).notOk()72 .click(radio.withAttribute('name', 'question-11.q1').withAttribute('value', '0'))73 .expect(Selector('p').withText('Q1: You selected A').exists).ok()74 .expect(Selector('p').withText('Q1: You selected B').exists).notOk()75 .expect(Selector('p').withText('Q1: You selected C').exists).notOk()76 .click(radio.withAttribute('name', 'question-11.q1').withAttribute('value', '1'))77 .expect(Selector('p').withText('Q1: You selected A').exists).notOk()78 .expect(Selector('p').withText('Q1: You selected B').exists).ok()79 .expect(Selector('p').withText('Q1: You selected C').exists).notOk()80 .click(radio.withAttribute('name', 'question-11.q1').withAttribute('value', '2'))81 .expect(Selector('p').withText('Q1: You selected A').exists).notOk()82 .expect(Selector('p').withText('Q1: You selected B').exists).notOk()83 .expect(Selector('p').withText('Q1: You selected C').exists).ok()84 .click(radio.withAttribute('name', 'question-11.q2').withAttribute('value', '0'))85 .expect(Selector('p').withText('Q2: You selected A').exists).ok()86 .expect(Selector('p').withText('Q2: You selected B').exists).notOk()87 .expect(Selector('p').withText('Q2: You selected C').exists).notOk()88 .click(radio.withAttribute('name', 'question-11.q2').withAttribute('value', '1'))89 .expect(Selector('p').withText('Q2: You selected A').exists).notOk()90 .expect(Selector('p').withText('Q2: You selected B').exists).ok()91 .expect(Selector('p').withText('Q2: You selected C').exists).notOk()92 .click(radio.withAttribute('name', 'question-11.q2').withAttribute('value', '2'))93 .expect(Selector('p').withText('Q2: You selected A').exists).notOk()94 .expect(Selector('p').withText('Q2: You selected B').exists).notOk()95 .expect(Selector('p').withText('Q2: You selected C').exists).ok()96 .click(nextPage)97 .expect(h1.innerText).eql('Page 5 - Conditional on MultiChoiceGrid')98 .expect(Selector('p').withText('Q1: You selected A').exists).notOk()99 .expect(Selector('p').withText('Q1: You selected B').exists).notOk()100 .expect(Selector('p').withText('Q1: You selected C').exists).notOk()101 .expect(Selector('p').withText('Q2: You selected A').exists).notOk()102 .expect(Selector('p').withText('Q2: You selected B').exists).notOk()103 .expect(Selector('p').withText('Q2: You selected C').exists).notOk()104 .click(checkbox.withAttribute('name', 'question-18.q1').withAttribute('value', '0'))105 .expect(Selector('p').withText('Q1: You selected A').exists).ok()106 .expect(Selector('p').withText('Q1: You selected B').exists).notOk()107 .expect(Selector('p').withText('Q1: You selected C').exists).notOk()108 .click(checkbox.withAttribute('name', 'question-18.q1').withAttribute('value', '1'))109 .expect(Selector('p').withText('Q1: You selected A').exists).ok()110 .expect(Selector('p').withText('Q1: You selected B').exists).ok()111 .expect(Selector('p').withText('Q1: You selected C').exists).notOk()112 .click(checkbox.withAttribute('name', 'question-18.q1').withAttribute('value', '2'))113 .expect(Selector('p').withText('Q1: You selected A').exists).ok()114 .expect(Selector('p').withText('Q1: You selected B').exists).ok()115 .expect(Selector('p').withText('Q1: You selected C').exists).ok()116 .click(checkbox.withAttribute('name', 'question-18.q1').withAttribute('value', '1'))117 .expect(Selector('p').withText('Q1: You selected A').exists).ok()118 .expect(Selector('p').withText('Q1: You selected B').exists).notOk()119 .expect(Selector('p').withText('Q1: You selected C').exists).ok()120 .click(checkbox.withAttribute('name', 'question-18.q2').withAttribute('value', '0'))121 .expect(Selector('p').withText('Q2: You selected A').exists).ok()122 .expect(Selector('p').withText('Q2: You selected B').exists).notOk()123 .expect(Selector('p').withText('Q2: You selected C').exists).notOk()124 .click(checkbox.withAttribute('name', 'question-18.q2').withAttribute('value', '1'))125 .expect(Selector('p').withText('Q2: You selected A').exists).ok()126 .expect(Selector('p').withText('Q2: You selected B').exists).ok()127 .expect(Selector('p').withText('Q2: You selected C').exists).notOk()128 .click(checkbox.withAttribute('name', 'question-18.q2').withAttribute('value', '2'))129 .expect(Selector('p').withText('Q2: You selected A').exists).ok()130 .expect(Selector('p').withText('Q2: You selected B').exists).ok()131 .expect(Selector('p').withText('Q2: You selected C').exists).ok()132 .click(checkbox.withAttribute('name', 'question-18.q2').withAttribute('value', '1'))133 .expect(Selector('p').withText('Q2: You selected A').exists).ok()134 .expect(Selector('p').withText('Q2: You selected B').exists).notOk()135 .expect(Selector('p').withText('Q2: You selected C').exists).ok()136 .click(finishExperiment)137 .expect(h1.innerText).eql('Responses saved');138 await request('http:/​/​localhost:6543/​tests/​assert?obj=participant&test=count&value=1');139 const msg = await loadJSON(await request('http:/​/​localhost:6543/​tests/​assert?obj=participant&test=exist'));140 await test141 .expect(msg.type).eql('participants')142 .expect(msg.attributes).ok()143 .expect(msg.attributes.responses).ok()144 .expect(msg.attributes.responses['1']['1']).eql('2')145 .expect(msg.attributes.responses['2']['5']).eql(['0', '2'])146 .expect(msg.attributes.responses['3']['9']).eql('35')147 .expect(msg.attributes.responses['4']['11'].q1).eql('2')148 .expect(msg.attributes.responses['4']['11'].q2).eql('2')149 .expect(msg.attributes.responses['5']['18'].q1).eql(['0', '2'])150 .expect(msg.attributes.responses['5']['18'].q2).eql(['0', '2'])...

Full Screen

Full Screen

permissions.ts

Source: permissions.ts Github

copy

Full Screen

1import { Selector } from 'testcafe';2import { request } from '../​util';3fixture('Experiment Permissions').beforeEach(async (test) => {4 await request('http:/​/​localhost:6543/​tests/​create?obj=experiment1&obj=experiment2&obj=user2&obj=experiment5');5 await test6 .navigateTo('http:/​/​localhost:6543/​')7 .resizeWindow(1100, 800)8 .click(Selector('a').withText('Sign in'))9 .expect(Selector('h1').innerText).eql('Sign in')10 .typeText(Selector('input[name="email"]'), 'test1@example.com')11 .typeText(Selector('input[name="password"]'), 'test1')12 .click(Selector('button').withText('Sign in'));13});14test('Access limited experiment 1', async (test) => {15 await test16 .click(Selector('a').withText('Experiments'))17 .click(Selector('a').withText('Experiment 1'))18 .expect(Selector('h1').withText('Experiment 1').innerText).eql('Experiment 1');19 await test20 .click(Selector('a').withText('Sign out'))21 .click(Selector('a').withText('Sign in'))22 .expect(Selector('h1').innerText).eql('Sign in')23 .typeText(Selector('input[name="email"]'), 'test2@example.com')24 .typeText(Selector('input[name="password"]'), 'test2')25 .click(Selector('button').withText('Sign in'))26 .click(Selector('a').withText('Experiments'))27 .expect(Selector('a').withText('Experiment 1').exists).notOk()28 .navigateTo('http:/​/​localhost:6543/​experiments/​1/​edit')29 .expect(Selector('h1').withText('403 - Forbidden').exists).ok();30});31test('Cannot delete single owner', async (test) => {32 await test33 .click(Selector('a').withText('Experiments'))34 .click(Selector('a').withText('Experiment 1'))35 .expect(Selector('h1').withText('Experiment 1').innerText).eql('Experiment 1')36 .click(Selector('a').withText('Settings'))37 .click(Selector('a').withText('Permissions'))38 .expect(Selector('svg').withAttribute('aria-label', 'This permission cannot be deleted')).ok()39 .expect(Selector('p').withText('This user owns this experiment').innerText).eql('This user owns this experiment. As there is only one owner, this cannot be changed.');40});41test('Add an author', async (test) => {42 await test43 .click(Selector('a').withText('Experiments'))44 .click(Selector('a').withText('Experiment 1'))45 .expect(Selector('h1').withText('Experiment 1').innerText).eql('Experiment 1')46 .click(Selector('a').withText('Settings'))47 .click(Selector('a').withText('Permissions'))48 .expect(Selector('svg').withAttribute('aria-label', 'This permission cannot be deleted')).ok()49 .expect(Selector('p').withText('This user owns this experiment').innerText).eql('This user owns this experiment. As there is only one owner, this cannot be changed.')50 .click(Selector('button').withText('Add permission'))51 .expect(Selector('button').withText("Don't add permission").exists).ok()52 .typeText(Selector('input[type="text"]'), 'test')53 .expect(Selector('ul.no-bullet > li > a').withText('Test 1').exists).notOk()54 .click(Selector('a').withText('Test 2'))55 .expect(Selector('ul.no-bullet.no-margin > li').childNodeCount).eql(2)56 .expect(Selector('.settings-permissions select').value).eql('author');57 await test58 .click(Selector('a').withText('Sign out'))59 .click(Selector('a').withText('Sign in'))60 .expect(Selector('h1').innerText).eql('Sign in')61 .typeText(Selector('input[name="email"]'), 'test2@example.com')62 .typeText(Selector('input[name="password"]'), 'test2')63 .click(Selector('button').withText('Sign in'))64 .click(Selector('a').withText('Experiments'))65 .click(Selector('a').withText('Experiment 1'))66 .expect(Selector('h1').withText('Experiment 1').innerText).eql('Experiment 1')67 .click(Selector('a').withText('Settings'))68 .expect(Selector('a').withText('Permissions').exists).notOk();69});70test('Add an owner', async (test) => {71 await test72 .click(Selector('a').withText('Experiments'))73 .click(Selector('a').withText('Experiment 1'))74 .expect(Selector('h1').withText('Experiment 1').innerText).eql('Experiment 1')75 .click(Selector('a').withText('Settings'))76 .click(Selector('a').withText('Permissions'))77 .expect(Selector('svg').withAttribute('aria-label', 'This permission cannot be deleted').exists).ok()78 .expect(Selector('p').withText('This user owns this experiment').innerText).eql('This user owns this experiment. As there is only one owner, this cannot be changed.')79 .click(Selector('button').withText('Add permission'))80 .expect(Selector('button').withText("Don't add permission").exists).ok()81 .typeText(Selector('input[type="text"]'), 'test')82 .expect(Selector('ul.no-bullet > li > a').withText('Test 1').exists).notOk()83 .click(Selector('a').withText('Test 2'))84 .expect(Selector('ul.no-bullet.no-margin > li').childNodeCount).eql(2)85 .click(Selector('.settings-permissions select'))86 .click(Selector('option').withAttribute('value', 'owner'))87 .expect(Selector('.settings-permissions select').count).eql(2)88 .expect(Selector('svg').withAttribute('aria-label', 'This permission cannot be deleted').exists).notOk()89 await test90 .click(Selector('a').withText('Sign out'))91 .click(Selector('a').withText('Sign in'))92 .expect(Selector('h1').innerText).eql('Sign in')93 .typeText(Selector('input[name="email"]'), 'test2@example.com')94 .typeText(Selector('input[name="password"]'), 'test2')95 .click(Selector('button').withText('Sign in'))96 .click(Selector('a').withText('Experiments'))97 .click(Selector('a').withText('Experiment 1'))98 .expect(Selector('h1').withText('Experiment 1').innerText).eql('Experiment 1')99 .click(Selector('a').withText('Settings'))100 .expect(Selector('a').withText('Permissions').exists).ok();101});102test('Add a tester', async (test) => {103 await test104 .click(Selector('a').withText('Experiments'))105 .click(Selector('a').withText('Experiment 5'))106 .expect(Selector('h1').withText('Experiment 5').innerText).eql('Experiment 5')107 .click(Selector('a').withText('Settings'))108 .click(Selector('a').withText('Permissions'))109 .expect(Selector('svg').withAttribute('aria-label', 'This permission cannot be deleted').exists).ok()110 .expect(Selector('p').withText('This user owns this experiment').innerText).eql('This user owns this experiment. As there is only one owner, this cannot be changed.')111 .click(Selector('button').withText('Add permission'))112 .expect(Selector('button').withText("Don't add permission").exists).ok()113 .typeText(Selector('input[type="text"]'), 'test')114 .expect(Selector('ul.no-bullet > li > a').withText('Test 2').exists).ok()115 .click(Selector('a').withText('Test 2'))116 .expect(Selector('ul.no-bullet.no-margin > li').childNodeCount).eql(2)117 .click(Selector('.settings-permissions select'))118 .click(Selector('option').withAttribute('value', 'tester'));119 await test120 .click(Selector('a').withText('Sign out'))121 .click(Selector('a').withText('Sign in'))122 .expect(Selector('h1').innerText).eql('Sign in')123 .typeText(Selector('input[name="email"]'), 'test2@example.com')124 .typeText(Selector('input[name="password"]'), 'test2')125 .click(Selector('button').withText('Sign in'))126 .click(Selector('a').withText('Experiments'))127 .expect(Selector('a').withText('Experiment 5').exists).notOk()128 .click(Selector('a').withText('Test the Experiment'))129 .expect(Selector('h1').innerText).eql('Welcome');130});131test('Development experiments are not publicly accessible', async (test) => {132 await test133 .click(Selector('a').withText('Sign out'))134 .navigateTo('http:/​/​localhost:6543/​run/​experiment-5')135 .expect(Selector('h1').withText('404 - Not Found').exists).ok();136 await test137 .navigateTo('http:/​/​localhost:6543/​')138 .click(Selector('a').withText('Sign in'))139 .expect(Selector('h1').innerText).eql('Sign in')140 .typeText(Selector('input[name="email"]'), 'test2@example.com')141 .typeText(Selector('input[name="password"]'), 'test2')142 .click(Selector('button').withText('Sign in'))143 .navigateTo('http:/​/​localhost:6543/​run/​experiment-5')144 .expect(Selector('h1').withText('404 - Not Found').exists).ok();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithText } from 'storybook-root';2const MyComponent = () => <WithText text="Hello Storybook" /​>;3export default MyComponent;4import { configure } from '@storybook/​react';5import { addDecorator } from '@storybook/​react';6import { withInfo } from '@storybook/​addon-info';7import { withKnobs } from '@storybook/​addon-knobs';8import { withA11y } from '@storybook/​addon-a11y';9import { withConsole } from '@storybook/​addon-console';10import { withTests } from '@storybook/​addon-jest';11import results from '../​.jest-test-results.json';12import { setOptions } from '@storybook/​addon-options';13import { setDefaults } from 'storybook-addon-jsx';14addDecorator(15 withInfo({16 styles: {17 infoBody: {18 },19 header: {20 h1: {21 },22 body: {23 },24 h2: {25 },26 },27 source: {28 h1: {29 },30 },31 propTableHead: {32 },33 },34 })35);36addDecorator(withKnobs);37addDecorator(withA11y);38addDecorator((storyFn, context) => withConsole()(storyFn)(context));39addDecorator(40 withTests({41 })42);43setOptions({

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithText } from 'storybook-root';2export default WithText('Hello Button', () => (3));4import React from 'react';5import PropTypes from 'prop-types';6const WithText = (text, story) => (7 {text}8 {story()}9);10WithText.propTypes = {11};12export default WithText;

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

A Complete Guide To CSS Container Queries

In 2007, Steve Jobs launched the first iPhone, which revolutionized the world. But because of that, many businesses dealt with the problem of changing the layout of websites from desktop to mobile by delivering completely different mobile-compatible websites under the subdomain of ‘m’ (e.g., https://m.facebook.com). And we were all trying to figure out how to work in this new world of contending with mobile and desktop screen sizes.

How To Use driver.FindElement And driver.FindElements In Selenium C#

One of the essential parts when performing automated UI testing, whether using Selenium or another framework, is identifying the correct web elements the tests will interact with. However, if the web elements are not located correctly, you might get NoSuchElementException in Selenium. This would cause a false negative result because we won’t get to the actual functionality check. Instead, our test will fail simply because it failed to interact with the correct element.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

Testing in Production: A Detailed Guide

When most firms employed a waterfall development model, it was widely joked about in the industry that Google kept its products in beta forever. Google has been a pioneer in making the case for in-production testing. Traditionally, before a build could go live, a tester was responsible for testing all scenarios, both defined and extempore, in a testing environment. However, this concept is evolving on multiple fronts today. For example, the tester is no longer testing alone. Developers, designers, build engineers, other stakeholders, and end users, both inside and outside the product team, are testing the product and providing feedback.

Different Ways To Style CSS Box Shadow Effects

Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful