Files

3.2 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5f8884f4c46685731aabfc41 Executar testes funcionais usando um navegador headless II 2 301594 run-functional-tests-using-a-headless-browser-ii

--description--

Lembrando que este projeto está sendo construído a partir do Replit, ou pose ser clonado no GitHub.

--instructions--

Em tests/2_functional-tests.js, no teste 'Submit the surname "Vespucci" in the HTML form' (// #5), automatize o seguinte:

  1. Preencha o formulário com o surname Vespucci
  2. Pressione o botão Submit

Na callback pressButton:

  1. Avalie se o status é OK 200
  2. Avalie se o texto dentro do elemento span#name é 'Amerigo'
  3. Avalie se o texto dentro do elemento span#surname é 'Vespucci'
  4. Avalie se o(s) elemento(s) span#dates existe(m) e sua contagem é 1

Não se esqueça de remover a chamada assert.fail().

--hints--

Todos os testes devem passar.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
    (data) => {
      assert.equal(data.state, 'passed');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

Você deve avaliar se a solicitação do navegador headless foi bem-sucedida.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
    (data) => {
      assert.equal(data.assertions[0].method, 'browser.success');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

Você deve avaliar se o texto dentro do elemento span#name é 'Amerigo'.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
    (data) => {
      assert.equal(data.assertions[1].method, 'browser.text');
      assert.match(data.assertions[1].args[0], /('|")span#name\1/);
      assert.match(data.assertions[1].args[1], /('|")Amerigo\1/);
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

Você deve avaliar se o texto dentro do elemento span#surname é 'Vespucci'.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
    (data) => {
      assert.equal(data.assertions[2].method, 'browser.text');
      assert.match(data.assertions[2].args[0], /('|")span#surname\1/);
      assert.match(data.assertions[2].args[1], /('|")Vespucci\1/);
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

Você deve avaliar se o elemento span#dates existe e que sua contagem é 1.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
    (data) => {
      assert.equal(data.assertions[3].method, 'browser.elements');
      assert.match(data.assertions[3].args[0], /('|")span#dates\1/);
      assert.equal(data.assertions[3].args[1], 1);
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

--solutions--

/**
  Backend challenges don't need solutions, 
  because they would need to be tested against a full working project. 
  Please check our contributing guidelines to learn more.
*/