canonical / lxd-ui

Easy and accessible container and virtual machine management. A browser interface for LXD
GNU General Public License v3.0
242 stars 30 forks source link

[WD-11114] Feat: Improving tests by using text assertion #789

Closed Kxiru closed 1 month ago

Kxiru commented 1 month ago

Done

export const assertTextVisible = async (
  page: Page,
  textValue: string,
  exact = false,
) => {
  const textLocator = page.getByText(textValue, { exact: exact });
  await expect(textLocator).toBeVisible();
};

QA

  1. Run the LXD-UI:
    • On the demo server via the link posted by @webteam-app below. This is only available for PRs created by collaborators of the repo. Ask @mas-who or @edlerd for access.
    • With a local copy of this branch, run as described here.
  2. Perform the following QA steps:
    • N/A

Screenshots

N/A

webteam-app commented 1 month ago

Demo

Jenkins

demos.haus

Kxiru commented 1 month ago

Observations from WD-11114:

edlerd commented 1 month ago
  • In projects.spec.ts , test "project edit configuration" fails for both lxd-5.0-edge and lxd-latest-edge but for different reasons. For 5.0-edge, the checkbox option "Network Zones" is expected to be hidden, but it is visible.

Did you run the 5.0-edge tests against a LXD backend from the 5.0/edge channel? The backend behaves differently depending on its version.

  • Continued from above, for lxd-latest-edge, the same test fails because "Clusters" does not exist on the page ("Cluster" does, but this does not hold any clusters and thus the test would still fail".

The cluster test relies on the clustering to be enabled. But be careful to enable it on your local host, it might block LXD on your machine in case the external ip changes -- which is not an expected behaviour for a cluster.

Kxiru commented 1 month ago
  • In projects.spec.ts , test "project edit configuration" fails for both lxd-5.0-edge and lxd-latest-edge but for different reasons. For 5.0-edge, the checkbox option "Network Zones" is expected to be hidden, but it is visible.

Did you run the 5.0-edge tests against a LXD backend from the 5.0/edge channel? The backend behaves differently depending on its version.

  • Continued from above, for lxd-latest-edge, the same test fails because "Clusters" does not exist on the page ("Cluster" does, but this does not hold any clusters and thus the test would still fail".

The cluster test relies on the clustering to be enabled. But be careful to enable it on your local host, it might block LXD on your machine in case the external ip changes -- which is not an expected behaviour for a cluster.

I'm not sure what this means. Are you referring to the different Playwright projects / browsers that the tests can be performed on? If so, yes.

edlerd commented 1 month ago

I'm not sure what this means. Are you referring to the different Playwright projects / browsers that the tests can be performed on? If so, yes.

The playwright tests for 5.0-edge are meant to run against a LXD backend with version 5.0 from the edge channel. If you run that test suite against a LXD version latest/stable or alike they will fail. You can check with lxd version in your back end.

I'd suggest to setup lxd inside a container or vm with various version (i.e. 1 container for 5.0 with snap refresh lxd --channel=5.0/edge or snap install lxd --channel=5.0/edge. Then another container with the latest/edge channel. And on the host you can keep the 5.21/stable version. That way you can switch out the LXD_UI_BACKEND_IP in your .env.local file between host and the two containers, then restart dotrun, and you have a backend with a different version in seconds.

mas-who commented 1 month ago

Looks good, thanks for doing this! :+1: Just one small clarification from my side.